ECDiffieHellman.ImportEncryptedPkcs8PrivateKey 方法

定义

重载

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

使用基于字节的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

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

使用基于字符的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

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

使用基于字节的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

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>

解密密钥材料时用作密码的字节。The bytes to use as a password when decrypting the key material.

source
ReadOnlySpan<Byte>

ASN.1-BER 编码中 PKCS#8 EncryptedPrivateKeyInfo 结构的字节。The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.

bytesRead
Int32

此方法返回时,包含一个指示从 source 中读取的字节数的值。When this method returns, contains a value that indicates the number of bytes read from source. 该参数未经初始化即被处理。This parameter is treated as uninitialized.

异常

密码不正确。The password is incorrect.

-or-

source 的内容表示要应用的密钥派生功能 (KDF) 是旧的 PKCS#12 KDF,需要基于 Char 的密码。The contents of source indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires Char-based passwords.

- 或 --or-

source 的内容不表示 ASN.1-BER 编码的 PKCS#8 EncryptedPrivateKeyInfo 结构。The contents of source do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.

- 或 --or-

source 的内容指示密钥用于此实例表示的算法以外的算法。The contents of source indicate the key is for an algorithm other than the algorithm represented by this instance.

-or-

source 的内容表示密钥采用的格式不受支持。The contents of source represent the key in a format that is not supported.

-or-

特定于算法的密钥导入失败。The algorithm-specific key import failed.

注解

密码字节直接传递到由 EncryptedPrivateKeyInfo 内容指示的算法使用的密钥派生函数(KDF)。The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by the EncryptedPrivateKeyInfo contents. 这样,就可以与使用 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). 此方法只支持 EncryptedPrivateKeyInfo 的二进制(BER/CER/DER)编码。This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo. 如果值采用 Base64 编码或 PEM 文本格式,则调用方必须在调用此方法之前对内容进行 Base64 编码。If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.

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

使用基于字符的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

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>

用于解密密钥材料的密码。The password to use for decrypting the key material.

source
ReadOnlySpan<Byte>

ASN.1-BER 编码中 PKCS#8 EncryptedPrivateKeyInfo 结构的字节。The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.

bytesRead
Int32

此方法返回时,包含一个指示从 source 中读取的字节数的值。When this method returns, contains a value that indicates the number of bytes read from source. 该参数未经初始化即被处理。This parameter is treated as uninitialized.

异常

密码不正确。The password is incorrect.

-or-

source 的内容不表示 ASN.1-BER 编码的 PKCS#8 EncryptedPrivateKeyInfo 结构。The contents of source do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.

-or-

source 的内容指示密钥用于此实例表示的算法以外的算法。The contents of source indicate the key is for an algorithm other than the algorithm represented by this instance.

-or-

source 的内容表示密钥采用的格式不受支持。The contents of source represent the key in a format that is not supported.

-or-

特定于算法的密钥导入失败。The algorithm-specific key import failed.

注解

当的内容source指示使用 PBKDF1 (基于密码的密钥派生函数1)或 PBKDF2 (基于密码的密钥派生函数2)的算法时,密码将通过 utf-8 编码转换为字节。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. 此方法只支持 EncryptedPrivateKeyInfo 的二进制(BER/CER/DER)编码。This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo. 如果值采用 Base64 编码或 PEM 文本格式,则调用方必须在调用此方法之前对内容进行 Base64 编码。If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.

适用于