RSACng 类

定义

提供 RSA 算法的下一代加密(CNG)实现。

public ref class RSACng sealed : System::Security::Cryptography::RSA
public sealed class RSACng : System.Security.Cryptography.RSA
type RSACng = class
    inherit RSA
Public NotInheritable Class RSACng
Inherits RSA
继承

注解

RSACng 类派生自 RSA 该类。 因此,它不是现有用途的 RSACryptoServiceProvider下降替代。

RSACng使用类似于类而不是类的ECDsaCng编程模型RSACryptoServiceProvider。 例如:

  • 所使用的 RSACng 密钥由单独的 CngKey 对象管理。 相比之下, RSACryptoServiceProvider 具有直接绑定到类型本身操作的键。

  • RSACng 使用对象的属性 RSACng 执行签名和验证签名等操作,就像使用对象属性来控制签名和验证操作一样 ECDsaCng

注释

RSACng 类是使用 Windows CNG 库的 RSA 算法的实现,在除 Windows 以外的操作系统上不可用。 对于未执行Windows互操作的应用程序,建议使用 RSA.Create,而不是直接引用此类型。

构造函数

名称 说明
RSACng()

使用随机 2,048 位密钥对初始化类的新实例 RSACng

RSACng(CngKey)

使用指定的键初始化类的新实例 RSACng

RSACng(Int32)

使用指定大小的随机生成的键初始化类的新实例 RSACng

字段

名称 说明
KeySizeValue

表示非对称算法使用的键模数的大小(以位为单位)。

(继承自 AsymmetricAlgorithm)
LegalKeySizesValue

指定非对称算法支持的密钥大小。

(继承自 AsymmetricAlgorithm)

属性

名称 说明
Key

获取对象将用于 RSACng 其执行的任何加密操作的密钥。

KeyExchangeAlgorithm

获取此 RSA 实现中可用的密钥交换算法的名称。

KeyExchangeAlgorithm

获取此实现 RSA中可用的密钥交换算法的名称。

(继承自 RSA)
KeySize

获取或设置非对称算法使用的键模数的大小(以位为单位)。

(继承自 AsymmetricAlgorithm)
LegalKeySizes

获取此 RSA 实现支持的键大小(以位为单位)。

LegalKeySizes

获取非对称算法支持的密钥大小。

(继承自 AsymmetricAlgorithm)
SignatureAlgorithm

获取此 RSA 实现中可用的签名算法的名称。

SignatureAlgorithm

获取此实现 RSA可用的签名算法的名称。

(继承自 RSA)

方法

名称 说明
Clear()

释放类使用 AsymmetricAlgorithm 的所有资源。

(继承自 AsymmetricAlgorithm)
Decrypt(Byte[], RSAEncryptionPadding)

使用指定的填充模式解密输入数据。

Decrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

使用指定的填充模式解密输入数据。

(继承自 RSA)
Decrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding)

使用指定的填充模式解密输入数据。

(继承自 RSA)
DecryptValue(Byte[])

使用私钥解密输入数据。

DecryptValue(Byte[])
已过时.

在派生类中重写时,使用私钥解密输入数据。

(继承自 RSA)
Dispose()

释放类的 AsymmetricAlgorithm 当前实例使用的所有资源。

(继承自 AsymmetricAlgorithm)
Dispose(Boolean)

释放类使用 AsymmetricAlgorithm 的非托管资源,并选择性地释放托管资源。

(继承自 AsymmetricAlgorithm)
Encrypt(Byte[], RSAEncryptionPadding)

使用指定的填充加密输入数据。

Encrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

使用指定的填充模式加密输入数据。

(继承自 RSA)
Encrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding)

使用指定的填充模式加密输入数据。

(继承自 RSA)
EncryptValue(Byte[])

使用公钥加密输入数据。

EncryptValue(Byte[])
已过时.

在派生类中重写时,使用公钥加密输入数据。

(继承自 RSA)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用基于字节的密码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用基于字节的密码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用基于字符的密码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用基于字符的密码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters)

使用基于字节的密码 PEM 编码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters)

使用基于字符的密码 PEM 编码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportParameters(Boolean)

将 RSA 对象使用的密钥导出到对象 RSAParameters 中。

ExportPkcs8PrivateKey()

导出 PKCS#8 PrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
ExportPkcs8PrivateKeyPem()

导出 PKCS#8 PrivateKeyInfo 格式的当前密钥(已编码 PEM)。

(继承自 AsymmetricAlgorithm)
ExportRSAPrivateKey()

导出 PKCS#1 RSAPrivateKey 格式的当前密钥。

(继承自 RSA)
ExportRSAPrivateKeyPem()

导出 PKCS#1 RSAPrivateKey 格式(PEM 编码)中的当前密钥。

(继承自 RSA)
ExportRSAPublicKey()

以 PKCS#1 RSAPublicKey 格式导出当前密钥的公钥部分。

(继承自 RSA)
ExportRSAPublicKeyPem()

以 PKCS#1 RSAPublicKey 格式(PEM 编码)导出当前密钥的公钥部分。

(继承自 RSA)
ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式导出当前密钥的公钥部分。

(继承自 AsymmetricAlgorithm)
ExportSubjectPublicKeyInfoPem()

以 X.509 SubjectPublicKeyInfo 格式(PEM 编码)导出当前密钥的公钥部分。

(继承自 AsymmetricAlgorithm)
FromXmlString(String)

RSA从 XML 字符串中的键信息初始化对象。

(继承自 RSA)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetMaxOutputSize()

获取 RSA 操作可以生成的最大字节数。

(继承自 RSA)
GetType()

获取当前实例的 Type

(继承自 Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName)

在派生类中重写时,使用指定的哈希算法计算字节数组的指定部分的哈希值。

(继承自 RSA)
HashData(Stream, HashAlgorithmName)

在派生类中重写时,使用指定的哈希算法计算指定的二进制流的哈希值。

(继承自 RSA)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

使用基于字节的密码解密后,从 PKCS#8 EncryptedPrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

使用基于字节的密码解密后,从 PKCS#8 EncryptedPrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

(继承自 RSA)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用基于字符的密码解密后,从 PKCS#8 EncryptedPrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用基于字符的密码解密后,从 PKCS#8 EncryptedPrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

(继承自 RSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

导入加密的 RFC 7468 PEM 编码私钥,替换此对象的密钥。

(继承自 RSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

导入加密的 RFC 7468 PEM 编码私钥,替换此对象的密钥。

(继承自 RSA)
ImportFromPem(ReadOnlySpan<Char>)

导入 RFC 7468 PEM 编码的密钥,替换此对象的密钥。

(继承自 RSA)
ImportParameters(RSAParameters)

通过为参数结构创建新 CngKey 项,替换当前实例正在使用的现有键。

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#8 PrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#8 PrivateKeyInfo 结构导入公钥/私钥对,替换此对象的密钥。

(继承自 RSA)
ImportRSAPrivateKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#1 RSAPrivateKey 结构导入公钥/私钥对,替换此对象的密钥。

(继承自 RSA)
ImportRSAPublicKey(ReadOnlySpan<Byte>, Int32)

解密后,从 PKCS#1 RSAPublicKey 结构导入公钥,替换此对象的密钥。

(继承自 RSA)
ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

解密后,从 X.509 SubjectPublicKeyInfo 结构导入公钥,替换此对象的密钥。

(继承自 RSA)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节数组的哈希值,并对生成的哈希值进行签名。

(继承自 RSA)
SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定字节数组的一部分的哈希值,并对生成的哈希值进行签名。

(继承自 RSA)
SignData(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

计算指定数据的哈希值并对其进行签名。

(继承自 RSA)
SignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

使用指定的算法计算所提供的数据的哈希,并使用当前密钥对哈希进行签名,并将签名写入提供的缓冲区。

(继承自 RSA)
SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式计算指定流的哈希值,并对生成的哈希值进行签名。

(继承自 RSA)
SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的哈希算法和填充模式对已哈希处理的数据进行签名。

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

使用指定的填充计算指定哈希值的签名。

(继承自 RSA)
SignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

使用当前密钥对哈希进行签名,将签名写入提供的缓冲区。

(继承自 RSA)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
ToXmlString(Boolean)

创建并返回包含当前 RSA 对象的键的 XML 字符串。

(继承自 RSA)
TryDecrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

使用私钥解密数据。

TryDecrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

尝试使用指定的填充模式解密输入数据,将结果写入提供的缓冲区。

(继承自 RSA)
TryEncrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

使用公钥加密数据。

TryEncrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

尝试使用指定的填充模式将输入数据加密为提供的缓冲区。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字节的密码将 PKCS#8 EncryptedPrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字节的密码将 PKCS#8 EncryptedPrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字符的密码将 PKCS#8 EncryptedPrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字符的密码将 PKCS#8 EncryptedPrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

尝试使用基于字节的密码 PEM 编码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

使用基于字符的密码 PEM 编码导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。

(继承自 AsymmetricAlgorithm)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

尝试将 PKCS#8 PrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

TryExportPkcs8PrivateKey(Span<Byte>, Int32)

尝试将 PKCS#8 PrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportPkcs8PrivateKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#8 PrivateKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 AsymmetricAlgorithm)
TryExportRSAPrivateKey(Span<Byte>, Int32)

尝试将 PKCS#1 RSAPrivateKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportRSAPrivateKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#1 RSAPrivateKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportRSAPublicKey(Span<Byte>, Int32)

尝试将 PKCS#1 RSAPublicKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportRSAPublicKeyPem(Span<Char>, Int32)

尝试将 PEM 编码的 PKCS#1 RSAPublicKey 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

尝试将 X.509 SubjectPublicKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 RSA)
TryExportSubjectPublicKeyInfoPem(Span<Char>, Int32)

尝试将 PEM 编码的 X.509 SubjectPublicKeyInfo 格式中的当前密钥导出到提供的缓冲区中。

(继承自 AsymmetricAlgorithm)
TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

尝试使用指定的算法计算所提供的数据的哈希,将结果写入提供的缓冲区。

(继承自 RSA)
TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32)

尝试使用指定的算法对所提供的数据进行哈希处理,并使用当前密钥对哈希进行签名,并将签名写入提供的缓冲区。

(继承自 RSA)
TrySignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32)

尝试使用当前密钥对哈希进行签名,将签名写入提供的缓冲区。

TrySignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding, Int32)

尝试使用当前密钥对哈希进行签名,将签名写入提供的缓冲区。

(继承自 RSA)
VerifyData(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充计算指定数据的哈希值并将其与提供的签名进行比较,验证数字签名是否有效。

(继承自 RSA)
VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充计算字节数组中某个部分数据的哈希值并将其与提供的签名进行比较,验证数字签名是否有效。

(继承自 RSA)
VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充计算指定数据的哈希值并将其与提供的签名进行比较,验证数字签名是否有效。

(继承自 RSA)
VerifyData(Stream, Byte[], HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充计算指定流的哈希值并将其与提供的签名进行比较,验证数字签名是否有效。

(继承自 RSA)
VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

验证已签名且已使用指定算法和填充模式进行哈希处理的数据。

VerifyHash(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充来确定签名中的哈希值并将其与提供的哈希值进行比较,验证数字签名是否有效。

VerifyHash(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

通过使用指定的哈希算法和填充来确定签名中的哈希值并将其与提供的哈希值进行比较,验证数字签名是否有效。

(继承自 RSA)

适用于