RSA 类

定义

表示 RSA 算法的所有实现均从中继承的基类。

public ref class RSA abstract : System::Security::Cryptography::AsymmetricAlgorithm
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class RSA : System.Security.Cryptography.AsymmetricAlgorithm
public abstract class RSA : System.Security.Cryptography.AsymmetricAlgorithm
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RSA : System.Security.Cryptography.AsymmetricAlgorithm
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type RSA = class
    inherit AsymmetricAlgorithm
type RSA = class
    inherit AsymmetricAlgorithm
[<System.Runtime.InteropServices.ComVisible(true)>]
type RSA = class
    inherit AsymmetricAlgorithm
Public MustInherit Class RSA
Inherits AsymmetricAlgorithm
继承
派生
属性

注解

建议开发人员针对 RSA 基类而不是任何特定的派生类进行编程。 派生类用于与基础系统加密库进行互操作。

构造函数

RSA()

初始化 RSA 类的新实例。

字段

KeySizeValue

表示非对称算法所用密钥模块的大小(以位为单位)。

(继承自 AsymmetricAlgorithm)
LegalKeySizesValue

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

(继承自 AsymmetricAlgorithm)

属性

KeyExchangeAlgorithm

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

KeyExchangeAlgorithm

当在派生类中重写时,请获取密钥交换算法的名称。 否则,将引发 NotImplementedException

(继承自 AsymmetricAlgorithm)
KeySize

获取或设置非对称算法所用密钥模块的大小(以位为单位)。

(继承自 AsymmetricAlgorithm)
LegalKeySizes

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

(继承自 AsymmetricAlgorithm)
SignatureAlgorithm

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

SignatureAlgorithm

当在派生类中实现时,请获取签名算法的名称。 否则,将始终引发 NotImplementedException

(继承自 AsymmetricAlgorithm)

方法

Clear()

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

(继承自 AsymmetricAlgorithm)
Create()

创建 RSA 算法的默认实现的实例。

Create(Int32)

创建具有指定密钥大小的新临时 RSA 密钥。

Create(RSAParameters)

创建具有指定 RSA 密钥参数的新临时 RSA 密钥。

Create(String)
已过时.

创建 RSA 的指定实现的实例。

Decrypt(Byte[], RSAEncryptionPadding)

在派生类中被重写时,使用指定的填充模式来解密输入数据。

Decrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

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

Decrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding)

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

DecryptValue(Byte[])
已过时.

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

Dispose()

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

(继承自 AsymmetricAlgorithm)
Dispose(Boolean)

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

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

在派生类中被重写时,使用指定的填充模式加密输入数据。

Encrypt(ReadOnlySpan<Byte>, RSAEncryptionPadding)

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

Encrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding)

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

EncryptValue(Byte[])
已过时.

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

Equals(Object)

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

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

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

(继承自 AsymmetricAlgorithm)
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)

当在派生类中重写时,导出 RSAParameters

ExportPkcs8PrivateKey()

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

(继承自 AsymmetricAlgorithm)
ExportPkcs8PrivateKeyPem()

以 PKCS#8 PrivateKeyInfo 格式导出当前密钥,PEM 编码。

(继承自 AsymmetricAlgorithm)
ExportRSAPrivateKey()

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

ExportRSAPrivateKeyPem()

以 PKCS#1 RSAPrivateKey 格式导出当前密钥,PEM 编码。

ExportRSAPublicKey()

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

ExportRSAPublicKeyPem()

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

ExportSubjectPublicKeyInfo()

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

(继承自 AsymmetricAlgorithm)
ExportSubjectPublicKeyInfoPem()

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

(继承自 AsymmetricAlgorithm)
FromXmlString(String)

通过 XML 字符串中的密钥信息初始化 RSA 对象。

FromXmlString(String)

当在派生类中重写时,从 XML 字符串重新构造 AsymmetricAlgorithm 对象。 否则,将引发 NotImplementedException

(继承自 AsymmetricAlgorithm)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetMaxOutputSize()

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

GetType()

获取当前实例的 Type

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

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

HashData(Stream, HashAlgorithmName)

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

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

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

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

在派生的类中替代时,使用基于字节的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

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

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

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

在派生的类中替代时,使用基于字符的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

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

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

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

在派生的类中重写时,导入已加密的 RFC 7468 PEM 编码的密钥,替换此对象的密钥。

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

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

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

在派生的类中重写时,导入已加密的 RFC 7468 PEM 编码的密钥,替换此对象的密钥。

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

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

ImportFromPem(ReadOnlySpan<Char>)

在派生的类中重写时,导入 RFC 7468 按原文编码的密钥,替换此对象的密钥。

(继承自 AsymmetricAlgorithm)
ImportParameters(RSAParameters)

当在派生类中重写时,导入指定的 RSAParameters

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

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

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

在派生的类中替代时,解密后从 PKCS#8 PrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

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

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

ImportRSAPublicKey(ReadOnlySpan<Byte>, Int32)

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

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

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

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

在派生的类中替代时,解密后从 X.509 SubjectPublicKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。

(继承自 AsymmetricAlgorithm)
MemberwiseClone()

创建当前 Object 的浅表副本。

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

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

SignData(Byte[], Int32, Int32, HashAlgorithmName, RSASignaturePadding)

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

SignData(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

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

SignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

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

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

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

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

在派生类中重写时,使用指定的填充来计算指定的哈希值的签名。

SignHash(ReadOnlySpan<Byte>, HashAlgorithmName, RSASignaturePadding)

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

SignHash(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, RSASignaturePadding)

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

ToString()

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

(继承自 Object)
ToXmlString(Boolean)

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

ToXmlString(Boolean)

当在派生类中重写时,创建并返回当前 AsymmetricAlgorithm 对象的 XML 字符串表示形式。 否则,将引发 NotImplementedException

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

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

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

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

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

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

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

在派生的类中替代时,尝试使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

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

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

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

在派生的类中替代时,尝试使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

(继承自 AsymmetricAlgorithm)
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 格式将当前密钥导出到所提供的缓冲区。

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

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

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

尝试以 PKCS#1 RSAPrivateKey 格式将当前密钥导入所提供的缓冲区。

TryExportRSAPrivateKeyPem(Span<Char>, Int32)

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

TryExportRSAPublicKey(Span<Byte>, Int32)

尝试以 PKCS#1 RSAPublicKey 格式将当前密钥导入所提供的缓冲区。

TryExportRSAPublicKeyPem(Span<Char>, Int32)

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

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

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

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

在派生的类中替代时,尝试以 X.509 SubjectPublicKeyInfo 格式将当前密钥导出到所提供的缓冲区。

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

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

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

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

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

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

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

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

VerifyData(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

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

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, RSASignaturePadding)

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

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

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

VerifyData(Stream, Byte[], HashAlgorithmName, RSASignaturePadding)

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

VerifyHash(Byte[], Byte[], HashAlgorithmName, RSASignaturePadding)

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

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

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

显式接口实现

IDisposable.Dispose()

此 API 支持产品基础结构,不能在代码中直接使用。

有关此成员的说明,请参见 Dispose()

(继承自 AsymmetricAlgorithm)

适用于

另请参阅