C# Класс System.Security.Cryptography.RSACryptoServiceProvider

Наследование: RSA, ICspAsymmetricAlgorithm
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
AcquireSafeProviderHandle System.Security.Cryptography.SafeProvHandle
GetAlgorithmId int
GetHashAlgorithm HashAlgorithm
HashAlgorithmNameNullOrEmpty Exception
IsPublic bool
IsPublic bool
PaddingModeNotSupported Exception
RSACryptoServiceProvider System.Diagnostics
SignHash byte[]
VerifyHash bool

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

Dispose the key handles

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

Приватные методы

Метод Описание
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.

Описание методов

Decrypt() публичный Метод

public Decrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
data byte
padding RSAEncryptionPadding
Результат byte[]

Decrypt() публичный Метод

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
Результат byte[]

Dispose() защищенный Метод

Dispose the key handles
protected Dispose ( bool disposing ) : void
disposing bool
Результат void

Encrypt() публичный Метод

public Encrypt ( byte data, RSAEncryptionPadding padding ) : byte[]
data byte
padding RSAEncryptionPadding
Результат byte[]

Encrypt() публичный Метод

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
Результат byte[]

ExportCspBlob() публичный Метод

Exports a blob containing the key information associated with an RSACryptoServiceProvider object.
public ExportCspBlob ( bool includePrivateParameters ) : byte[]
includePrivateParameters bool
Результат byte[]

ExportParameters() публичный Метод

Exports the RSAParameters
public ExportParameters ( bool includePrivateParameters ) : RSAParameters
includePrivateParameters bool
Результат RSAParameters

HashData() защищенный Метод

protected HashData ( Stream data, HashAlgorithmName hashAlgorithm ) : byte[]
data System.IO.Stream
hashAlgorithm HashAlgorithmName
Результат byte[]

HashData() защищенный Метод

protected HashData ( byte data, int offset, int count, HashAlgorithmName hashAlgorithm ) : byte[]
data byte
offset int
count int
hashAlgorithm HashAlgorithmName
Результат byte[]

ImportCspBlob() публичный Метод

Imports a blob that represents RSA key information
public ImportCspBlob ( byte keyBlob ) : void
keyBlob byte
Результат void

ImportParameters() публичный Метод

Imports the specified RSAParameters
public ImportParameters ( RSAParameters parameters ) : void
parameters RSAParameters
Результат void

RSACryptoServiceProvider() публичный Метод

public RSACryptoServiceProvider ( ) : System.Diagnostics
Результат System.Diagnostics

RSACryptoServiceProvider() публичный Метод

public RSACryptoServiceProvider ( CspParameters parameters ) : System.Diagnostics
parameters CspParameters
Результат System.Diagnostics

RSACryptoServiceProvider() публичный Метод

public RSACryptoServiceProvider ( int dwKeySize ) : System.Diagnostics
dwKeySize int
Результат System.Diagnostics

RSACryptoServiceProvider() публичный Метод

public RSACryptoServiceProvider ( int dwKeySize, CspParameters parameters ) : System.Diagnostics
dwKeySize int
parameters CspParameters
Результат System.Diagnostics

SignData() публичный Метод

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.
Результат byte[]

SignData() публичный Метод

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.
Результат byte[]

SignData() публичный Метод

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.
Результат byte[]

SignHash() публичный Метод

public SignHash ( byte hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : byte[]
hash byte
hashAlgorithm HashAlgorithmName
padding RSASignaturePadding
Результат byte[]

SignHash() публичный Метод

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.
Результат byte[]

VerifyData() публичный Метод

Verifies the signature of a hash value.
public VerifyData ( byte buffer, object halg, byte signature ) : bool
buffer byte
halg object
signature byte
Результат bool

VerifyHash() публичный Метод

public VerifyHash ( byte hash, byte signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : bool
hash byte
signature byte
hashAlgorithm HashAlgorithmName
padding RSASignaturePadding
Результат bool

VerifyHash() публичный Метод

Verifies the signature of a hash value.
public VerifyHash ( byte rgbHash, string str, byte rgbSignature ) : bool
rgbHash byte
str string
rgbSignature byte
Результат bool