Performs asymmetric encryption and decryption using the implementation of the System.Security.Cryptography.RSA algorithm provided by the cryptographic service provider (CSP). This class cannot be inherited.
See Also: RSACryptoServiceProvider Members
This is the default implementation of System.Security.Cryptography.RSA.
The System.Security.Cryptography.RSACryptoServiceProvider supports key sizes from 384 bits to 16384 bits in increments of 8 bits if you have the Microsoft Enhanced Cryptographic Provider installed. It supports key sizes from 384 bits to 512 bits in increments of 8 bits if you have the Microsoft Base Cryptographic Provider installed.
Valid key sizes are dependent on the cryptographic service provider (CSP) that is used by the System.Security.Cryptography.RSACryptoServiceProvider instance. Windows CSPs enable keys sizes of 384 to 16384 bits for Windows versions prior to win81, and key sizes of 512 to 16384 bits for win81. For more information, see tp://msdn.microsoft.com/library/aa379941(v=vs.85) function in the Windows documentation.
Unlike the RSA implementation in unmanaged CAPI, the System.Security.Cryptography.RSACryptoServiceProvider class reverses the order of an encrypted array of bytes after encryption and before decryption. By default, data encrypted by the System.Security.Cryptography.RSACryptoServiceProvider class cannot be decrypted by the CAPI CryptDecrypt function and data encrypted by the CAPI CryptEncrypt method cannot be decrypted by the System.Security.Cryptography.RSACryptoServiceProvider class.
If you do not compensate for the reverse ordering when interoperating between APIs, the System.Security.Cryptography.RSACryptoServiceProvider class throws a System.Security.Cryptography.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(Array) method.