ECDiffieHellman.ImportFromEncryptedPem 方法
定义
重载
| 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<Char>) |
导入已加密的 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 编码的私钥,替换此对象的密钥。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.
public:
override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<System::Byte> passwordBytes);
public override void ImportFromEncryptedPem (ReadOnlySpan<char> input, ReadOnlySpan<byte> passwordBytes);
override this.ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<byte> -> unit
Public Overrides Sub ImportFromEncryptedPem (input As ReadOnlySpan(Of Char), passwordBytes As ReadOnlySpan(Of Byte))
参数
- input
- ReadOnlySpan<Char>
要导入的加密密钥的 PEM 文本。The PEM text of the encrypted key to import.
- passwordBytes
- ReadOnlySpan<Byte>
解密密钥材料时用作密码的字节。The bytes to use as a password when decrypting the key material.
例外
input 不包含带有可识别标签的 PEM 编码的密钥。input does not contain a PEM-encoded key with a recognized label.
或-or-
input 包含多个带有可识别标签的 PEM 编码的密钥。input contains multiple PEM-encoded keys with a recognized label.
密码不正确。The password is incorrect.
或-or-
input 中 PEM 文本的 Base-64 解码的内容不表示 ASN.1-BER 编码的 PKCS#8 EncryptedPrivateKeyInfo 结构。The base-64 decoded contents of the PEM text from input do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.
或-or-
input 中 PEM 文本的 Base-64 解码的内容指示密钥用于此实例表示的算法以外的算法。The base-64 decoded contents of the PEM text from input indicate the key is for an algorithm other than the algorithm represented by this instance.
或-or-
input 中 PEM 文本的 Base-64 解码的内容表示密钥采用的格式不受支持。The base-64 decoded contents of the PEM text from input represent the key in a format that is not supported.
或-or-
特定于算法的密钥导入失败。The algorithm-specific key import failed.
注解
密码字节直接传递到密钥派生函数 (KDF) 使用的算法所使用的算法 pbeParameters 。The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters. 这样,在使用 PBKDF2 处理密码时,与使用 UTF-8 以外的文本编码的其他系统兼容, (基于密码的密钥派生函数 2) 。This enables compatibility with other systems that use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).
不支持或格式不正确的 PEM 编码对象将被忽略。Unsupported or malformed PEM-encoded objects will be ignored. 如果找到多个受支持的 PEM 标签,则会引发异常,以防当键不明确时导入密钥。If multiple supported PEM labels are found, an exception is thrown to prevent importing a key when the key is ambiguous.
此方法支持 ENCRYPTED PRIVATE KEY PEM 标签。This method supports the ENCRYPTED PRIVATE KEY PEM label.
适用于
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)
导入已加密的 RFC 7468 PEM 编码的私钥,替换此对象的密钥。Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.
public:
override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<char> password);
public override void ImportFromEncryptedPem (ReadOnlySpan<char> input, ReadOnlySpan<char> password);
override this.ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<char> -> unit
Public Overrides Sub ImportFromEncryptedPem (input As ReadOnlySpan(Of Char), password As ReadOnlySpan(Of Char))
参数
- input
- ReadOnlySpan<Char>
要导入的加密密钥的 PEM 文本。The PEM text of the encrypted key to import.
- password
- ReadOnlySpan<Char>
用于解密密钥材料的密码。The password to use for decrypting the key material.
例外
input 不包含带有可识别标签的 PEM 编码的密钥。input does not contain a PEM-encoded key with a recognized label.
或-or-
input 包含多个带有可识别标签的 PEM 编码的密钥。input contains multiple PEM-encoded keys with a recognized label.
密码不正确。The password is incorrect.
或-or-
input 中 PEM 文本的 Base-64 解码的内容不表示 ASN.1-BER 编码的 PKCS#8 EncryptedPrivateKeyInfo 结构。The base-64 decoded contents of the PEM text from input do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.
或-or-
input 中 PEM 文本的 Base-64 解码的内容指示密钥用于此实例表示的算法以外的算法。The base-64 decoded contents of the PEM text from input indicate the key is for an algorithm other than the algorithm represented by this instance.
或-or-
input 中 PEM 文本的 Base-64 解码的内容表示密钥采用的格式不受支持。The base-64 decoded contents of the PEM text from input represent the key in a format that is not supported.
或-or-
特定于算法的密钥导入失败。The algorithm-specific key import failed.
注解
如果64的已解码内容 input 指示使用 PBKDF1 (基于密码的密钥派生函数 1) 或 PBKDF2 (基于密码的密钥派生函数 2) 的算法,则密码将通过 utf-8 编码转换为字节。When the base-64 decoded contents of input 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.
不支持或格式不正确的 PEM 编码对象将被忽略。Unsupported or malformed PEM-encoded objects will be ignored. 如果找到多个受支持的 PEM 标签,则会引发异常,以防当键不明确时导入密钥。If multiple supported PEM labels are found, an exception is thrown to prevent importing a key when the key is ambiguous.
此方法支持 ENCRYPTED PRIVATE KEY PEM 标签。This method supports the ENCRYPTED PRIVATE KEY PEM label.