Expand description
PASETO v5 using AWS-LC for ML-DSA-87 signatures and symmetric encryption.
Enable fips to use the AWS-LC FIPS module, or non-fips to require the
non-FIPS backend. These features are mutually exclusive. Without either,
AWS-LC uses its default backend.
New signing keys are generated inside AWS-LC. Secret-key encodings contain the 32-byte ML-DSA seed; importing a seed preserves its existing provenance.
Plaintext key encodings follow the post-quantum PASERK draft. Key IDs, wrapping and sealing are not implemented by this backend.
§PASERK plaintext keys
Format a public key with to_string(). For local and secret keys,
expose_key().to_string() exports the secret material in plaintext.
Parse that text into the corresponding key type. Use KeyText for raw bytes:
use paseto_v5_aws_lc::{KeyText, SecretKey};
let seed = [7; 32];
let key: SecretKey = KeyText::from_raw_bytes(&seed).try_into()?;
let text = key.expose_key().to_string();
let restored: SecretKey = text.parse()?;
assert_eq!(restored.expose_key().as_raw_bytes(), &seed);§Sign and verify a public token
use paseto_v5_aws_lc::{SecretKey, SignedToken, UnsignedToken};
use paseto_json::{ForAudience, HasExpiry, RegisteredClaims, Time, Validate};
use std::time::Duration;
let key = SecretKey::random()?;
let claims = RegisteredClaims::now(Duration::from_secs(300)).for_audience("inbox".into());
let token = UnsignedToken::new(claims).sign(&key)?.to_string();
let received: SignedToken<RegisteredClaims> = token.parse()?;
let policy = Time::valid_now().and_then(HasExpiry).and_then(ForAudience("inbox"));
let accepted = received.verify(&key.public_key(), &policy)?;
assert_eq!(accepted.claims.aud.as_deref(), Some("inbox"));§Encrypt and decrypt a local token
use paseto_v5_aws_lc::{EncryptedToken, LocalKey, UnencryptedToken};
use paseto_json::{ForAudience, HasExpiry, RegisteredClaims, Time, Validate};
use std::time::Duration;
let key = LocalKey::random()?;
let claims = RegisteredClaims::now(Duration::from_secs(300)).for_audience("inbox".into());
let token = UnencryptedToken::new(claims).encrypt(&key)?.to_string();
let received: EncryptedToken<RegisteredClaims> = token.parse()?;
let policy = Time::valid_now().and_then(HasExpiry).and_then(ForAudience("inbox"));
let accepted = received.decrypt(&key, &policy)?;
assert_eq!(accepted.claims.aud.as_deref(), Some("inbox"));Modules§
- core
- Low level implementation primitives.
Enums§
- Paseto
Error - Error returned for all PASETO and PASERK operations that can fail
Type Aliases§
- Encrypted
Token - A token with secret data.
- KeyText
- A plaintext encoding of a key.
- Local
Key - Private key used for token encryption and decryption.
- Public
Key - Public key used for signature verification.
- Secret
Key - Private key used for token signing.
- Signed
Token - A token with publicly readable data, but not yet verified.
- Unencrypted
Token - An
EncryptedTokenthat has been decrypted. - Unsigned
Token - A
SignedTokenthat has been verified.