Share via


Pkcs8PrivateKeyInfo 构造函数

定义

初始化 Pkcs8PrivateKeyInfo 类的新实例。

public Pkcs8PrivateKeyInfo (System.Security.Cryptography.Oid algorithmId, ReadOnlyMemory<byte>? algorithmParameters, ReadOnlyMemory<byte> privateKey, bool skipCopies = false);
new System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo : System.Security.Cryptography.Oid * Nullable<ReadOnlyMemory<byte>> * ReadOnlyMemory<byte> * bool -> System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo
Public Sub New (algorithmId As Oid, algorithmParameters As Nullable(Of ReadOnlyMemory(Of Byte)), privateKey As ReadOnlyMemory(Of Byte), Optional skipCopies As Boolean = false)

参数

algorithmId
Oid

标识此密钥所用于的非对称算法的对象标识符 (OID)。

algorithmParameters
Nullable<ReadOnlyMemory<Byte>>

与此密钥关联的 BER 编码算法参数;如果在编码时省略算法参数,则为 null

privateKey
ReadOnlyMemory<Byte>

特定于算法的编码私钥。

skipCopies
Boolean

如果存储 algorithmParametersprivateKey 而不创建防御性副本,则为 true;否则为 false。 默认值为 false

例外

algorithmId 参数为 null

algorithmParameters 参数不为 null、空或单个 BER 编码值。

注解

不会对 privateKey 参数执行任何验证;并非所有算法都需要 BER 编码的值。

此构造函数的默认行为是创建 和 privateKey 参数的algorithmParameters防御性副本。 skipCopies当 参数为 true时,将跳过此防御性副本。 如果跳过防御性副本,并在返回值或其方法或privateKey属性生成的任何对象的生存期内更改 或 的内容algorithmParameters,则这些对象的方法和属性可能会生成无意义的结果或由于损坏状态而引发异常。 因此,建议调用方仅当可以合理地确保数据保持不变时,才对 skipCopies 参数使用true值。

适用于

另请参阅