paseto-v3-aws-lc

Crates.iopaseto-v3-aws-lc
lib.rspaseto-v3-aws-lc
version0.1.0-rc.8
created_at2025-09-21 14:20:58.892997+00
updated_at2025-10-26 11:41:36.521639+00
descriptionPASETO/PASERK V3 based on AWS-LC
homepage
repositoryhttps://github.com/conradludgate/paseto-rs
max_upload_size
id1848850
size64,442
Conrad Ludgate (conradludgate)

documentation

README

paseto-v3-aws-lc

AWS-LC based PASETO V3 implementation.

Examples

use paseto_v3_aws_lc::UnsignedToken;
use paseto_v3_aws_lc::key::{SecretKey, SealingKey};
use paseto_json::RegisteredClaims;
use std::time::Duration;

// create a new keypair
let secret_key = SecretKey::random().unwrap();
let public_key = secret_key.public_key();

// create a set of token claims
let claims = RegisteredClaims::now(Duration::from_secs(3600))
    .from_issuer("https://paseto.conrad.cafe/".to_string())
    .for_subject("conradludgate".to_string());

// create and sign a new token
let signed_token = UnsignedToken::new(claims).sign(&secret_key).unwrap();

// serialize the token.
let token = signed_token.to_string();
// "v3.public..."

// serialize the public key.
let key = public_key.to_string();
// "k3.public..."
use paseto_v3_aws_lc::SignedToken;
use paseto_v3_aws_lc::key::PublicKey;
use paseto_json::{RegisteredClaims, Time, HasExpiry, FromIssuer, ForSubject, Validate};

// parse the token
let signed_token: SignedToken<RegisteredClaims> = token.parse().unwrap();

// parse the key
let public_key: PublicKey = key.parse().unwrap();

// verify the token signature and validate the claims.
let validation = Time::valid_now()
    .and_then(HasExpiry)
    .and_then(FromIssuer("https://paseto.conrad.cafe/"))
    .and_then(ForSubject("conradludgate"));
let verified_token = signed_token.verify(&public_key, &validation).unwrap();
Commit count: 21

cargo fmt