RSACryptoServiceProvider Class
NuGet: GHIElectronics.TinyCLR.Cryptography
Assembly: System.Security.Cryptography
Namespace: System.Security.Cryptography
Concrete RSA implementation. Construct with the desired key size or with externally supplied RSAParameters.
public sealed class RSACryptoServiceProvider : RSA
Constructors
RSACryptoServiceProvider()
public RSACryptoServiceProvider()
Creates an RSA provider with the default key size.
RSACryptoServiceProvider(int dwKeySize)
public RSACryptoServiceProvider(int dwKeySize)
Creates an RSA provider with the given key size, in bits.
Properties
KeySize
public override int KeySize { get; set; }
The key size, in bits. Set it via the constructor.
KeyExchangeAlgorithm
public override string KeyExchangeAlgorithm { get; }
Name of the key-exchange algorithm.
Methods
ExportParameters(bool includePrivateParameters)
public override RSAParameters ExportParameters(bool includePrivateParameters)
Exports the RSA key, optionally including the private parameters.
Returns RSAParameters
ImportParameters(RSAParameters parameters)
public override void ImportParameters(RSAParameters parameters)
Imports the given RSA key parameters.
Encrypt(byte[] data, RSAEncryptionPadding padding)
public override byte[] Encrypt(byte[] data, RSAEncryptionPadding padding)
Encrypts data with the public key. Only PKCS#1 padding is supported.
Returns byte[]
Decrypt(byte[] data, RSAEncryptionPadding padding)
public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding)
Decrypts data with the private key. Only PKCS#1 padding is supported.
Returns byte[]
SignData(byte[] data, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override byte[] SignData(byte[] data, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
Signs data with the private key. Only PKCS#1 padding is supported.
Returns byte[]
SignHash(byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override byte[] SignHash(byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
Signs a precomputed hash with the private key. Only PKCS#1 padding is supported.
Returns byte[]
VerifyData(byte[] data, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override bool VerifyData(byte[] data, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
Verifies a data signature against the public key. Only PKCS#1 padding is supported.
Returns bool
VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
public override bool VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
Verifies a hash signature against the public key. Only PKCS#1 padding is supported.
Returns bool
Encrypt(byte[] rgb, bool fOAEP)
public byte[] Encrypt(byte[] rgb, bool fOAEP)
Encrypts data with the public key (legacy overload). OAEP is not supported.
Returns byte[]
Decrypt(byte[] rgb, bool fOAEP)
public byte[] Decrypt(byte[] rgb, bool fOAEP)
Decrypts data with the private key (legacy overload). OAEP is not supported.
Returns byte[]
SignData(byte[] buffer, bool sha256)
public byte[] SignData(byte[] buffer, bool sha256 = false)
Signs data with the private key (legacy overload). Set sha256 to use SHA-256 instead of SHA-1.
Returns byte[]
VerifyData(byte[] buffer, byte[] signature, bool sha256)
public bool VerifyData(byte[] buffer, byte[] signature, bool sha256 = false)
Verifies a data signature (legacy overload). Set sha256 to use SHA-256 instead of SHA-1.
Returns bool
Dispose()
public override void Dispose()
Releases the resources used by the provider.