RSA 類別

定義

表示基底類別,RSA 演算法的所有實作都會從它衍生。Represents the base class from which all implementations of the RSA algorithm inherit.

public ref class RSA abstract : 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
type RSA = class
    inherit AsymmetricAlgorithm
[<System.Runtime.InteropServices.ComVisible(true)>]
type RSA = class
    inherit AsymmetricAlgorithm
Public MustInherit Class RSA
Inherits AsymmetricAlgorithm
繼承
衍生
屬性

備註

我們鼓勵開發人員針對基類進行程式設計, RSA 而不是針對任何特定的衍生類別進行程式設計。Developers are encouraged to program against the RSA base class rather than any specific derived class. 衍生類別的目的是要與基礎系統密碼編譯程式庫交互操作。The derived classes are intended for interop with the underlying system cryptographic libraries.

建構函式

RSA()

初始化 RSA 類別的新執行個體。Initializes a new instance of the RSA class.

欄位

KeySizeValue

表示非對稱演算法使用的金鑰模數大小,以位元為單位。Represents the size, in bits, of the key modulus used by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
LegalKeySizesValue

指定非對稱演算法所支援的金鑰大小。Specifies the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)

屬性

KeyExchangeAlgorithm

取得可透過這個 RSA 實作所提供之金鑰交換演算法的名稱。Gets the name of the key exchange algorithm available with this implementation of RSA.

KeyExchangeAlgorithm

在衍生類別中覆寫時,取得金鑰交換演算法的名稱。When overridden in a derived class, gets the name of the key exchange algorithm. 否則,擲回 NotImplementedExceptionOtherwise, throws an NotImplementedException.

(繼承來源 AsymmetricAlgorithm)
KeySize

取得或設定非對稱演算法使用的金鑰模數大小,以位元為單位。Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
LegalKeySizes

取得非對稱演算法所支援的金鑰大小。Gets the key sizes that are supported by the asymmetric algorithm.

(繼承來源 AsymmetricAlgorithm)
SignatureAlgorithm

取得可透過這個 RSA 實作所提供之簽章演算法的名稱。Gets the name of the signature algorithm available with this implementation of RSA.

SignatureAlgorithm

在衍生類別中實作時,取得簽章演算法的名稱。When implemented in a derived class, gets the name of the signature algorithm. 否則,一律擲回 NotImplementedExceptionOtherwise, always throws a NotImplementedException.

(繼承來源 AsymmetricAlgorithm)

方法

Clear()

釋放 AsymmetricAlgorithm 類別所使用的所有資源。Releases all resources used by the AsymmetricAlgorithm class.

(繼承來源 AsymmetricAlgorithm)
Create()

建立 RSA 演算法之預設實作的執行個體。Creates an instance of the default implementation of the RSA algorithm.

Create(Int32)

使用指定的金鑰大小建立新的暫時 RSA 金鑰。Creates a new ephemeral RSA key with the specified key size.

Create(RSAParameters)

以指定的 RSA 金鑰參數建立新的暫時 RSA 金鑰。Creates a new ephemeral RSA key with the specified RSA key parameters.

Create(String)

建立 RSA 之指定實作的執行個體。Creates an instance of the specified implementation of RSA.

Decrypt(Byte[], RSAEncryptionPadding)

使用指定的填補模式在衍生類別中覆寫,解密輸入的資料。When overridden in a derived class, decrypts the input data using the specified padding mode.

DecryptValue(Byte[])

在衍生類別中覆寫時,使用私密金鑰解密輸入資料。When overridden in a derived class, decrypts the input data using the private key.

Dispose()

釋放 AsymmetricAlgorithm 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the AsymmetricAlgorithm class.

(繼承來源 AsymmetricAlgorithm)
Dispose(Boolean)

釋放 AsymmetricAlgorithm 類別所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the AsymmetricAlgorithm class and optionally releases the managed resources.

(繼承來源 AsymmetricAlgorithm)
Encrypt(Byte[], RSAEncryptionPadding)

使用指定的填補模式在衍生類別中覆寫,加密輸入的資料。When overridden in a derived class, encrypts the input data using the specified padding mode.

EncryptValue(Byte[])

在衍生類別中覆寫時,使用公開金鑰加密輸入資料。When overridden in a derived class, encrypts the input data using the public key.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用位元組型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

(繼承來源 AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

(繼承來源 AsymmetricAlgorithm)
ExportParameters(Boolean)

在衍生類別中覆寫時,會匯出 RSAParametersWhen overridden in a derived class, exports the RSAParameters.

ExportPkcs8PrivateKey()

以 PKCS#8 PrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 PrivateKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
ExportRSAPrivateKey()

以 PKCS#1 RSAPrivateKey 格式匯出目前金鑰。Exports the current key in the PKCS#1 RSAPrivateKey format.

ExportRSAPublicKey()

以 PKCS#1 RSAPublicKey 格式匯出目前金鑰的公開金鑰部分。Exports the public-key portion of the current key in the PKCS#1 RSAPublicKey format.

ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式匯出目前金鑰的公開金鑰部分。Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.

(繼承來源 AsymmetricAlgorithm)
FromXmlString(String)

從 XML 字串的金鑰資訊初始化 RSA 物件。Initializes an RSA object from the key information from an XML string.

FromXmlString(String)

在衍生類別中覆寫時,從 XML 字串重新建構 AsymmetricAlgorithm 物件。When overridden in a derived class, reconstructs an AsymmetricAlgorithm object from an XML string. 否則,擲回 NotImplementedExceptionOtherwise, throws a NotImplementedException.

(繼承來源 AsymmetricAlgorithm)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName)

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為位元組陣列中的指定部分計算出雜湊值。When overridden in a derived class, computes the hash value of a specified portion of a byte array by using a specified hashing algorithm.

HashData(Stream, HashAlgorithmName)

在衍生類別中覆寫時,會使用指定的雜湊演算法,來為指定的二進位資料流計算出雜湊值。When overridden in a derived class, computes the hash value of a specified binary stream by using a specified hashing algorithm.

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

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

當在衍生類別中受到覆寫時,於使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

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

當在衍生類別中受到覆寫時,於使用字元型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

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

在衍生類別中覆寫時,匯入 RFC 7468 PEM 編碼的加密金鑰,並取代這個物件的金鑰。When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的加密私密金鑰,並取代這個物件的金鑰。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

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

在衍生類別中覆寫時,匯入 RFC 7468 PEM 編碼的加密金鑰,並取代這個物件的金鑰。When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportFromPem(ReadOnlySpan<Char>)

匯入 RFC 7468 PEM 編碼的金鑰,並取代這個物件的金鑰。Imports an RFC 7468 PEM-encoded key, replacing the keys for this object.

ImportFromPem(ReadOnlySpan<Char>)

在衍生類別中覆寫時,匯入 RFC 7468文字編碼的金鑰,並取代這個物件的金鑰。When overridden in a derived class, imports an RFC 7468 textually encoded key, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportParameters(RSAParameters)

在衍生類別中覆寫時,會匯入指定的 RSAParametersWhen overridden in a derived class, imports the specified RSAParameters.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

解密後,從 PKCS#8 PrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

當在衍生類別中受到覆寫時,於解密後從 PKCS#8 PrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。When overriden in a derived class, imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
ImportRSAPrivateKey(ReadOnlySpan<Byte>, Int32)

解密後,從 PKCS#1 RSAPrivateKey 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。Imports the public/private keypair from a PKCS#1 RSAPrivateKey structure after decryption, replacing the keys for this object.

ImportRSAPublicKey(ReadOnlySpan<Byte>, Int32)

解密後,從 PKCS#1 RSAPublicKey 結構匯入公開金鑰,以取代這個物件的金鑰。Imports the public key from a PKCS#1 RSAPublicKey structure after decryption, replacing the keys for this object.

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

解密後,從 X.509 SubjectPublicKeyInfo 結構匯入公開金鑰,以取代這個物件的金鑰。Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

當在衍生類別中受到覆寫時,於解密後從 X.509 SubjectPublicKeyInfo 結構匯入公開金鑰,以取代這個物件的金鑰。When overriden in a derived class, imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

(繼承來源 AsymmetricAlgorithm)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
SignData(Byte[], HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的位元組陣列計算出雜湊值。Computes the hash value of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value.

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

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的部分位元組陣列計算出雜湊值。Computes the hash value of a portion of the specified byte array using the specified hash algorithm and padding mode, and signs the resulting hash value.

SignData(Stream, HashAlgorithmName, RSASignaturePadding)

使用指定的雜湊演算法和填補模式,並簽署產生的雜湊值,來為指定的資料流計算出雜湊值。Computes the hash value of the specified stream using the specified hash algorithm and padding mode, and signs the resulting hash value.

SignHash(Byte[], HashAlgorithmName, RSASignaturePadding)

在衍生類別中覆寫時,針對指定雜湊值的簽章,使用指定的填補來計算。When overridden in a derived class, computes the signature for the specified hash value using the specified padding.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
ToXmlString(Boolean)

建立並傳回 XML 字串,其中包含目前 RSA 物件的金鑰。Creates and returns an XML string containing the key of the current RSA object.

ToXmlString(Boolean)

在衍生類別中覆寫時,建立並傳回目前 AsymmetricAlgorithm 物件的 XML 字串表示。When overridden in a derived class, creates and returns an XML string representation of the current AsymmetricAlgorithm object. 否則,擲回 NotImplementedExceptionOtherwise, throws a NotImplementedException.

(繼承來源 AsymmetricAlgorithm)
TryDecrypt(ReadOnlySpan<Byte>, Span<Byte>, RSAEncryptionPadding, Int32)

使用指定的填補模式,將結果寫入提供的緩衝區,以嘗試解密輸入資料。Attempts to decrypt the input data using the specified padding mode, writing the result into a provided buffer.

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

使用指定的填補模式,嘗試加密所提供緩衝區中的輸入資料。Attempts to encrypt the input data with a specified padding mode into a provided buffer.

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

使用位元組型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

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

當在衍生類別中受到覆寫時,使用位元組型密碼嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。When overridden in a derived class, attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

(繼承來源 AsymmetricAlgorithm)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

使用 Char 型密碼,嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

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

當在衍生類別中受到覆寫時,使用字元型密碼嘗試以 PKCS#8 EncryptedPrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。When overriden in a derived class, attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

(繼承來源 AsymmetricAlgorithm)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

嘗試以 PKCS#8 PrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#8 PrivateKeyInfo format into a provided buffer.

TryExportPkcs8PrivateKey(Span<Byte>, Int32)

當在衍生類別中受到覆寫時,嘗試以 PKCS#8 PrivateKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。When overridden in a derived class, attempts to export the current key in the PKCS#8 PrivateKeyInfo format into a provided buffer.

(繼承來源 AsymmetricAlgorithm)
TryExportRSAPrivateKey(Span<Byte>, Int32)

嘗試以 PKCS#1 RSAPrivateKey 格式將目前金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#1 RSAPrivateKey format into a provided buffer.

TryExportRSAPublicKey(Span<Byte>, Int32)

嘗試以 PKCS#1 RSAPublicKey 格式將目前金鑰匯出至提供的緩衝區。Attempts to export the current key in the PKCS#1 RSAPublicKey format into a provided buffer.

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

嘗試以 X.509 SubjectPublicKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。Attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

當在衍生類別中受到覆寫時,嘗試以 X.509 SubjectPublicKeyInfo 格式將目前的金鑰匯出至提供的緩衝區。When overridden in a derived class, attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

(繼承來源 AsymmetricAlgorithm)
TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

使用指定的演算法來,將結果寫入提供的緩衝區,以嘗試計算所提供資料的雜湊。Attempts to compute the hash of the provided data by using the specified algorithm, writing the results into a provided buffer.

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

使用所指定演算法並使用目前的金鑰簽署雜湊,將簽章寫入提供的緩衝區,以嘗試雜湊處理所提供的資料。Attempts to hash the provided data with the specified algorithm and sign the hash with the current key, writing the signature into a provided buffer.

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

將簽章寫入提供的緩衝區,嘗試以目前的金鑰簽署雜湊。Attempts to sign the hash with the current key, writing the signature into a provided buffer.

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

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and padding, and comparing it to the provided signature.

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

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的部分位元組陣列計算出資料的雜湊值,便藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and padding, and comparing it to the provided signature.

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

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and padding, and comparing it to the provided signature.

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

使用指定的雜湊演算法和填補,並和提供的簽章比較,來為指定的資料流計算出雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and padding, and comparing it to the provided signature.

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

使用指定的雜湊演算法和填補,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

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

使用指定的雜湊演算法和填補,並和提供的雜湊值比較,來為簽章判斷雜湊值,藉此驗證數位簽章是否有效。Verifies that a digital signature is valid by determining the hash value in the signature using the specified hash algorithm and padding, and comparing it to the provided hash value.

明確介面實作

IDisposable.Dispose()

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(繼承來源 AsymmetricAlgorithm)

適用於

另請參閱