pub struct PublicKey { /* private fields */ }Expand description
An RSA public key parsed from a PKCS#1 SubjectPublicKeyInfo DER blob.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_n_e(n_bytes: &[u8], e: &[u8]) -> Result<Self, RsaError>
pub fn from_n_e(n_bytes: &[u8], e: &[u8]) -> Result<Self, RsaError>
Build an RSA public key from raw modulus n and public exponent e
(both big-endian byte slices).
This is useful when importing keys from formats like JWK where n and
e are available directly as bytes rather than inside an ASN.1 DER
wrapper.
Sourcepub fn from_pkcs1_der(data: &[u8]) -> Result<Self, RsaError>
pub fn from_pkcs1_der(data: &[u8]) -> Result<Self, RsaError>
Parse an RSA public key from the raw PKCS#1 bytes.
The input is the content of the BIT STRING inside the SPKI —
an ASN.1 SEQUENCE { INTEGER n, INTEGER e }.
Sourcepub fn verify_pkcs1_v1_5(
&self,
signature: &[u8],
message_digest: &[u8],
digest_info_prefix: &[u8],
) -> Result<(), RsaError>
pub fn verify_pkcs1_v1_5( &self, signature: &[u8], message_digest: &[u8], digest_info_prefix: &[u8], ) -> Result<(), RsaError>
Verify a PKCS#1 v1.5 signature.
signature is the raw signature bytes (eg., 256 bytes for RSA-2048).
message_digest is the hash of the message to verify.
digest_info_prefix is the ASN.1 DigestInfo prefix for the hash algorithm
(the constant-length portion before the hash value).
Sourcepub fn verify_pss<H: Hasher>(
&self,
signature: &[u8],
message: &[u8],
salt_len: usize,
) -> Result<(), RsaError>
pub fn verify_pss<H: Hasher>( &self, signature: &[u8], message: &[u8], salt_len: usize, ) -> Result<(), RsaError>
Verify an RSA-PSS signature (RFC 8017 §9.1.2).
message_digest is the hash of the TLS signed_data.
hash_fn produces a digest of hash_len bytes.
salt_len equals the hash length (Go’s PSSSaltLengthEqualsHash).