Skip to content

OnixLabs.Security.Cryptography.IPublicKeyPemImportable

matthew edited this page May 27, 2026 · 1 revision

IPublicKeyPemImportable<T> Interface

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

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

Definition

public interface IPublicKeyPemImportable<out T> where T : PublicKey

Type Parameters

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

Remarks

IPublicKeyPemImportable<T> defines the contract for importing a public key from RFC 7468 PEM-encoded text. The PEM label determines the encoding format that is decoded — typically PUBLIC KEY (SPKI). All import members are declared static abstract and are called on the concrete implementing type, not on an instance.

An unencrypted ImportPem(ReadOnlySpan<char>) overload handles plain PUBLIC KEY PEM blocks. The two password overloads handle encrypted PEM, accepting either a char-based or byte-based password for password-based decryption.

This interface is composed into IPublicKeyImportable<T> alongside IPublicKeyRawImportable<T>. Callers that need both import forms should depend on IPublicKeyImportable<T> rather than the two leaf interfaces individually.

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 public key from RFC 7468 PEM-encoded text. The PEM label determines the format that is decoded (typically PUBLIC KEY, i.e. SPKI).

Parameter Type Description
data ReadOnlySpan<char> The PEM-encoded public 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 public key.

See Also

ONIXLabs .NET Library


Clone this wiki locally