Skip to main content

Crate pqbox

Crate pqbox 

Source
Expand description

§pqbox

A post-quantum crypto toolkit built from RustCrypto crates, Cryspen’s formally verified libcrux-ml-kem (ML-KEM-1024) and, for Classic McEliece, classic-mceliece-rust. It implements no primitive itself: it composes pinned crates, defines hybrid combiners and a versioned wire format.

Three suites (Suite):

IdNameKEMSignature
0x01xwing (compat only)X-Wing (ML-KEM-768 + X25519)ML-DSA-65 + Ed25519
0x02pqbox-max (default)ML-KEM-1024 + ECDH P-384ML-DSA-87 + ECDSA P-384
0x03pqbox-paranoid (feature paranoid, experimental)ML-KEM-1024 + Classic McEliece 8192128 + ECDH P-384ML-DSA-87 + SLH-DSA-SHAKE-256s + ECDSA P-384

pqbox-paranoid is compiled only with the paranoid cargo feature, which is off by default. Parsers and open accept only pqbox-max unless given a SuitePolicy that allows more (see suite).

Symmetric primitives: XChaCha20-Poly1305 (default) and AES-256-GCM (aead), HKDF-SHA-256 and HMAC-SHA-256 (kdf), SHA-256, SHA3-256 and BLAKE3 (hash), Argon2id (password). Sealed boxes ([seal]) combine a suite’s KEM with HKDF-SHA-256 and XChaCha20-Poly1305.

The crate is sans-IO: it never touches files, the network or the clock, and every function that needs randomness takes a caller-provided CSPRNG (Rng).

Re-exports§

pub use error::Error;
pub use error::Result;
pub use seal::open;
pub use seal::open_with_policy;
pub use seal::seal;
pub use suite::Suite;
pub use suite::SuitePolicy;

Modules§

aead
Authenticated encryption: XChaCha20-Poly1305 (chacha20poly1305, the default) and AES-256-GCM (aes-gcm), with a fresh random nonce per message.
error
Errors returned by every fallible operation.
format
The versioned wire format.
hash
Hash functions: SHA-256 (sha2), SHA3-256 (sha3) and BLAKE3 (blake3).
hazmat
Building blocks the suites use, exposed for known-answer testing.
kdf
Key derivation and MACs: HKDF-SHA-256 (hkdf, RFC 5869) and HMAC-SHA-256 (hmac, RFC 2104).
kem
Hybrid key encapsulation, one construction per Suite.
password
Argon2id (argon2, RFC 9106): password hashing to PHC strings such as $argon2id$v=19$m=65536,t=3,p=1$<salt>$<hash>, and key derivation from a password and a stored salt.
seal
Sealed boxes: anonymous public-key encryption to a KEM public key, in the spirit of libsodium’s crypto_box_seal. The box uses the recipient key’s suite.
sign
Composite (hybrid) signatures, one construction per Suite. Every component signature must verify.
suite
Cipher suites. One byte in every object header names the suite, so a key, a ciphertext or a signature can never be used with another suite’s algorithms.

Traits§

Rng
A cryptographically secure RNG as this crate expects it (rand_core 0.10, infallible).

Functions§

ct_eq
Constant-time equality of two byte strings (lengths are not secret).