pakery-spake2
SPAKE2 balanced PAKE protocol implementation (RFC 9382).
Part of the pakery workspace.
SPAKE2 is a balanced (symmetric) PAKE with mutual explicit key confirmation. Both parties share a password-derived scalar and agree on a session key with provable security.
Usage
[]
= "0.1"
= { = "0.1", = ["ristretto255"] }
Example
use ;
use ;
use ;
use Hash;
;
// Requires the `os_rng` crate feature. In rand_core 0.9 `OsRng` only
// implements `TryRngCore`; `UnwrapErr` adapts it to the `CryptoRng`
// bound used by pakery's API (panics on RNG failure, which never
// happens on a real OS).
let mut rng = UnwrapErr;
// Derive password scalar
let hash = digest;
let w = scalar_from_wide_bytes.unwrap;
// Both parties exchange shares and derive keys
let = start.unwrap;
let = start.unwrap;
let out_a = state_a.finish.unwrap;
let out_b = state_b.finish.unwrap;
// Session keys match
assert_eq!;
// Verify mutual confirmation MACs
out_a.verify_peer_confirmation.unwrap;
out_b.verify_peer_confirmation.unwrap;
Features
| Feature | Description |
|---|---|
std (default) |
Enable std support |
getrandom |
Enable OS-backed RNG via rand_core/getrandom |
test-utils |
Expose deterministic constructors for testing |
Security
#![forbid(unsafe_code)]- Constant-time comparisons via
subtle - Secret values zeroized on drop via
zeroize - Validated against RFC 9382 test vectors
MSRV
The minimum supported Rust version is 1.79.
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.