Skip to content

OnixLabs.Security.Cryptography.IRsaPublicKey

matthew edited this page May 27, 2026 · 1 revision

IRsaPublicKey Interface

Defines an RSA cryptographic public key.

Namespace OnixLabs.Security.Cryptography
Assembly OnixLabs.Security.Cryptography.dll (NuGet)
Implements IPublicKeyImportable<RsaPublicKey>, IPublicKeyExportable, IBinaryConvertible

Definition

public interface IRsaPublicKey :
    IPublicKeyImportable<RsaPublicKey>,
    IPublicKeyExportable,
    IBinaryConvertible

Remarks

IRsaPublicKey follows the same IsDataValid / VerifyData / IsHashValid / VerifyHash pattern as IEcdsaPublicKey, but every overload requires an RSASignaturePadding argument in addition to the HashAlgorithmName. RSA public keys accept only HashAlgorithmName (not a HashAlgorithm instance), consistent with the .NET RSA API. There are no slice overloads for IsHashValid / VerifyHash.

Methods

Member Returns Description
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) bool Checks if a span was signed with the given raw signature.
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithmName, RSASignaturePadding) bool Checks if a byte-range slice was signed with the given raw signature.
IsDataValid(ReadOnlySpan<byte>, Stream, HashAlgorithmName, RSASignaturePadding) bool Checks if a stream was signed with the given raw signature.
IsDataValid(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithmName, RSASignaturePadding) bool Checks if an IBinaryConvertible was signed with the given raw signature.
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) bool Checks if a span was signed with a DigitalSignature.
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithmName, RSASignaturePadding) bool Checks if a byte-range slice was signed with a DigitalSignature.
IsDataValid(DigitalSignature, Stream, HashAlgorithmName, RSASignaturePadding) bool Checks if a stream was signed with a DigitalSignature.
IsDataValid(DigitalSignature, IBinaryConvertible, HashAlgorithmName, RSASignaturePadding) bool Checks if an IBinaryConvertible was signed with a DigitalSignature.
IsHashValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) bool Checks if a raw hash span was signed with the given raw signature.
IsHashValid(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) bool Checks if a raw hash span was signed with a DigitalSignature.
IsHashValid(ReadOnlySpan<byte>, Hash, HashAlgorithmName, RSASignaturePadding) bool Checks if a Hash was signed with the given raw signature.
IsHashValid(DigitalSignature, Hash, HashAlgorithmName, RSASignaturePadding) bool Checks if a Hash was signed with a DigitalSignature.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) void Verifies a span; throws on failure.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithmName, RSASignaturePadding) void Verifies a byte-range slice; throws on failure.
VerifyData(ReadOnlySpan<byte>, Stream, HashAlgorithmName, RSASignaturePadding) void Verifies a stream; throws on failure.
VerifyData(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithmName, RSASignaturePadding) void Verifies an IBinaryConvertible; throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) void Verifies a span using a DigitalSignature; throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithmName, RSASignaturePadding) void Verifies a byte-range slice using a DigitalSignature; throws on failure.
VerifyData(DigitalSignature, Stream, HashAlgorithmName, RSASignaturePadding) void Verifies a stream using a DigitalSignature; throws on failure.
VerifyData(DigitalSignature, IBinaryConvertible, HashAlgorithmName, RSASignaturePadding) void Verifies an IBinaryConvertible using a DigitalSignature; throws on failure.
VerifyHash(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) void Verifies a raw hash span with a raw signature; throws on failure.
VerifyHash(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, RSASignaturePadding) void Verifies a raw hash span with a DigitalSignature; throws on failure.
VerifyHash(ReadOnlySpan<byte>, Hash, HashAlgorithmName, RSASignaturePadding) void Verifies a Hash with a raw signature; throws on failure.
VerifyHash(DigitalSignature, Hash, HashAlgorithmName, RSASignaturePadding) void Verifies a Hash with a DigitalSignature; throws on failure.

IsDataValid overloads

bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(ReadOnlySpan<byte> signature, Stream data, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(DigitalSignature signature, Stream data, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsDataValid(DigitalSignature signature, IBinaryConvertible data, HashAlgorithmName algorithm, RSASignaturePadding padding);

Determines whether the specified data was signed by the RSA private key corresponding to this public key.

Parameter Type Description
signature ReadOnlySpan<byte> or DigitalSignature The signature to validate.
data ReadOnlySpan<byte> / Stream / IBinaryConvertible The unsigned data to validate.
offset int (slice overloads) The offset into the span from which to begin reading.
count int (slice overloads) The number of bytes to read from the span.
algorithm HashAlgorithmName The hash algorithm used when signing.
padding RSASignaturePadding The RSA signature padding mode used when signing.

Returns — true if the signature is valid for the supplied data; otherwise false.


IsHashValid overloads

bool IsHashValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsHashValid(DigitalSignature signature, ReadOnlySpan<byte> hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsHashValid(ReadOnlySpan<byte> signature, Hash hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
bool IsHashValid(DigitalSignature signature, Hash hash, HashAlgorithmName algorithm, RSASignaturePadding padding);

Determines whether the specified pre-computed hash was signed by the RSA private key corresponding to this public key.

Parameter Type Description
signature ReadOnlySpan<byte> or DigitalSignature The signature to validate.
hash ReadOnlySpan<byte> or Hash The pre-computed hash to validate.
algorithm HashAlgorithmName The hash algorithm used when signing.
padding RSASignaturePadding The RSA signature padding mode used when signing.

Returns — true if the signature is valid for the supplied hash; otherwise false.


VerifyData overloads

void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(ReadOnlySpan<byte> signature, Stream data, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(DigitalSignature signature, Stream data, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyData(DigitalSignature signature, IBinaryConvertible data, HashAlgorithmName algorithm, RSASignaturePadding padding);

Verifies that the specified data was signed by the RSA private key corresponding to this public key. Throws if verification fails.

Parameters match those of the IsDataValid overloads above.

Exceptions — Throws (implementation-defined, typically CryptographicException) if the signature is not valid for the supplied data and key.


VerifyHash overloads

void VerifyHash(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyHash(DigitalSignature signature, ReadOnlySpan<byte> hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyHash(ReadOnlySpan<byte> signature, Hash hash, HashAlgorithmName algorithm, RSASignaturePadding padding);
void VerifyHash(DigitalSignature signature, Hash hash, HashAlgorithmName algorithm, RSASignaturePadding padding);

Verifies that the specified pre-computed hash was signed by the RSA private key corresponding to this public key. Throws if verification fails.

Parameters match those of the IsHashValid overloads above.

Exceptions — Throws (implementation-defined, typically CryptographicException) if the signature is not valid for the supplied hash and key.

See Also

ONIXLabs .NET Library


Clone this wiki locally