C# Class System.Security.Cryptography.RSACryptoServiceProvider

Inheritance: RSA, ICspAsymmetricAlgorithm
Afficher le fichier Open project: dotnet/corefx Class Usage Examples

Private Properties

Свойство Type Description
AcquireSafeProviderHandle System.Security.Cryptography.SafeProvHandle
GetAlgorithmId int
GetHashAlgorithm HashAlgorithm
HashAlgorithmNameNullOrEmpty Exception
IsPublic bool
IsPublic bool
PaddingModeNotSupported Exception
RSACryptoServiceProvider System.Diagnostics
SignHash byte[]
VerifyHash bool

Méthodes publiques

Méthode Description
Decrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
Decrypt ( byte rgb, bool fOAEP ) : byte[]

Decrypt raw data, generally used for decrypting symmetric key material

Encrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
Encrypt ( byte rgb, bool fOAEP ) : byte[]

Encrypt raw data, generally used for encrypting symmetric key material.

This method can only encrypt (keySize - 88 bits) of data, so should not be used for encrypting arbitrary byte arrays. Instead, encrypt a symmetric key with this method, and use the symmetric key to encrypt the sensitive data.

ExportCspBlob ( bool includePrivateParameters ) : byte[]

Exports a blob containing the key information associated with an RSACryptoServiceProvider object.

ExportParameters ( bool includePrivateParameters ) : RSAParameters

Exports the RSAParameters

ImportCspBlob ( byte keyBlob ) : void

Imports a blob that represents RSA key information

ImportParameters ( RSAParameters parameters ) : void

Imports the specified RSAParameters

RSACryptoServiceProvider ( ) : System.Diagnostics
RSACryptoServiceProvider ( CspParameters parameters ) : System.Diagnostics
RSACryptoServiceProvider ( int dwKeySize ) : System.Diagnostics
RSACryptoServiceProvider ( int dwKeySize, CspParameters parameters ) : System.Diagnostics
SignData ( Stream inputStream, Object halg ) : byte[]

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

SignData ( byte buffer, Object halg ) : byte[]

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

SignData ( byte buffer, int offset, int count, object halg ) : byte[]

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

SignHash ( byte hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : byte[]
SignHash ( byte rgbHash, string str ) : byte[]

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

VerifyData ( byte buffer, object halg, byte signature ) : bool

Verifies the signature of a hash value.

VerifyHash ( byte hash, byte signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : bool
VerifyHash ( byte rgbHash, string str, byte rgbSignature ) : bool

Verifies the signature of a hash value.

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void

Dispose the key handles

HashData ( Stream data, HashAlgorithmName hashAlgorithm ) : byte[]
HashData ( byte data, int offset, int count, HashAlgorithmName hashAlgorithm ) : byte[]

Private Methods

Méthode Description
AcquireSafeProviderHandle ( ) : System.Security.Cryptography.SafeProvHandle

This method helps Acquire the default CSP and avoids the need for static SafeProvHandle in CapiHelper class

GetAlgorithmId ( HashAlgorithmName hashAlgorithm ) : int
GetHashAlgorithm ( HashAlgorithmName hashAlgorithm ) : HashAlgorithm
HashAlgorithmNameNullOrEmpty ( ) : Exception
IsPublic ( RSAParameters rsaParams ) : bool

Since P is required, we will assume its presence is synonymous to a private key.

IsPublic ( byte keyBlob ) : bool

find whether an RSA key blob is public.

PaddingModeNotSupported ( ) : Exception
RSACryptoServiceProvider ( int keySize, CspParameters parameters, bool useDefaultKeySize ) : System.Diagnostics
SignHash ( byte rgbHash, int calgHash ) : byte[]

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.

VerifyHash ( byte rgbHash, int calgHash, byte rgbSignature ) : bool

Verifies the signature of a hash value.

Method Details

Decrypt() public méthode

public Decrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
data byte
padding RSAEncryptionPadding
Résultat byte[]

Decrypt() public méthode

Decrypt raw data, generally used for decrypting symmetric key material
public Decrypt ( byte rgb, bool fOAEP ) : byte[]
rgb byte encrypted data
fOAEP bool true to use OAEP padding (PKCS #1 v2), false to use PKCS #1 type 2 padding
Résultat byte[]

Dispose() protected méthode

Dispose the key handles
protected Dispose ( bool disposing ) : void
disposing bool
Résultat void

Encrypt() public méthode

public Encrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
data byte
padding RSAEncryptionPadding
Résultat byte[]

Encrypt() public méthode

Encrypt raw data, generally used for encrypting symmetric key material.
This method can only encrypt (keySize - 88 bits) of data, so should not be used for encrypting arbitrary byte arrays. Instead, encrypt a symmetric key with this method, and use the symmetric key to encrypt the sensitive data.
public Encrypt ( byte rgb, bool fOAEP ) : byte[]
rgb byte raw data to encrypt
fOAEP bool true to use OAEP padding (PKCS #1 v2), false to use PKCS #1 type 2 padding
Résultat byte[]

ExportCspBlob() public méthode

Exports a blob containing the key information associated with an RSACryptoServiceProvider object.
public ExportCspBlob ( bool includePrivateParameters ) : byte[]
includePrivateParameters bool
Résultat byte[]

ExportParameters() public méthode

Exports the RSAParameters
public ExportParameters ( bool includePrivateParameters ) : RSAParameters
includePrivateParameters bool
Résultat RSAParameters

HashData() protected méthode

protected HashData ( Stream data, HashAlgorithmName hashAlgorithm ) : byte[]
data System.IO.Stream
hashAlgorithm HashAlgorithmName
Résultat byte[]

HashData() protected méthode

protected HashData ( byte data, int offset, int count, HashAlgorithmName hashAlgorithm ) : byte[]
data byte
offset int
count int
hashAlgorithm HashAlgorithmName
Résultat byte[]

ImportCspBlob() public méthode

Imports a blob that represents RSA key information
public ImportCspBlob ( byte keyBlob ) : void
keyBlob byte
Résultat void

ImportParameters() public méthode

Imports the specified RSAParameters
public ImportParameters ( RSAParameters parameters ) : void
parameters RSAParameters
Résultat void

RSACryptoServiceProvider() public méthode

public RSACryptoServiceProvider ( ) : System.Diagnostics
Résultat System.Diagnostics

RSACryptoServiceProvider() public méthode

public RSACryptoServiceProvider ( CspParameters parameters ) : System.Diagnostics
parameters CspParameters
Résultat System.Diagnostics

RSACryptoServiceProvider() public méthode

public RSACryptoServiceProvider ( int dwKeySize ) : System.Diagnostics
dwKeySize int
Résultat System.Diagnostics

RSACryptoServiceProvider() public méthode

public RSACryptoServiceProvider ( int dwKeySize, CspParameters parameters ) : System.Diagnostics
dwKeySize int
parameters CspParameters
Résultat System.Diagnostics

SignData() public méthode

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
public SignData ( Stream inputStream, Object halg ) : byte[]
inputStream System.IO.Stream The input data for which to compute the hash
halg Object The hash algorithm to use to create the hash value.
Résultat byte[]

SignData() public méthode

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
public SignData ( byte buffer, Object halg ) : byte[]
buffer byte The input data for which to compute the hash
halg Object The hash algorithm to use to create the hash value.
Résultat byte[]

SignData() public méthode

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
public SignData ( byte buffer, int offset, int count, object halg ) : byte[]
buffer byte The input data for which to compute the hash
offset int The offset into the array from which to begin using data
count int The number of bytes in the array to use as data.
halg object The hash algorithm to use to create the hash value.
Résultat byte[]

SignHash() public méthode

public SignHash ( byte hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : byte[]
hash byte
hashAlgorithm HashAlgorithmName
padding RSASignaturePadding
Résultat byte[]

SignHash() public méthode

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
public SignHash ( byte rgbHash, string str ) : byte[]
rgbHash byte The input data for which to compute the hash
str string The hash algorithm to use to create the hash value.
Résultat byte[]

VerifyData() public méthode

Verifies the signature of a hash value.
public VerifyData ( byte buffer, object halg, byte signature ) : bool
buffer byte
halg object
signature byte
Résultat bool

VerifyHash() public méthode

public VerifyHash ( byte hash, byte signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : bool
hash byte
signature byte
hashAlgorithm HashAlgorithmName
padding RSASignaturePadding
Résultat bool

VerifyHash() public méthode

Verifies the signature of a hash value.
public VerifyHash ( byte rgbHash, string str, byte rgbSignature ) : bool
rgbHash byte
str string
rgbSignature byte
Résultat bool