Skip to content

OnixLabs.Security.Cryptography.IRsaPrivateKey

matthew edited this page May 27, 2026 · 1 revision

IRsaPrivateKey Interface

Defines an RSA cryptographic private key.

Namespace OnixLabs.Security.Cryptography
Assembly OnixLabs.Security.Cryptography.dll (NuGet)
Implements IPrivateKeyDerivable<RsaPublicKey>, IPrivateKeyImportable<RsaPrivateKey>, IPrivateKeyExportable, IBinaryConvertible

Definition

public interface IRsaPrivateKey :
    IPrivateKeyDerivable<RsaPublicKey>,
    IPrivateKeyImportable<RsaPrivateKey>,
    IPrivateKeyExportable,
    IBinaryConvertible

Remarks

IRsaPrivateKey follows the same SignData / SignHash pattern as IEcdsaPrivateKey but always requires an RSASignaturePadding argument (PKCS1v15 or PSS) in addition to the hash algorithm. RSA keys accept a HashAlgorithmName only (not a HashAlgorithm instance), consistent with the .NET RSA API.

Methods

Member Returns Description
SignData(ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) byte[] Hashes and signs a span of bytes.
SignData(ReadOnlySpan<byte>, int, int, HashAlgorithmName, RSASignaturePadding) byte[] Hashes and signs a byte-range slice.
SignData(Stream, HashAlgorithmName, RSASignaturePadding) byte[] Hashes and signs a Stream.
SignData(IBinaryConvertible, HashAlgorithmName, RSASignaturePadding) byte[] Hashes and signs an IBinaryConvertible.
SignHash(Hash, HashAlgorithmName, RSASignaturePadding) byte[] Signs a pre-computed Hash.
SignHash(ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) byte[] Signs a pre-computed hash supplied as a raw span.

SignData overloads

byte[] SignData(ReadOnlySpan<byte> data, HashAlgorithmName algorithm, RSASignaturePadding padding);
byte[] SignData(ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, RSASignaturePadding padding);
byte[] SignData(Stream data, HashAlgorithmName algorithm, RSASignaturePadding padding);
byte[] SignData(IBinaryConvertible data, HashAlgorithmName algorithm, RSASignaturePadding padding);

Hashes the specified input data and signs the resulting hash.

Parameter Type Description
data ReadOnlySpan<byte> / Stream / IBinaryConvertible The input data to hash and sign.
offset int (slice overload) The offset into the span from which to begin reading.
count int (slice overload) The number of bytes to read from the span.
algorithm HashAlgorithmName The hash algorithm used to hash the input data.
padding RSASignaturePadding The RSA signature padding mode (e.g. RSASignaturePadding.Pkcs1 or RSASignaturePadding.Pss).

Returns — A byte[] containing the cryptographic digital signature.


SignHash overloads

byte[] SignHash(Hash hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
byte[] SignHash(ReadOnlySpan<byte> hash, HashAlgorithmName algorithm, RSASignaturePadding padding);

Signs a pre-computed hash value.

Parameter Type Description
hash Hash or ReadOnlySpan<byte> The pre-computed hash to sign.
algorithm HashAlgorithmName The hash algorithm that was used to produce the hash.
padding RSASignaturePadding The RSA signature padding mode.

Returns — A byte[] containing the cryptographic digital signature.

See Also

ONIXLabs .NET Library


Clone this wiki locally