Skip to content

OnixLabs.Security.Cryptography.IPrivateKeyPkcs8PemExportable

matthew edited this page May 27, 2026 · 1 revision

IPrivateKeyPkcs8PemExportable Interface

Defines a cryptographic private key that can be exported in PKCS #8 RFC 7468 PEM form.

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

Definition

public interface IPrivateKeyPkcs8PemExportable
{
    string ExportPkcs8Pem();
    string ExportPkcs8Pem(ReadOnlySpan<char> password, PbeParameters parameters);
    string ExportPkcs8Pem(ReadOnlySpan<byte> password, PbeParameters parameters);
}

Remarks

IPrivateKeyPkcs8PemExportable defines the PKCS #8 PEM export contract. Unencrypted output uses the RFC 7468 PRIVATE KEY PEM label; encrypted output uses ENCRYPTED PRIVATE KEY. Unlike IPrivateKeyRawPemExportable, which produces algorithm-native PEM (e.g. EC PRIVATE KEY), this interface always produces the format-neutral PKCS #8 PEM encoding.

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

Methods

Member Returns Description
ExportPkcs8Pem() string Exports the key in PKCS #8 RFC 7468 PEM format.
ExportPkcs8Pem(ReadOnlySpan<char>, PbeParameters) string Exports the key in encrypted PKCS #8 RFC 7468 PEM format using a char-based password.
ExportPkcs8Pem(ReadOnlySpan<byte>, PbeParameters) string Exports the key in encrypted PKCS #8 RFC 7468 PEM format using a byte-based password.

ExportPkcs8Pem overloads

string ExportPkcs8Pem();
string ExportPkcs8Pem(ReadOnlySpan<char> password, PbeParameters parameters);
string ExportPkcs8Pem(ReadOnlySpan<byte> password, PbeParameters parameters);

Exports the cryptographic private key data in PKCS #8 RFC 7468 PEM format. Unencrypted output uses the PRIVATE KEY PEM label; encrypted output uses ENCRYPTED PRIVATE KEY.

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.

Returns — A string containing the PEM-encoded PKCS #8 private key.

See Also

ONIXLabs .NET Library


Clone this wiki locally