<PackageReference Include="System.Security.Cryptography.Pkcs" Version="11.0.0-rc.1.26425.128" />

System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo

public sealed class Pkcs8PrivateKeyInfo
Enables the inspection of and creation of PKCS#8 PrivateKeyInfo and EncryptedPrivateKeyInfo values. This class cannot be inherited.
public Oid AlgorithmId { get; }

Gets the Object Identifier (OID) value identifying the algorithm this key is for.

public ReadOnlyMemory<byte>? AlgorithmParameters { get; }

Gets a memory value containing the BER-encoded algorithm parameters associated with this key.

Gets the modifiable collection of attributes for this private key.

public ReadOnlyMemory<byte> PrivateKeyBytes { get; }

Gets a memory value that represents the algorithm-specific encoded private key.

public Pkcs8PrivateKeyInfo(Oid algorithmId, ReadOnlyMemory<byte>? algorithmParameters, ReadOnlyMemory<byte> privateKey, bool skipCopies = false)

Initializes a new instance of the Pkcs8PrivateKeyInfo class.

Exports a specified key as a PKCS#8 PrivateKeyInfo and returns its decoded interpretation.

public static Pkcs8PrivateKeyInfo Decode(ReadOnlyMemory<byte> source, out int bytesRead, bool skipCopy = false)

Reads the provided data as a PKCS#8 PrivateKeyInfo and returns an object view of the contents.

public static Pkcs8PrivateKeyInfo DecryptAndDecode(ReadOnlySpan<char> password, ReadOnlyMemory<byte> source, out int bytesRead)

Decrypts the provided data using the provided character-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

public static Pkcs8PrivateKeyInfo DecryptAndDecode(ReadOnlySpan<byte> passwordBytes, ReadOnlyMemory<byte> source, out int bytesRead)

Decrypts the provided data using the provided byte-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

public byte[] Encode()

Encodes the property data of this instance as a PKCS#8 PrivateKeyInfo and returns the encoding as a byte array.

public byte[] Encrypt(ReadOnlySpan<char> password, PbeParameters pbeParameters)

Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters.

public byte[] Encrypt(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters)

Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters.

public bool TryEncode(Span<byte> destination, out int bytesWritten)

Attempts to encode the property data of this instance as a PKCS#8 PrivateKeyInfo, writing the results into a provided buffer.

public bool TryEncrypt(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters, writing the result into a provided buffer.

public bool TryEncrypt(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters, writing the results into a provided buffer.