Skip to content

OnixLabs.Security.Cryptography.IPrivateKeyPkcs8Exportable

matthew edited this page May 27, 2026 · 1 revision

IPrivateKeyPkcs8Exportable Interface

Defines a cryptographic private key that can be exported in PKCS #8 binary form.

Namespace OnixLabs.Security.Cryptography
Assembly OnixLabs.Security.Cryptography.dll (NuGet)

Definition

public interface IPrivateKeyPkcs8Exportable
{
    byte[] ExportPkcs8();
    byte[] ExportPkcs8(ReadOnlySpan<char> password, PbeParameters parameters);
    byte[] ExportPkcs8(ReadOnlySpan<byte> password, PbeParameters parameters);
}

Remarks

IPrivateKeyPkcs8Exportable defines the PKCS #8 binary export contract. The parameterless overload produces an unencrypted PKCS #8 DER structure. The two-argument overloads wrap the key in an encrypted PKCS #8 (EncryptedPrivateKeyInfo) structure using the supplied password and PbeParameters (which control the encryption algorithm and iteration count).

This interface is composed into IPrivateKeyExportable and is also implemented directly by IEddsaPrivateKey.

Methods

Member Returns Description
ExportPkcs8() byte[] Exports the key in PKCS #8 DER format.
ExportPkcs8(ReadOnlySpan<char>, PbeParameters) byte[] Exports the key in encrypted PKCS #8 DER format using a char-based password.
ExportPkcs8(ReadOnlySpan<byte>, PbeParameters) byte[] Exports the key in encrypted PKCS #8 DER format using a byte-based password.

ExportPkcs8 overloads

byte[] ExportPkcs8();
byte[] ExportPkcs8(ReadOnlySpan<char> password, PbeParameters parameters);
byte[] ExportPkcs8(ReadOnlySpan<byte> password, PbeParameters parameters);

Exports the cryptographic private key data in PKCS #8 format.

Parameter Type Description
password ReadOnlySpan<char> or ReadOnlySpan<byte> (encrypted overloads) The password used to encrypt the exported key.
parameters PbeParameters (encrypted overloads) The password-based encryption parameters (algorithm and iteration count).

Returns — A byte[] containing the key in PKCS #8 (or encrypted PKCS #8) DER format.

See Also

ONIXLabs .NET Library


Clone this wiki locally