Expand description
§jose4rs
A Rust implementation of the JOSE standards – JWS (RFC 7515), JWE (RFC 7516), JWK (RFC 7517), and JWT (RFC 7519) – ported from the Java jose4j library.
§Modules
jwk– JSON Web Keys and key sets, plus optional HTTPS JWKS fetching.jws– JSON Web Signature creation and verification.jwe– JSON Web Encryption encryption and decryption.jwt– JWT claims and a validating consumer.jwa– algorithm identifiers and algorithm constraints.jwx– shared JOSE header parameters and structure traits.error– the crate’s error type.
§Design goals
- Minimal allocations on the hot parse/verify/decrypt paths. Decoded JOSE parts are referenced by offset into a single owned buffer rather than copied.
- No panics on attacker-controlled input. Malformed tokens and keys
return
error::JoseError; panics are reserved for internal invariants. - Backend flexibility. Cryptography is provided by aws-lc-rs (default) or BoringSSL, selected by feature flag. ML-DSA is currently available only with AWS-LC.
§Features
| Feature | Effect |
|---|---|
aws-lc (default) | Use the aws-lc-rs cryptography backend. Mutually exclusive with boring. |
boring | Use the BoringSSL cryptography backend. Mutually exclusive with aws-lc. |
base64-simd (default) | SIMD-accelerated base64. |
base64 | Portable (non-SIMD) base64 fallback. |
pq-ml-dsa | ML-DSA signatures and AKP JWKs (RFC 9964); implies aws-lc. |
jwks-https | Blocking HTTPS JWKS fetching (bring your own transport). |
jwks-https-async | Async HTTPS JWKS fetching; implies jwks-https. |
Exactly one cryptography backend (aws-lc or boring) must be enabled;
selecting both or neither is a compile error.
§Example
Verify a JWS and read its payload:
use jose4rs::jws::JsonWebSignature;
use jose4rs::jwk::JsonWebKey;
let key = JsonWebKey::from_json(key_json)?;
let mut jws = JsonWebSignature::from_compact_serialization(compact)?;
let payload = jws.payload(&key)?; // verifies the signature firstModules§
- error
- The crate error type,
error::JoseError. - jwa
- JOSE algorithms: identifiers and algorithm-constraint enforcement.
- jwe
- JSON Web Encryption (JWE, RFC 7516) creation and decryption.
- jwk
- JSON Web Keys (JWK, RFC 7517) and key sets (JWKS).
- jws
- JSON Web Signature (JWS, RFC 7515) creation and verification. JSON Web Signature (JWS) implementation.
- jwt
- JSON Web Token (JWT, RFC 7519) claims and a validating consumer. JWT (JSON Web Token) Claims handling.
- jwx
- Shared JOSE header parameters and the common structure trait.