AsymmetricAlgorithm.ImportEncryptedPkcs8PrivateKey 方法

定義

多載

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

當在衍生類別中受到覆寫時,於使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

當在衍生類別中受到覆寫時,於使用字元型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

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

來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs

當在衍生類別中受到覆寫時,於使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

public:
 virtual void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<System::Byte> passwordBytes, ReadOnlySpan<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public virtual void ImportEncryptedPkcs8PrivateKey (ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
abstract member ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * ReadOnlySpan<byte> * int -> unit
override this.ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * ReadOnlySpan<byte> * int -> unit
Public Overridable 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) 由 所指示 pbeParameters 的演算法使用。 這可讓與使用 UTF-8 以外的文字編碼的其他系統相容,以 PBKDF2 處理密碼 (密碼型金鑰衍生函式 2) 。

這個方法僅支援 EncryptedPrivateKeyInfo 的二進位 (BER/CER/DER) 編碼。 如果值為 Base64 編碼或 PEM 文字格式,則呼叫端必須在呼叫此方法之前先將內容解碼為 Base64。

由於需要演算法特定的支援才能解譯此資料格式的內容, ImportEncryptedPkcs8PrivateKey 因此預設會擲回 NotImplementedException

適用於

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

來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs

當在衍生類別中受到覆寫時,於使用字元型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。

public:
 virtual void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public virtual void ImportEncryptedPkcs8PrivateKey (ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
abstract member ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * ReadOnlySpan<byte> * int -> unit
override this.ImportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * ReadOnlySpan<byte> * int -> unit
Public Overridable 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 因此預設會擲回 NotImplementedException

適用於