RSA.TryExportEncryptedPkcs8PrivateKey 方法

定義

多載

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<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<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.

public:
 override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public override bool TryExportEncryptedPkcs8PrivateKey (ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
override this.TryExportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters * Span<byte> * int -> bool
Public Overrides Function TryExportEncryptedPkcs8PrivateKey (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters, destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

參數

passwordBytes
ReadOnlySpan<Byte>

加密金鑰內容時要用作密碼的位元組。The bytes to use as a password when encrypting the key material.

pbeParameters
PbeParameters

加密金鑰產製原料時要使用的密碼型加密 (PBE) 參數。The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Byte>

要接收 PKCS#8 EncryptedPrivateKeyInfo 資料的位元組範圍。The byte span to receive the PKCS#8 EncryptedPrivateKeyInfo data.

bytesWritten
Int32

當此方法傳回時,會包含一個值,指出寫入 destination 的位元組數。When this method returns, contains a value that indicates the number of bytes written to destination. 這個參數會被視為未初始化。This parameter is treated as uninitialized.

傳回

Boolean

destination 夠大可接收輸出,則為 true;否則為 falsetrue if destination is big enough to receive the output; otherwise, false.

例外狀況

無法匯出金鑰。The key could not be exported.

-或--or-

pbeParameters 指出應該使用 TripleDes3KeyPkcs12,這需要 Char 型密碼。pbeParameters indicates that TripleDes3KeyPkcs12 should be used, which requires Char-based passwords.

備註

密碼位元組會直接傳遞至金鑰衍生函式 (KDF 由所表示的演算法所使用的) pbeParametersThe password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters. 這可讓您在使用 PBKDF2 (密碼型金鑰衍生函式 2) 處理密碼時,使用 UTF-8 以外的文字編碼來與其他系統相容。This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).

另請參閱

適用於

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.

public:
 override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public override bool TryExportEncryptedPkcs8PrivateKey (ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
override this.TryExportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters * Span<byte> * int -> bool
Public Overrides Function TryExportEncryptedPkcs8PrivateKey (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters, destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

參數

password
ReadOnlySpan<Char>

加密金鑰產製原料時要使用的密碼。The password to use when encrypting the key material.

pbeParameters
PbeParameters

加密金鑰產製原料時要使用的密碼型加密 (PBE) 參數。The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Byte>

要接收 PKCS#8 EncryptedPrivateKeyInfo 資料的位元組範圍。The byte span to receive the PKCS#8 EncryptedPrivateKeyInfo data.

bytesWritten
Int32

當此方法傳回時,會包含一個值,指出寫入 destination 的位元組數。When this method returns, contains a value that indicates the number of bytes written to destination. 這個參數會被視為未初始化。This parameter is treated as uninitialized.

傳回

Boolean

destination 夠大可接收輸出,則為 true;否則為 falsetrue if destination is big enough to receive the output; otherwise, false.

例外狀況

無法匯出金鑰。The key could not be exported.

備註

pbeParameters 表示使用 PBKDF2 (密碼型金鑰衍生函式 2) 的演算法時,密碼會透過 utf-8 編碼轉換成位元組。When pbeParameters indicates an algorithm that uses PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.

另請參閱

適用於