Timely Pass is designed as a modular system consisting of a core SDK and a consumer CLI.
graph TD
CLI[timely-pass-cli] --> SDK[timely-pass-sdk]
SDK --> Crypto[Crypto Module]
SDK --> Policy[Policy Engine]
SDK --> Store[Secret Store]
Store --> File[(Encrypted File)]
Crypto --> Argon2[Argon2id]
Crypto --> AEAD[XChaCha20Poly1305]
The SDK encapsulates all business logic, security primitives, and data management. It is designed to be embedded in other Rust applications.
crypto: Handles all cryptographic operations.- Wraps
argon2for password hashing and KDF. - Wraps
chacha20poly1305for authenticated encryption. - Implements
SecretandMasterKeytypes withzeroizetraits to ensure secrets are wiped from memory on drop.
- Wraps
policy: Defines the policy structure and serialization (TOML).- Implements the
Policy,Period, andHookstructs.
- Implements the
eval: The policy evaluation engine.- Takes a
Policyand anEvaluationContext(time, usage stats). - Returns a
Verdict(Accept/Reject) and detailed reasons.
- Takes a
store: Manages the persistence layer.- Handles secure reading/writing of the encrypted store file.
- Implements atomic writes using temporary files to prevent data corruption.
- Manages the
Credentialinventory.
A thin wrapper around the SDK, built using clap. It handles:
- Argument parsing.
- User interaction (prompts for passwords).
- Formatting output (tables, JSON).
- File I/O for policy files.
- User invokes
timely-pass get --id <ID>. - CLI prompts for the store passphrase.
- SDK derives the
MasterKeyfrom the passphrase + Salt (stored in file header) using Argon2id. - SDK reads the file header (plaintext, contains salt/version).
- SDK decrypts the payload using the
MasterKey. - SDK deserializes the payload (Bincode) into a
SecretStorestruct. - SDK looks up the credential by ID.
- SDK evaluates the attached policy (if any) against the current time.
- If Allowed:
- SDK increments the usage counter.
- SDK re-encrypts and saves the store.
- CLI prints the secret.
- If Denied:
- CLI prints the rejection reason.
- User invokes
add. - SDK decrypts the store (as above).
- SDK adds the new credential to the in-memory HashMap.
- SDK serializes the updated store.
- SDK encrypts the new payload with a fresh Nonce.
- SDK writes to a temporary file, then atomically renames it to the target path.