pub struct Rs256Signer { /* private fields */ }Expand description
Signs RS256 JWTs with an RSA private key.
Google’s service-account JSON ships its key as PKCS#8
(-----BEGIN PRIVATE KEY-----); older exports and other providers use the
legacy PKCS#1 form (-----BEGIN RSA PRIVATE KEY-----). Self::from_pem
takes either, so a venture never has to know which it was handed.
PKCS#1 v1.5 signing is deterministic and takes no RNG, which is what lets
this run on a Workers isolate. That is a portability property, not a
security one: rsa 0.9 blinds the private-key modexp only in
sign_with_rng, so signing here is unblinded and carries no timing
countermeasure. It is safe in this crate because there is no decryption
oracle, the claims are ours rather than an attacker’s, and the JWT is
minted off the request path where nobody can time it — see the
RUSTSEC-2023-0071 acceptance in deny.toml. Signing attacker-supplied
bytes, or signing where the duration can be observed, re-opens that.
Implementations§
Source§impl Rs256Signer
impl Rs256Signer
Sourcepub fn from_pkcs8_pem(pem: &str) -> Result<Self, KeyError>
pub fn from_pkcs8_pem(pem: &str) -> Result<Self, KeyError>
Parses a PKCS#8 PEM RSA private key — the form Google’s
service-account JSON carries in private_key.
§Errors
KeyError::Parse if the PEM is not a PKCS#8 RSA private key.
Sourcepub fn from_pkcs1_pem(pem: &str) -> Result<Self, KeyError>
pub fn from_pkcs1_pem(pem: &str) -> Result<Self, KeyError>
Parses the legacy PKCS#1 PEM form
(-----BEGIN RSA PRIVATE KEY-----).
§Errors
KeyError::Parse if the PEM is not a PKCS#1 RSA private key.