Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RSAParameters Structure

Represents the standard parameters for the RSA algorithm.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib.Extensions (in mscorlib.Extensions.dll)

[SerializableAttribute]
[ComVisibleAttribute(false)]
public struct RSAParameters

The RSAParameters type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneEqualsIndicates whether this instance and a specified object are equal. (Inherited from ValueType.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeReturns the hash code for this instance. (Inherited from ValueType.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns the fully qualified type name of this instance. (Inherited from ValueType.)
Top

  NameDescription
Public fieldSupported by Silverlight for Windows PhoneDRepresents the D parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneDPRepresents the DP parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneDQRepresents the DQ parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneExponentRepresents the Exponent parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneInverseQRepresents the InverseQ parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneModulusRepresents the Modulus parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhonePRepresents the P parameter for the RSA algorithm.
Public fieldSupported by Silverlight for Windows PhoneQRepresents the Q parameter for the RSA algorithm.
Top

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 on the RSA Laboratories Web site 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. In fact, none of the fields that contain private key information can be serialized. If you try to serialize an RSAParameters structure with a remoting call or by using one of the serializers, you will receive only public key information. If you want to pass private key information, you will have to manually send that data. In all cases, if anyone can derive the parameters, the key that you transmit becomes useless.

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft