ECAlgorithm.ImportEncryptedPkcs8PrivateKey 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32) |
使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。 |
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32) |
使用位元組型密碼解密之後,從 PKCS#8 EncryptedPrivateKeyInfo 結構匯入公開/私密金鑰組,以取代這個物件的金鑰。 |
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
的內容表示金鑰的格式不受支援。
-或-
演算法專屬金鑰匯入失敗。
衍生類別尚未提供 的實作 ImportParameters(ECParameters) 。
備註
The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by the EncryptedPrivateKeyInfo contents. 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).
This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo.
If the value is Base64-encoded, the caller must Base64-decode the contents before calling this method.
If the contents are PEM-encoded, <xref:System.Security.Cryptography.ECAlgorithm.ImportFromEncryptedPem(System.ReadOnlySpan{System.Char},System.ReadOnlySpan{System.Byte})>
should be used.
適用於
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)
使用位元組型密碼解密之後,從 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
的內容表示金鑰的格式不受支援。
-或-
演算法專屬金鑰匯入失敗。
衍生類別尚未提供 的實作 ImportParameters(ECParameters) 。
備註
When the contents of source
indicate an algorithm that uses PBKDF1
(Password-Based Key Derivation Function 1) or PBKDF2 (Password-Based Key Derivation Function 2),
the password is converted to bytes via the UTF-8 encoding.
This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo.
If the value is Base64-encoded, the caller must Base64-decode the contents before calling this method.
If the contents are PEM-encoded, <xref:System.Security.Cryptography.ECAlgorithm.ImportFromEncryptedPem(System.ReadOnlySpan{System.Char},System.ReadOnlySpan{System.Char})>
should be used.