RSACng Constructors

Definition

Initializes a new instance of the RSACng class.

Overloads

RSACng()

Initializes a new instance of the RSACng class with a random 2,048-bit key pair.

RSACng(Int32)

Initializes a new instance of the RSACng class with a randomly generated key of the specified size.

RSACng(CngKey)

Initializes a new instance of the RSACng class with the specified key.

RSACng()

Initializes a new instance of the RSACng class with a random 2,048-bit key pair.

public:
 RSACng();
public RSACng ();
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public RSACng ();
Public Sub New ()
Attributes

Remarks

This constructor does not generate a new public/private keypair immediately. This constructor sets the KeySize property to 2048 and when a key is needed one is generated using the property value. If a key is loaded via the ImportParameters method, or other key import method, the key size from this constructor has no meaning.

Applies to

RSACng(Int32)

Initializes a new instance of the RSACng class with a randomly generated key of the specified size.

public:
 RSACng(int keySize);
public RSACng (int keySize);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public RSACng (int keySize);
new System.Security.Cryptography.RSACng : int -> System.Security.Cryptography.RSACng
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
new System.Security.Cryptography.RSACng : int -> System.Security.Cryptography.RSACng
Public Sub New (keySize As Integer)

Parameters

keySize
Int32

The size of the key to generate in bits.

Attributes

Exceptions

keySize is not valid.

Remarks

Valid key sizes range from 384 to 16,384 bits, in increments of 8. We recommend that a minimum size of 2,048 bits be used for all keys.

This constructor does not generate a new public/private keypair immediately. This constructor sets the KeySize property to keySize and when a key is needed one is generated using the property value. If a key is loaded via the ImportParameters method, or other key import method, the key size from this constructor has no meaning.

Applies to

RSACng(CngKey)

Initializes a new instance of the RSACng class with the specified key.

public:
 RSACng(System::Security::Cryptography::CngKey ^ key);
public RSACng (System.Security.Cryptography.CngKey key);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public RSACng (System.Security.Cryptography.CngKey key);
new System.Security.Cryptography.RSACng : System.Security.Cryptography.CngKey -> System.Security.Cryptography.RSACng
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
new System.Security.Cryptography.RSACng : System.Security.Cryptography.CngKey -> System.Security.Cryptography.RSACng
Public Sub New (key As CngKey)

Parameters

key
CngKey

The key to use for RSA operations.

Attributes

Exceptions

key is not a valid RSA key.

key is null.

Remarks

The CngKey.AlgorithmGroup of key must be CngAlgorithmGroup.Rsa.

This constructor creates a copy of the key. Even if key is disposed, the copy of this key object in RSA remains alive.

Applies to