RSACng Class

.NET Framework (current version)
 

Provides a Cryptography Next Generation (CNG) implementation of the RSA algorithm.

Namespace:   System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)


public ref class RSACng sealed : RSA

NameDescription
System_CAPS_pubmethodRSACng()

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

System_CAPS_pubmethodRSACng(CngKey^)

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

System_CAPS_pubmethodRSACng(Int32)

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

NameDescription
System_CAPS_pubpropertyKey

Gets the key that will be used by the RSACng object for any cryptographic operation that it performs.

System_CAPS_pubpropertyKeyExchangeAlgorithm

Gets the name of the key exchange algorithm available with this implementation of RSA.(Overrides RSA::KeyExchangeAlgorithm.)

System_CAPS_pubpropertyKeySize

Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.(Inherited from AsymmetricAlgorithm.)

System_CAPS_pubpropertyLegalKeySizes

Gets the key sizes that are supported by the asymmetric algorithm.(Inherited from AsymmetricAlgorithm.)

System_CAPS_pubpropertySignatureAlgorithm

Gets the name of the signature algorithm available with this implementation of RSA.(Overrides RSA::SignatureAlgorithm.)

NameDescription
System_CAPS_pubmethodClear()

Releases all resources used by the AsymmetricAlgorithm class.(Inherited from AsymmetricAlgorithm.)

System_CAPS_pubmethodDecrypt(array<Byte>^, RSAEncryptionPadding^)

Decrypts input data using the specified padding mode.(Overrides RSA::Decrypt(array<Byte>^, RSAEncryptionPadding^).)

System_CAPS_pubmethodDecryptValue(array<Byte>^)

Decrypts the input data using the private key.(Overrides RSA::DecryptValue(array<Byte>^).)

System_CAPS_pubmethodDispose()

Releases all resources used by the current instance of the AsymmetricAlgorithm class.(Inherited from AsymmetricAlgorithm.)

System_CAPS_pubmethodEncrypt(array<Byte>^, RSAEncryptionPadding^)

Encrypts the input data using the specified padding.(Overrides RSA::Encrypt(array<Byte>^, RSAEncryptionPadding^).)

System_CAPS_pubmethodEncryptValue(array<Byte>^)

Encrypts the input data using the public key.(Overrides RSA::EncryptValue(array<Byte>^).)

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodExportParameters(Boolean)

Exports the key used by the RSA object into a RSAParameters object. (Overrides RSA::ExportParameters(Boolean).)

System_CAPS_pubmethodFromXmlString(String^)

Initializes an RSA object from the key information from an XML string.(Inherited from RSA.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodImportParameters(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).)

System_CAPS_pubmethodSignData(array<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.)

System_CAPS_pubmethodSignData(array<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.)

System_CAPS_pubmethodSignData(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.)

System_CAPS_pubmethodSignHash(array<Byte>^, HashAlgorithmName, RSASignaturePadding^)

Signs data that was hashed by using the specified hashing algorithm and padding mode.(Overrides RSA::SignHash(array<Byte>^, HashAlgorithmName, RSASignaturePadding^).)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodToXmlString(Boolean)

Creates and returns an XML string containing the key of the current RSA object.(Inherited from RSA.)

System_CAPS_pubmethodVerifyData(array<Byte>^, array<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.)

System_CAPS_pubmethodVerifyData(array<Byte>^, Int32, Int32, array<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.)

System_CAPS_pubmethodVerifyData(Stream^, array<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.)

System_CAPS_pubmethodVerifyHash(array<Byte>^, array<Byte>^, HashAlgorithmName, RSASignaturePadding^)

Verifies data that was signed and already hashed with the specified algorithm and padding mode. (Overrides RSA::VerifyHash(array<Byte>^, array<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.

.NET Framework
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.

Return to top
Show: