polyjose
JSON Object Signing and Encryption in pure Rust: JWS, JWE, JWK, JWA and JWT (RFC 7515 to 7519),
built from RustCrypto and dalek primitives, with no OpenSSL, ring or aws-lc. Verify and decrypt
always take an explicit algorithm allow-list, none is never accepted, and secrets are zeroized
when dropped (RFC 8725).
The same core ships as @polyjose/node, @polyjose/wasm, a Kotlin library for Android and the JVM,
and a Swift package. See https://polyjose.dev for every platform.
Install
Rust 1.89 or later. The crate has no default features. deflate adds JWE compression (zip: DEF,
RFC 7516 §4.1.3), which is off by default because compressing before encrypting can leak plaintext
(RFC 8725 §3.6). Never enable insecure-test-vectors: it exists only for polyjose's own tests.
Quick start: sign and verify a JWT
use SigningAlg;
use ;
use keys;
Every failure is a polyjose::Error; err.code() gives a stable string, such as TokenExpired
or AlgorithmNotAllowed, that is the same on every platform.
Encrypt and decrypt (JWE)
use ;
use ;
use EcCurve;
use ;
The plaintext is wiped from memory when decrypted is dropped.
Documentation
- Guides for every platform: https://polyjose.dev
- Getting started in Rust: https://polyjose.dev/start/rust/
- API reference: https://docs.rs/polyjose
- Security model: https://polyjose.dev/security/model/
- Source, issues and changelog: https://github.com/bharathkontham/polyjose
License
MIT. See https://github.com/bharathkontham/polyjose/blob/main/LICENSE.