ECDsa.ImportEncryptedPkcs8PrivateKey 方法

定義

多載

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

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

使用 Char 型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

public:
 override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public override void ImportEncryptedPkcs8PrivateKey (ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
override this.ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * ReadOnlySpan<byte> * int -> unit
Public Overrides Sub ImportEncryptedPkcs8PrivateKey (password As ReadOnlySpan(Of Char), source As ReadOnlySpan(Of Byte), ByRef bytesRead As Integer)

參數

password
ReadOnlySpan<Char>

要用於解密金鑰產製原料的密碼。

source
ReadOnlySpan<Byte>

以 ASN.1-BER 編碼的 PKCS#8 EncryptedPrivateKeyInfo 結構位元組。

bytesRead
Int32

當此方法傳回時,會包含一個值,指出讀取自 source 的位元組數。 這個參數會被視為未初始化。

例外狀況

密碼不正確。

-或-

source 的內容不表示 ASN.1-BER 編碼的 PKCS#8 EncryptedPrivateKeyInfo 結構。

-或-

source 的內容指出金鑰適用於這個執行個體所表示演算法以外的演算法。

-或-

source 的內容表示金鑰的格式不受支援。

-或-

演算法專屬金鑰匯入失敗。

備註

當 的內容 source 指出使用 PBKDF1 (密碼型金鑰衍生函數 1) 或 PBKDF2 (密碼型金鑰衍生函數 2) 的演算法時,密碼會透過 UTF-8 編碼轉換成位元組。 這個方法僅支援 EncryptedPrivateKeyInfo 的二進位 (BER/CER/DER) 編碼。 如果值為 Base64 編碼或 PEM 文字格式,則呼叫端必須先以 Base64 解碼內容,再呼叫此方法。

適用於

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

使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

public:
 override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<System::Byte> passwordBytes, ReadOnlySpan<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public override void ImportEncryptedPkcs8PrivateKey (ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
override this.ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * ReadOnlySpan<byte> * int -> unit
Public Overrides Sub ImportEncryptedPkcs8PrivateKey (passwordBytes As ReadOnlySpan(Of Byte), source As ReadOnlySpan(Of Byte), ByRef bytesRead As Integer)

參數

passwordBytes
ReadOnlySpan<Byte>

解密金鑰產製原料時要用作密碼的位元組。

source
ReadOnlySpan<Byte>

以 ASN.1-BER 編碼的 PKCS#8 EncryptedPrivateKeyInfo 結構位元組。

bytesRead
Int32

當此方法傳回時,會包含一個值,指出讀取自 source 的位元組數。 這個參數會被視為未初始化。

例外狀況

密碼不正確。

-或-

source 的內容指出要套用的金鑰衍生函數 (Key Derivation Function) (KDF) 是舊版 PKCS#12 KDF,這需要 Char 型密碼。

-或-

source 的內容不表示 ASN.1-BER 編碼的 PKCS#8 EncryptedPrivateKeyInfo 結構。

-或-

source 的內容指出金鑰適用於這個執行個體所表示演算法以外的演算法。

-或-

source 的內容表示金鑰的格式不受支援。

-或-

演算法專屬金鑰匯入失敗。

備註

密碼位元組會直接傳遞至金鑰衍生函式, (KDF) 由 EncryptedPrivateKeyInfo 內容指示的演算法使用。 這可讓您與使用 UTF-8 以外的文字編碼的其他系統相容,以 PBKDF2 處理密碼時, (密碼型金鑰衍生函式 2) 。 這個方法僅支援 EncryptedPrivateKeyInfo 的二進位 (BER/CER/DER) 編碼。 如果值為 Base64 編碼或 PEM 文字格式,則呼叫端必須先以 Base64 解碼內容,再呼叫此方法。

適用於