RSACng Class
Provides a Cryptography Next Generation (CNG) implementation of the RSA algorithm.
Assembly: System.Core (in System.Core.dll)
System.Security.Cryptography.AsymmetricAlgorithm
System.Security.Cryptography.RSA
System.Security.Cryptography.RSACng
| Name | Description | |
|---|---|---|
![]() | RSACng() | Initializes a new instance of the RSACng class with a random 2,048-bit key pair. |
![]() | RSACng(CngKey) | Initializes a new instance of the RSACng class with the specified key. |
![]() | RSACng(Int32) | Initializes a new instance of the RSACng class with a randomly generated key of the specified size. |
| Name | Description | |
|---|---|---|
![]() | Key | Gets the key that will be used by the RSACng object for any cryptographic operation that it performs. |
![]() | KeyExchangeAlgorithm | Gets the name of the key exchange algorithm available with this implementation of RSA.(Overrides RSA.KeyExchangeAlgorithm.) |
![]() | KeySize | Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.(Inherited from AsymmetricAlgorithm.) |
![]() | LegalKeySizes | Gets the key sizes that are supported by the asymmetric algorithm.(Inherited from AsymmetricAlgorithm.) |
![]() | SignatureAlgorithm | Gets the name of the signature algorithm available with this implementation of RSA.(Overrides RSA.SignatureAlgorithm.) |
| Name | Description | |
|---|---|---|
![]() | Clear() | Releases all resources used by the AsymmetricAlgorithm class.(Inherited from AsymmetricAlgorithm.) |
![]() | Decrypt(Byte(), RSAEncryptionPadding) | Decrypts input data using the specified padding mode.(Overrides RSA.Decrypt(Byte(), RSAEncryptionPadding).) |
![]() | DecryptValue(Byte()) | Decrypts the input data using the private key.(Overrides RSA.DecryptValue(Byte()).) |
![]() | Dispose() | Releases all resources used by the current instance of the AsymmetricAlgorithm class.(Inherited from AsymmetricAlgorithm.) |
![]() | Encrypt(Byte(), RSAEncryptionPadding) | Encrypts the input data using the specified padding.(Overrides RSA.Encrypt(Byte(), RSAEncryptionPadding).) |
![]() | EncryptValue(Byte()) | Encrypts the input data using the public key.(Overrides RSA.EncryptValue(Byte()).) |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | ExportParameters(Boolean) | Exports the key used by the RSA object into a RSAParameters object. (Overrides RSA.ExportParameters(Boolean).) |
![]() | FromXmlString(String) | |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ImportParameters(RSAParameters) | Replaces the existing key that the current instance is working with by creating a new CngKey for the parameters structure. (Overrides RSA.ImportParameters(RSAParameters).) |
![]() | SignData(Byte(), HashAlgorithmName, RSASignaturePadding) | Computes the hash value of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value. (Inherited from RSA.) |
![]() | SignData(Byte(), Int32, Int32, HashAlgorithmName, RSASignaturePadding) | Computes the hash value of a portion of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value. (Inherited from RSA.) |
![]() | SignData(Stream, HashAlgorithmName, RSASignaturePadding) | Computes the hash value of the specified stream using the specified hash algorithm and padding mode, and signs the resulting hash value.(Inherited from RSA.) |
![]() | SignHash(Byte(), HashAlgorithmName, RSASignaturePadding) | Signs data that was hashed by using the specified hashing algorithm and padding mode.(Overrides RSA.SignHash(Byte(), HashAlgorithmName, RSASignaturePadding).) |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
![]() | ToXmlString(Boolean) | |
![]() | VerifyData(Byte(), Byte(), HashAlgorithmName, RSASignaturePadding) | Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and padding, and comparing it to the provided signature. (Inherited from RSA.) |
![]() | VerifyData(Byte(), Int32, Int32, Byte(), HashAlgorithmName, RSASignaturePadding) | Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and padding, and comparing it to the provided signature. (Inherited from RSA.) |
![]() | VerifyData(Stream, Byte(), HashAlgorithmName, RSASignaturePadding) | Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and padding, and comparing it to the provided signature. (Inherited from RSA.) |
![]() | VerifyHash(Byte(), Byte(), HashAlgorithmName, RSASignaturePadding) | Verifies data that was signed and already hashed with the specified algorithm and padding mode. (Overrides RSA.VerifyHash(Byte(), Byte(), HashAlgorithmName, RSASignaturePadding).) |
The RSACng class is derived from the RSA class. Therefore, it is not a drop-in replacement for existing uses of RSACryptoServiceProvider.
RSACng uses a programming model that is similar to the ECDsaCng class rather than the RSACryptoServiceProvider class. For example:
The key used by RSACng is managed by a separate CngKey object. In contrast, RSACryptoServiceProvider has a key that is directly tied to the operations of the type itself.
RSACng performs such operations as signing and verifying signatures by using properties of the RSACng object, just as ECDsaCng uses its object properties to control signing and verification operations.
Available since 4.6
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

