rust-keyvault
A secure, modern cryptographic key management library for Rust.
rust-keyvault features
- AEAD Encryption: ChaCha20-Poly1305 and AES-256-GCM
- Key Rotation: Automatic versioning and lifecycle management
- Encrypted Storage: File-based persistence with Argon2 key derivation
- Thread-Safe: Multi-threaded storage backends
- Memory Protection: Automatic zeroization of sensitive data
- Zero Unsafe:
#![forbid(unsafe_code)]- completely memory safe
Quick Start
Add to your Cargo.toml;
[]
= "0.1"
Basic Usage
use *;
use *;
use SystemTime;
// Create an encrypted file store
let config = StorageConfig ;
let mut store = new?;
store.init_with_password?;
// Generate a new key
let base_id = generate_base?;
let secret_key = generate?;
let metadata = KeyMetadata ;
let versioned_key = VersionedKey ;
// Store the key
store.store?;
// Retrieve and use
let retrieved = store.retrieve?;
println!;
Key Rotation
// Rotate to a new version
let rotated_key = store.rotate_key?;
println!; // 2
// Get all versions
let versions = store.get_key_versions?;
println!; // 2
// Get latest active key
let latest = store.get_latest_key?;
Architecture
┌─────────────────┐
│ Applications │
└─────────────────┘
│
┌─────────────────┐ ┌──────────────────┐
│ KeyStore │ │ EncryptedStore │
│ Traits │ │ Traits │
└─────────────────┘ └──────────────────┘
│ │
┌─────────────────┐ ┌──────────────────┐
│ MemoryStore │ │ FileStore │
│ (Testing) │ │ (Production) │
└─────────────────┘ └──────────────────┘
│ │
┌─────────────────┐ ┌──────────────────┐
│ AEAD Crypto │ │ Argon2 KDF │
│ ChaCha20/AES │ │ Key Derivation │
└─────────────────┘ └──────────────────┘
Security Features
- Modern Cryptography: ChaCha20-Poly1305 and AES-256-GCM AEAD
- Memory Safety: Automatic zeroization with
zeroizecrate - Key Derivation: Argon2id password-based key derivation
- Authenticated Encryption: Built-in integrity protection
- Secure Random: ChaCha20-based CSPRNG
Documentation
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.