КриптоПро .NET
Search Results for

    Показать/Скрыть содержание

    Class CpRSACryptoServiceProvider

    Inheritance
    object
    AsymmetricAlgorithm
    CpRSA
    CpRSACryptoServiceProvider
    Implements
    IDisposable
    ICpCspAsymmetricAlgorithm
    Inherited Members
    CpRSA.Create()
    CpRSA.Create(int)
    CpRSA.Create(RSAParameters)
    CpRSA.GetMaxOutputSize()
    CpRSA.SignHash(byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.VerifyHash(byte[], byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.TryDecrypt(ReadOnlySpan<byte>, Span<byte>, RSAEncryptionPadding, out int)
    CpRSA.TryEncrypt(ReadOnlySpan<byte>, Span<byte>, RSAEncryptionPadding, out int)
    CpRSA.Encrypt(ReadOnlySpan<byte>, RSAEncryptionPadding)
    CpRSA.Encrypt(ReadOnlySpan<byte>, Span<byte>, RSAEncryptionPadding)
    CpRSA.Decrypt(ReadOnlySpan<byte>, RSAEncryptionPadding)
    CpRSA.Decrypt(ReadOnlySpan<byte>, Span<byte>, RSAEncryptionPadding)
    CpRSA.TrySignHash(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding, out int)
    CpRSA.VerifyHash(ReadOnlySpan<byte>, ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignData(byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignData(byte[], int, int, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignData(Stream, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.TrySignData(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding, out int)
    CpRSA.SignData(ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignData(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignHash(ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.SignHash(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.VerifyData(byte[], byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.VerifyData(byte[], int, int, byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.VerifyData(Stream, byte[], CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)
    CpRSA.ExportRSAPrivateKey()
    CpRSA.TryExportRSAPrivateKey(Span<byte>, out int)
    CpRSA.ExportRSAPublicKey()
    CpRSA.TryExportRSAPublicKey(Span<byte>, out int)
    CpRSA.TryExportSubjectPublicKeyInfo(Span<byte>, out int)
    CpRSA.TryExportPkcs8PrivateKey(Span<byte>, out int)
    CpRSA.TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char>, PbeParameters, Span<byte>, out int)
    CpRSA.TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte>, PbeParameters, Span<byte>, out int)
    CpRSA.ImportRSAPublicKey(ReadOnlySpan<byte>, out int)
    CpRSA.ImportRSAPrivateKey(ReadOnlySpan<byte>, out int)
    CpRSA.ImportPkcs8PrivateKey(ReadOnlySpan<byte>, out int)
    CpRSA.ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte>, ReadOnlySpan<byte>, out int)
    CpRSA.ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char>, ReadOnlySpan<byte>, out int)
    CpRSA.ImportFromPem(ReadOnlySpan<char>)
    CpRSA.ImportFromEncryptedPem(ReadOnlySpan<char>, ReadOnlySpan<char>)
    CpRSA.ImportFromEncryptedPem(ReadOnlySpan<char>, ReadOnlySpan<byte>)
    CpRSA.ExportRSAPrivateKeyPem()
    CpRSA.ExportRSAPublicKeyPem()
    CpRSA.TryExportRSAPrivateKeyPem(Span<char>, out int)
    CpRSA.TryExportRSAPublicKeyPem(Span<char>, out int)
    AsymmetricAlgorithm.Clear()
    AsymmetricAlgorithm.Create(string)
    AsymmetricAlgorithm.Dispose()
    AsymmetricAlgorithm.ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte>, PbeParameters)
    AsymmetricAlgorithm.ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char>, PbeParameters)
    AsymmetricAlgorithm.ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<byte>, PbeParameters)
    AsymmetricAlgorithm.ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char>, PbeParameters)
    AsymmetricAlgorithm.ExportPkcs8PrivateKey()
    AsymmetricAlgorithm.ExportPkcs8PrivateKeyPem()
    AsymmetricAlgorithm.ExportSubjectPublicKeyInfo()
    AsymmetricAlgorithm.ExportSubjectPublicKeyInfoPem()
    AsymmetricAlgorithm.FromXmlString(string)
    AsymmetricAlgorithm.ToXmlString(bool)
    AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<byte>, PbeParameters, Span<char>, out int)
    AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char>, PbeParameters, Span<char>, out int)
    AsymmetricAlgorithm.TryExportPkcs8PrivateKeyPem(Span<char>, out int)
    AsymmetricAlgorithm.TryExportSubjectPublicKeyInfoPem(Span<char>, out int)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: CryptoPro.Security.Cryptography
    Assembly: CryptoPro.Security.Cryptography.dll
    Syntax
    public sealed class CpRSACryptoServiceProvider : CpRSA, IDisposable, ICpCspAsymmetricAlgorithm

    Constructors

    CpRSACryptoServiceProvider()

    Declaration
    public CpRSACryptoServiceProvider()

    CpRSACryptoServiceProvider(CpCspParameters)

    Declaration
    public CpRSACryptoServiceProvider(CpCspParameters parameters)
    Parameters
    Type Name Description
    CpCspParameters parameters

    CpRSACryptoServiceProvider(int)

    Declaration
    public CpRSACryptoServiceProvider(int dwKeySize)
    Parameters
    Type Name Description
    int dwKeySize

    CpRSACryptoServiceProvider(int, CpCspParameters)

    Declaration
    public CpRSACryptoServiceProvider(int dwKeySize, CpCspParameters parameters)
    Parameters
    Type Name Description
    int dwKeySize
    CpCspParameters parameters

    Properties

    CipherOid

    Параметры шифрования

    Declaration
    public string CipherOid { get; set; }
    Property Value
    Type Description
    string

    ContainerCertificate

    Получение/установка сертификата в конейнер.

    Declaration
    public byte[] ContainerCertificate { get; set; }
    Property Value
    Type Description
    byte[]

    Возвращается хранимый сертификат или null, если сертификат в контейнере отсутствует.

    CspKeyContainerInfo

    Получает информацию о CSP CspKeyContainerInfo, в котором хранится ключевая пара.

    Declaration
    public CpCspKeyContainerInfo CspKeyContainerInfo { get; }
    Property Value
    Type Description
    CpCspKeyContainerInfo

    Handle

    Gets a copy to a native HCRYPTPROV handle.

    Declaration
    public nint Handle { get; }
    Property Value
    Type Description
    nint

    HandleNoDuplicate

    Gets a native HCRYPTPROV handle.

    Declaration
    public nint HandleNoDuplicate { get; }
    Property Value
    Type Description
    nint

    KeyExchangeAlgorithm

    When overridden in a derived class, gets the name of the key exchange algorithm. Otherwise, throws an NotImplementedException.

    Declaration
    public override string KeyExchangeAlgorithm { get; }
    Property Value
    Type Description
    string

    The name of the key exchange algorithm.

    Overrides
    CpRSA.KeyExchangeAlgorithm

    KeySize

    Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.

    Declaration
    public override int KeySize { get; }
    Property Value
    Type Description
    int

    The size, in bits, of the key modulus used by the asymmetric algorithm.

    Overrides
    AsymmetricAlgorithm.KeySize
    Exceptions
    Type Condition
    CryptographicException

    The key modulus size is invalid.

    KeySpec

    Gets a key specification.

    Declaration
    public int KeySpec { get; }
    Property Value
    Type Description
    int

    LegalKeySizes

    Gets the key sizes that are supported by the asymmetric algorithm.

    Declaration
    public override KeySizes[] LegalKeySizes { get; }
    Property Value
    Type Description
    KeySizes[]

    An array that contains the key sizes supported by the asymmetric algorithm.

    Overrides
    AsymmetricAlgorithm.LegalKeySizes

    NotAfter

    Срок действия закртытого ключа, указанного в KP_NOTAFTER

    Declaration
    public DateTimeOffset NotAfter { get; }
    Property Value
    Type Description
    DateTimeOffset

    PublicOnly

    Получает значение, указывающее, не содержит ли объект Gost3410_2012_256CryptoServiceProvider только открытый ключ.

    Declaration
    public bool PublicOnly { get; }
    Property Value
    Type Description
    bool

    true, если Gost3410_2012_256CryptoServiceProvider содержит только открытый ключ, false - иначе.

    SignatureAlgorithm

    When implemented in a derived class, gets the name of the signature algorithm. Otherwise, always throws a NotImplementedException.

    Declaration
    public override string SignatureAlgorithm { get; }
    Property Value
    Type Description
    string

    The name of the signature algorithm.

    Overrides
    CpRSA.SignatureAlgorithm

    UseMachineKeyStore

    Возвращает или устанавливает флаг того, что ключ должен храниться в STORE ключей компьютера, а не в профиле пользователя.

    Declaration
    public static bool UseMachineKeyStore { get; set; }
    Property Value
    Type Description
    bool

    true, если ключ должен храниться в банке ключей компьютера, false - иначе.

    Remarks

    Данный флаг устанавливает использование ключей из STORE пользователя или компьютера при открытии ключей без указания данного флага. Установка данного флага эквивалентна передаче установке флага UseMachineKeyStore в CspParameters. Свойство UseMachineKeyStore устанавливается для всего кода в текущем домене, в то время как CspParameters применимо только к объекту на который он ссылается. Установка/сброс данного флага полезна при имперсонализации или работе без загруженного профиля пользователя.

    При инициализации объекта через конструктор CpRSACryptoServiceProvider(CpCspParameters) будут использованы именно эти параметры, в независимости от флага UseMachineKeyStore. По умолчанию значение флага из CpRSACryptoServiceProvider(CpCspParameters) устанавливется в использование ключей из хранилищи пользователя. Для использования ключей из хранилища компьютера при использовании конструктора CpRSACryptoServiceProvider(CpCspParameters) необходимо установить флаг Flags: UseMachineKeyStore.

    Methods

    Decrypt(byte[], bool)

    Decrypt raw data, generally used for decrypting symmetric key material

    Declaration
    public byte[] Decrypt(byte[] rgb, bool fOAEP)
    Parameters
    Type Name Description
    byte[] rgb

    encrypted data

    bool fOAEP

    true to use OAEP padding (PKCS #1 v2), false to use PKCS #1 type 2 padding

    Returns
    Type Description
    byte[]

    decrypted data

    Decrypt(byte[], RSAEncryptionPadding)

    Declaration
    public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding)
    Parameters
    Type Name Description
    byte[] data
    RSAEncryptionPadding padding
    Returns
    Type Description
    byte[]
    Overrides
    CpRSA.Decrypt(byte[], RSAEncryptionPadding)

    Dispose(bool)

    Dispose the key handles

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    AsymmetricAlgorithm.Dispose(bool)

    Encrypt(byte[], bool)

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

    Declaration
    public byte[] Encrypt(byte[] rgb, bool fOAEP)
    Parameters
    Type Name Description
    byte[] rgb

    raw data to encrypt

    bool fOAEP

    true to use OAEP padding (PKCS #1 v2), false to use PKCS #1 type 2 padding

    Returns
    Type Description
    byte[]

    Encrypted key

    Remarks

    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.

    Encrypt(byte[], RSAEncryptionPadding)

    Declaration
    public override byte[] Encrypt(byte[] data, RSAEncryptionPadding padding)
    Parameters
    Type Name Description
    byte[] data
    RSAEncryptionPadding padding
    Returns
    Type Description
    byte[]
    Overrides
    CpRSA.Encrypt(byte[], RSAEncryptionPadding)

    ExportCspBlob()

    Declaration
    public byte[] ExportCspBlob()
    Returns
    Type Description
    byte[]

    ExportCspBlob(bool)

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

    Declaration
    public byte[] ExportCspBlob(bool includePrivateParameters)
    Parameters
    Type Name Description
    bool includePrivateParameters
    Returns
    Type Description
    byte[]

    ExportParameters(bool)

    Exports the RSAParameters

    Declaration
    public override RSAParameters ExportParameters(bool includePrivateParameters)
    Parameters
    Type Name Description
    bool includePrivateParameters
    Returns
    Type Description
    RSAParameters
    Overrides
    CpRSA.ExportParameters(bool)

    ImportCspBlob(byte[])

    Imports a blob that represents RSA key information

    Declaration
    public void ImportCspBlob(byte[] keyBlob)
    Parameters
    Type Name Description
    byte[] keyBlob

    ImportParameters(RSAParameters)

    Imports the specified RSAParameters

    Declaration
    public override void ImportParameters(RSAParameters parameters)
    Parameters
    Type Name Description
    RSAParameters parameters
    Overrides
    CpRSA.ImportParameters(RSAParameters)

    ImportSubjectPublicKeyInfo(ReadOnlySpan<byte>, out int)

    When overriden in a derived class, imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

    Declaration
    public override void ImportSubjectPublicKeyInfo(ReadOnlySpan<byte> source, out int bytesRead)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> source

    The bytes of an X.509 SubjectPublicKeyInfo structure in the ASN.1-DER encoding.

    int bytesRead

    When this method returns, contains a value that indicates the number of bytes read from source. This parameter is treated as uninitialized.

    Overrides
    CpRSA.ImportSubjectPublicKeyInfo(ReadOnlySpan<byte>, out int)
    Exceptions
    Type Condition
    CryptographicException

    The contents of source do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure.

    -or-

    The contents of source indicate the key is for an algorithm other than the algorithm represented by this instance.

    -or-

    The contents of source represent the key in a format that is not supported.

    -or-

    The algorithm-specific key import failed.

    NotImplementedException

    A derived type has not overriden this member.

    SignData(byte[], int, int, object)

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

    Declaration
    public byte[] SignData(byte[] buffer, int offset, int count, object halg)
    Parameters
    Type Name Description
    byte[] buffer

    The input data for which to compute the hash

    int offset

    The offset into the array from which to begin using data

    int count

    The number of bytes in the array to use as data.

    object halg

    The hash algorithm to use to create the hash value.

    Returns
    Type Description
    byte[]

    The RSA signature for the specified data.

    SignData(byte[], object)

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

    Declaration
    public byte[] SignData(byte[] buffer, object halg)
    Parameters
    Type Name Description
    byte[] buffer

    The input data for which to compute the hash

    object halg

    The hash algorithm to use to create the hash value.

    Returns
    Type Description
    byte[]

    The RSA signature for the specified data.

    SignData(Stream, object)

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

    Declaration
    public byte[] SignData(Stream inputStream, object halg)
    Parameters
    Type Name Description
    Stream inputStream

    The input data for which to compute the hash

    object halg

    The hash algorithm to use to create the hash value.

    Returns
    Type Description
    byte[]

    The RSA signature for the specified data.

    SignHash(byte[], string?)

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

    Declaration
    public byte[] SignHash(byte[] rgbHash, string? str)
    Parameters
    Type Name Description
    byte[] rgbHash

    The input data for which to compute the hash

    string str

    The hash algorithm to use to create the hash value.

    Returns
    Type Description
    byte[]

    The RSA signature for the specified data.

    TrySignHashCore(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding, out int)

    Declaration
    protected override bool TrySignHashCore(ReadOnlySpan<byte> rgbHash, Span<byte> signature, CpHashAlgorithmName hashAlgorithm, RSASignaturePadding padding, out int bytesWritten)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> rgbHash
    Span<byte> signature
    CpHashAlgorithmName hashAlgorithm
    RSASignaturePadding padding
    int bytesWritten
    Returns
    Type Description
    bool
    Overrides
    CpRSA.TrySignHashCore(ReadOnlySpan<byte>, Span<byte>, CpHashAlgorithmName, RSASignaturePadding, out int)

    VerifyHashCore(ReadOnlySpan<byte>, ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)

    Verifies that a digital signature is valid for the provided hash.

    Declaration
    protected override bool VerifyHashCore(ReadOnlySpan<byte> rgbHash, ReadOnlySpan<byte> rgbSignature, CpHashAlgorithmName hashAlgorithmName, RSASignaturePadding padding)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> rgbHash
    ReadOnlySpan<byte> rgbSignature
    CpHashAlgorithmName hashAlgorithmName
    RSASignaturePadding padding
    Returns
    Type Description
    bool

    true if the digital signature is valid for the provided data; otherwise, false.

    Overrides
    CpRSA.VerifyHashCore(ReadOnlySpan<byte>, ReadOnlySpan<byte>, CpHashAlgorithmName, RSASignaturePadding)
    Exceptions
    Type Condition
    CryptographicException

    An error occurred in the verification operation.

    Implements

    IDisposable
    ICpCspAsymmetricAlgorithm
    В этом разделе
    Наверх Generated by DocFX