AsymmetricAlgorithm.ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32) 方法

定义

在派生的类中替代时,解密后从 PKCS#8 PrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。When overriden in a derived class, imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

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

参数

source
ReadOnlySpan<Byte>

ASN.1-BER 编码中 PKCS#8 PrivateKeyInfo 结构的字节。The bytes of a PKCS#8 PrivateKeyInfo 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.

例外

source 的内容不表示 ASN.1-BER 编码的 PKCS#8 PrivateKeyInfo 结构。The contents of source do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo 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.

派生的类型未替代此成员。A derived type has not overriden this member.

注解

此方法仅支持 PrivateKeyInfo 的 BER/CER/DER) 编码的二进制 (。This method only supports the binary (BER/CER/DER) encoding of PrivateKeyInfo. 如果值采用 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.

由于解释此数据格式的内容需要特定于算法的支持,因此 ImportPkcs8PrivateKey NotImplementedException 默认情况下会引发。Because algorithm-specific support is required to interpret the contents of this data format, ImportPkcs8PrivateKey throws a NotImplementedException by default.

适用于