pub struct RsaPublicKey { /* private fields */ }Expand description
An RSA public key for JWT verification, supporting both PKCS#1 v1.5 and RSA-PSS signatures.
§Algorithms
| Variant | JWT Algorithm | Scheme | Hash |
|---|---|---|---|
| RS256 | RS256 | PKCS#1 v1.5 | SHA-256 |
| RS384 | RS384 | PKCS#1 v1.5 | SHA-384 |
| RS512 | RS512 | PKCS#1 v1.5 | SHA-512 |
| PS256 | PS256 | RSA-PSS | SHA-256 |
| PS384 | PS384 | RSA-PSS | SHA-384 |
| PS512 | PS512 | RSA-PSS | SHA-512 |
Signing is not supported — this key type is verification-only.
§Constructors
RsaPublicKey::from_n_e— build from raw modulus and exponent bytes (useful with JWK)RsaPublicKey::from_pkcs1_der— parse from PKCS#1 DERSEQUENCE { INTEGER n, INTEGER e }
§Errors
Returns Error::InvalidKey if the algorithm is not an RSA variant or
if the underlying RSA key parsing fails. Returns Error::InvalidSignature
on verification failures.
Implementations§
Source§impl RsaPublicKey
impl RsaPublicKey
Sourcepub fn from_pkcs1_der(pkcs1_der: &[u8], alg: Algorithm) -> Result<Self, Error>
pub fn from_pkcs1_der(pkcs1_der: &[u8], alg: Algorithm) -> Result<Self, Error>
Parse an RSA public key from PKCS#1 DER bytes.
The input is the raw SEQUENCE { INTEGER n, INTEGER e } inside the
SubjectPublicKeyInfo BIT STRING.
§Errors
Returns Error::InvalidKey if alg is not an RSA algorithm
or if the DER bytes do not encode a valid RSA public key.
Trait Implementations§
Source§impl From<&RsaPublicKey> for Jwk
impl From<&RsaPublicKey> for Jwk
Source§fn from(key: &RsaPublicKey) -> Self
fn from(key: &RsaPublicKey) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RsaPublicKey
impl RefUnwindSafe for RsaPublicKey
impl Send for RsaPublicKey
impl Sync for RsaPublicKey
impl Unpin for RsaPublicKey
impl UnsafeUnpin for RsaPublicKey
impl UnwindSafe for RsaPublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more