Skip to content

OnixLabs.Security.Cryptography.IPrivateKeyPemImportable

matthew edited this page May 27, 2026 · 1 revision

IPrivateKeyPemImportable<T> Interface

Defines a cryptographic private key that can be imported from RFC 7468 PEM-encoded data.

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

Definition

public interface IPrivateKeyPemImportable<out T> where T : PrivateKey

Type Parameters

Parameter Description
T The type of PrivateKey returned by the static import members. Declared covariant (out T). Must derive from PrivateKey.

Remarks

IPrivateKeyPemImportable<T> defines the PEM import contract. The PEM label in the input data determines the encoding format — for example, PKCS #8 PRIVATE KEY, SEC1 EC PRIVATE KEY, or PKCS #1 RSA PRIVATE KEY. The two-argument overloads additionally decrypt an ENCRYPTED PRIVATE KEY PEM block using the supplied password. All members are declared static abstract and are called on the concrete type.

This interface is composed into IPrivateKeyImportable<T> and is also implemented directly by IEddsaPrivateKey.

Methods

Member Returns Description
ImportPem(ReadOnlySpan<char>) T Imports from unencrypted RFC 7468 PEM-encoded text.
ImportPem(ReadOnlySpan<char>, ReadOnlySpan<char>) T Imports from encrypted PEM using a char-based password.
ImportPem(ReadOnlySpan<char>, ReadOnlySpan<byte>) T Imports from encrypted PEM using a byte-based password.

ImportPem overloads

public static abstract T ImportPem(ReadOnlySpan<char> data);
public static abstract T ImportPem(ReadOnlySpan<char> data, ReadOnlySpan<char> password);
public static abstract T ImportPem(ReadOnlySpan<char> data, ReadOnlySpan<byte> password);

Imports a cryptographic private key from RFC 7468 PEM-encoded text. The PEM label determines the encoding format (for example, PKCS #8 PRIVATE KEY, SEC1 EC PRIVATE KEY, or PKCS #1 RSA PRIVATE KEY). The two-argument overloads additionally decrypt an ENCRYPTED PRIVATE KEY PEM block.

Parameter Type Description
data ReadOnlySpan<char> The PEM-encoded private key data to import.
password ReadOnlySpan<char> or ReadOnlySpan<byte> (encrypted overloads) The password required for password-based decryption.

Returns — A new T instance containing the imported private key.

See Also

ONIXLabs .NET Library


Clone this wiki locally