Skip to main content

Signer

Trait Signer 

Source
pub trait Signer: Send + Sync {
    // Required methods
    fn sign(&self, payload: &Payload) -> String;
    fn verify(&self, token: &str, expected_purpose: &str) -> Option<Payload>;
}
Expand description

Produces and verifies base64url(json).base64url(mac) tokens where the MAC is computed over the encoded payload string, so a token has exactly one valid encoding (ADR 0006).

The reference implementation keeps a bounded ring of keys (ADR 0014, issue #137): one in the signing state, any number in verification-only, and revoked keys whose tokens are refused. Verification tries every live key’s MAC in constant time; a token naming a revoked key, minted for another venture/environment binding, expired past its policy lifetime, or carrying the wrong purpose verifies as None.

Required Methods§

Source

fn sign(&self, payload: &Payload) -> String

Source

fn verify(&self, token: &str, expected_purpose: &str) -> Option<Payload>

None for malformed input, tampering, expiry, wrong purpose, a revoked key id, or a venture/environment binding mismatch; never panics on malformed input.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§