Skip to content

OnixLabs.Security.Cryptography.IPrivateKeyPkcs8Importable

matthew edited this page May 27, 2026 · 1 revision

IPrivateKeyPkcs8Importable<T> Interface

Defines a cryptographic private key that can be imported from PKCS #8 binary form.

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

Definition

public interface IPrivateKeyPkcs8Importable<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

IPrivateKeyPkcs8Importable<T> defines the PKCS #8 binary import contract. Unencrypted overloads accept a raw PKCS #8 DER buffer; encrypted overloads additionally accept a password to decrypt an EncryptedPrivateKeyInfo structure. Overloads that include an out int bytesRead parameter report how many bytes were consumed from the input span, which is useful when importing from a larger buffer. 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
ImportPkcs8(ReadOnlySpan<byte>) T Imports unencrypted PKCS #8 from a span.
ImportPkcs8(ReadOnlySpan<byte>, out int) T Imports unencrypted PKCS #8 from a span; reports bytes read.
ImportPkcs8(ReadOnlySpan<byte>, ReadOnlySpan<char>) T Imports encrypted PKCS #8 from a span using a char-based password.
ImportPkcs8(ReadOnlySpan<byte>, ReadOnlySpan<char>, out int) T Imports encrypted PKCS #8 from a span using a char-based password; reports bytes read.
ImportPkcs8(ReadOnlySpan<byte>, ReadOnlySpan<byte>) T Imports encrypted PKCS #8 from a span using a byte-based password.
ImportPkcs8(ReadOnlySpan<byte>, ReadOnlySpan<byte>, out int) T Imports encrypted PKCS #8 from a span using a byte-based password; reports bytes read.
ImportPkcs8(IBinaryConvertible) T Imports unencrypted PKCS #8 from an IBinaryConvertible.
ImportPkcs8(IBinaryConvertible, out int) T Imports unencrypted PKCS #8 from an IBinaryConvertible; reports bytes read.
ImportPkcs8(IBinaryConvertible, ReadOnlySpan<char>) T Imports encrypted PKCS #8 from an IBinaryConvertible using a char-based password.
ImportPkcs8(IBinaryConvertible, ReadOnlySpan<char>, out int) T Imports encrypted PKCS #8 from an IBinaryConvertible using a char-based password; reports bytes read.
ImportPkcs8(IBinaryConvertible, ReadOnlySpan<byte>) T Imports encrypted PKCS #8 from an IBinaryConvertible using a byte-based password.
ImportPkcs8(IBinaryConvertible, ReadOnlySpan<byte>, out int) T Imports encrypted PKCS #8 from an IBinaryConvertible using a byte-based password; reports bytes read.

ImportPkcs8 overloads

public static abstract T ImportPkcs8(ReadOnlySpan<byte> data);
public static abstract T ImportPkcs8(ReadOnlySpan<byte> data, out int bytesRead);
public static abstract T ImportPkcs8(ReadOnlySpan<byte> data, ReadOnlySpan<char> password);
public static abstract T ImportPkcs8(ReadOnlySpan<byte> data, ReadOnlySpan<char> password, out int bytesRead);
public static abstract T ImportPkcs8(ReadOnlySpan<byte> data, ReadOnlySpan<byte> password);
public static abstract T ImportPkcs8(ReadOnlySpan<byte> data, ReadOnlySpan<byte> password, out int bytesRead);
public static abstract T ImportPkcs8(IBinaryConvertible data);
public static abstract T ImportPkcs8(IBinaryConvertible data, out int bytesRead);
public static abstract T ImportPkcs8(IBinaryConvertible data, ReadOnlySpan<char> password);
public static abstract T ImportPkcs8(IBinaryConvertible data, ReadOnlySpan<char> password, out int bytesRead);
public static abstract T ImportPkcs8(IBinaryConvertible data, ReadOnlySpan<byte> password);
public static abstract T ImportPkcs8(IBinaryConvertible data, ReadOnlySpan<byte> password, out int bytesRead);

Imports a cryptographic private key from PKCS #8 DER-encoded data.

Parameter Type Description
data ReadOnlySpan<byte> or IBinaryConvertible The PKCS #8 DER-encoded key data to import.
password ReadOnlySpan<char> or ReadOnlySpan<byte> (encrypted overloads) The password required for password-based decryption.
bytesRead out int (bytesRead overloads) Receives the number of bytes consumed from data.

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

See Also

ONIXLabs .NET Library


Clone this wiki locally