RSAParameters Struct


Represents the standard parameters for the RSA algorithm.

public value class RSAParameters
public struct RSAParameters
public struct RSAParameters
public struct RSAParameters
type RSAParameters = struct
type RSAParameters = struct
type RSAParameters = struct
Public Structure RSAParameters


The RSA class exposes an ExportParameters method that enables you to retrieve the raw RSA key in the form of an RSAParameters structure. Understanding the contents of this structure requires familiarity with how the RSA algorithm works. The next section discusses the algorithm briefly.

RSA algorithm

To generate a key pair, you start by creating two large prime numbers named p and q. These numbers are multiplied and the result is called n. Because p and q are both prime numbers, the only factors of n are 1, p, q, and n.

If we consider only numbers that are less than n, the count of numbers that are relatively prime to n, that is, have no factors in common with n, equals (p - 1)(q - 1).

Now you choose a number e, which is relatively prime to the value you calculated. The public key is now represented as {e, n}.

To create the private key, you must calculate d, which is a number such that (d)(e) mod (p - 1)(q - 1) = 1. In accordance with the Euclidean algorithm, the private key is now {d, n}.

Encryption of plaintext m to ciphertext c is defined as c = (m ^ e) mod n. Decryption would then be defined as m = (c ^ d) mod n.

Summary of fields

Section A.1.2 of the PKCS #1: RSA Cryptography Standard defines a format for RSA private keys.

The following table summarizes the fields of the RSAParameters structure. The third column provides the corresponding field in section A.1.2 of PKCS #1: RSA Cryptography Standard.

RSAParameters field Contains Corresponding PKCS #1 field
D d, the private exponent privateExponent
DP d mod (p - 1) exponent1
DQ d mod (q - 1) exponent2
Exponent e, the public exponent publicExponent
InverseQ (InverseQ)(q) = 1 mod p coefficient
Modulus n modulus
P p prime1
Q q prime2

The security of RSA derives from the fact that, given the public key { e, n }, it is computationally infeasible to calculate d, either directly or by factoring n into p and q. Therefore, any part of the key related to d, p, or q must be kept secret. If you call ExportParameters and ask for only the public key information, this is why you will receive only Exponent and Modulus. The other fields are available only if you have access to the private key, and you request it.

RSAParameters is not encrypted in any way, so you must be careful when you use it with the private key information. All members of RSAParameters are serialized. If anyone can derive or intercept the private key parameters, the key and all the information encrypted or signed with it are compromised.



Represents the D parameter for the RSA algorithm.


Represents the DP parameter for the RSA algorithm.


Represents the DQ parameter for the RSA algorithm.


Represents the Exponent parameter for the RSA algorithm.


Represents the InverseQ parameter for the RSA algorithm.


Represents the Modulus parameter for the RSA algorithm.


Represents the P parameter for the RSA algorithm.


Represents the Q parameter for the RSA algorithm.

Applies to

See also