Export (0) Print
Expand All
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.

RSACryptoServiceProvider Class

July 28, 2014

Performs asymmetric encryption and decryption using the implementation of the RSA algorithm provided by the cryptographic service provider (CSP). This class cannot be inherited.

System.Object
  System.Security.Cryptography.AsymmetricAlgorithm
    System.Security.Cryptography.RSA
      System.Security.Cryptography.RSACryptoServiceProvider

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

public sealed class RSACryptoServiceProvider : RSA, 
	ICspAsymmetricAlgorithm

The RSACryptoServiceProvider type exposes the following members.

  NameDescription
Public methodRSACryptoServiceProvider()Initializes a new instance of the RSACryptoServiceProvider class using the default key.
Public methodRSACryptoServiceProvider(CspParameters)Initializes a new instance of the RSACryptoServiceProvider class with the specified parameters.
Public methodRSACryptoServiceProvider(Int32)Initializes a new instance of the RSACryptoServiceProvider class with the specified key size.
Public methodRSACryptoServiceProvider(Int32, CspParameters)Initializes a new instance of the RSACryptoServiceProvider class with the specified key size and parameters.
Top

  NameDescription
Public propertyCspKeyContainerInfoGets a CspKeyContainerInfo object that describes additional information about a cryptographic key pair.
Public propertyKeyExchangeAlgorithmGets the name of the key exchange algorithm available with this implementation of RSA. (Overrides AsymmetricAlgorithm.KeyExchangeAlgorithm.)
Public propertyKeySizeGets the size of the current key. (Overrides AsymmetricAlgorithm.KeySize.)
Public propertyLegalKeySizes (Inherited from AsymmetricAlgorithm.)
Public propertyPersistKeyInCspGets or sets a value indicating whether the key should be persisted in the cryptographic service provider (CSP).
Public propertyPublicOnlyGets a value that indicates whether the RSACryptoServiceProvider object contains only a public key.
Public propertySignatureAlgorithmGets the name of the signature algorithm available with this implementation of RSA. (Overrides AsymmetricAlgorithm.SignatureAlgorithm.)
Public propertyStatic memberUseMachineKeyStoreGets or sets a value indicating whether the key should be persisted in the computer's key store instead of the user profile store.
Top

  NameDescription
Public methodClear (Inherited from AsymmetricAlgorithm.)
Public methodDecryptDecrypts data with the RSA algorithm.
Public methodDecryptValueThis method is not supported in the current version. (Overrides RSA.DecryptValue(Byte[]).)
Public methodDispose() (Inherited from AsymmetricAlgorithm.)
Protected methodDispose(Boolean) (Inherited from AsymmetricAlgorithm.)
Public methodEncryptEncrypts data with the RSA algorithm.
Public methodEncryptValueThis method is not supported in the current version. (Overrides RSA.EncryptValue(Byte[]).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodExportCspBlobSecurity Critical. Exports a blob containing the key information associated with an RSACryptoServiceProvider object.
Public methodExportParametersExports the RSAParameters. (Overrides RSA.ExportParameters(Boolean).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodFromXmlStringInitializes an RSA object from the key information from an XML string. (Inherited from RSA.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodImportCspBlobSecurity Critical. Imports a blob that represents RSA key information.
Public methodImportParametersImports the specified RSAParameters. (Overrides RSA.ImportParameters(RSAParameters).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSignData(Byte[], Object)Computes the hash value of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
Public methodSignData(Stream, Object)Computes the hash value of the specified input stream using the specified hash algorithm, and signs the resulting hash value.
Public methodSignData(Byte[], Int32, Int32, Object)Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
Public methodSignHashComputes the signature for the specified hash value by encrypting it with the private key.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodToXmlStringCreates and returns an XML string containing the key of the current RSA object. (Inherited from RSA.)
Public methodVerifyDataVerifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the hash value of the provided data.
Public methodVerifyHashVerifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the provided hash value.
Top

  NameDescription
Protected fieldKeySizeValue (Inherited from AsymmetricAlgorithm.)
Protected fieldLegalKeySizesValue (Inherited from AsymmetricAlgorithm.)
Top

This is the default implementation of RSA.

 In Windows Phone, the RSACryptoServiceProvider supports key lengths from 384 bits to 4800 bits in increments of 8 bits.

Interoperation with the Microsoft Cryptographic API (CAPI)

Unlike the RSA implementation in unmanaged CAPI, the RSACryptoServiceProvider class reverses the order of an encrypted array of bytes after encryption and before decryption. By default, data encrypted by the RSACryptoServiceProvider class cannot be decrypted by the CAPI CryptDecrypt function and data encrypted by the CAPI CryptEncrypt method cannot be decrypted by the RSACryptoServiceProvider class.

If you do not compensate for the reverse ordering when interoperating between APIs, the RSACryptoServiceProvider class throws a CryptographicException.

To interoperate with CAPI, you must manually reverse the order of encrypted bytes before the encrypted data interoperates with another API. You can easily reverse the order of a managed byte array by calling the Array.Reverse method.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft