anubis_vault/lib.rs
1//! # Anubis Vault - The World's Most Secure Secrets Manager
2//!
3//! [](https://crates.io/crates/anubis-vault)
4//! [](https://docs.rs/anubis-vault)
5//! [](https://github.com/AnubisQuantumCipher/anubis-vault)
6//!
7//! **Guardian of Secrets - Protected by Quantum-Resistant Cryptography**
8//!
9//! Like Anubis, the ancient Egyptian guardian who protected the gates of the underworld and weighed
10//! the hearts of souls, **Anubis Vault** stands as the ultimate guardian of your digital secrets.
11//! No one—not even quantum computers or nation-state actors—can breach its defenses.
12//!
13//! ## Quick Start
14//!
15//! Add Anubis Vault to your `Cargo.toml`:
16//!
17//! ```toml
18//! [dependencies]
19//! anubis-vault = "0.1"
20//! ```
21//!
22//! ### Basic Usage
23//!
24//! ```rust,no_run
25//! use anubis_vault::{Vault, Secret};
26//!
27//! # fn main() -> anubis_vault::Result<()> {
28//! // Initialize a new vault
29//! let vault_path = "~/.anubis-vault";
30//! let master_password = "super-secret-password-123";
31//!
32//! // Create and initialize vault
33//! let mut vault = Vault::new(vault_path)?;
34//! vault.init(master_password)?;
35//!
36//! // Add a secret
37//! let secret = Secret::new("API_KEY", "my-secret-api-key");
38//! vault.add(secret)?;
39//!
40//! // Retrieve a secret
41//! let secret = vault.get("API_KEY")?;
42//! println!("API Key: {}", secret.reveal());
43//!
44//! // List all secrets
45//! let secrets = vault.list()?;
46//! for secret in secrets {
47//! println!("- {}", secret.name);
48//! }
49//! # Ok(())
50//! # }
51//! ```
52//!
53//! ## 5 Layers of Ultimate Security
54//!
55//! Anubis Vault provides **defense-in-depth security** with five independent layers:
56//!
57//! ### Layer 1: Classical Cryptography
58//!
59//! | Component | Algorithm | Parameters |
60//! |-----------|-----------|-----------|
61//! | **Encryption** | XChaCha20-Poly1305 | 256-bit key, 192-bit nonce, AEAD |
62//! | **Key Derivation** | Argon2id | 64 MiB memory, 3 iterations, p=4 |
63//! | **Key Exchange** | X25519 | Curve25519 ECDH |
64//! | **Signatures** | Ed25519 | EdDSA on Curve25519 |
65//! | **Hashing** | BLAKE3 | 256-bit output, Merkle trees |
66//!
67//! **Security Level:** 256-bit classical security
68//!
69//! ### Layer 2: Post-Quantum Cryptography
70//!
71//! | Component | Algorithm | Security Level |
72//! |-----------|-----------|---------------|
73//! | **Key Encapsulation** | ML-KEM-1024 | NIST Level 5 (256-bit quantum) |
74//! | **Digital Signatures** | ML-DSA-87 | NIST Level 5 (256-bit quantum) |
75//!
76//! **Security Level:** 256-bit quantum security (NIST FIPS 203/204)
77//!
78//! ### Layer 3: Zero-Knowledge Proofs
79//!
80//! - **Framework:** Plonky3 (ultra-fast STARKs)
81//! - **Performance:** 100x faster than Plonky2
82//! - **Use Case:** Privacy-preserving audit trails
83//!
84//! ### Layer 4: Shamir Secret Sharing
85//!
86//! - **Scheme:** M-of-N threshold recovery
87//! - **Security:** Information-theoretically secure
88//! - **Use Case:** Distributed backup and multi-party authentication
89//!
90//! ### Layer 5: Memory Protection
91//!
92//! - **Unix/Linux:** `mlock()` prevents swap to disk
93//! - **Windows:** `VirtualLock()` locks pages in memory
94//! - **All Platforms:** Automatic zeroization, core dumps disabled
95//!
96//! ## Features
97//!
98//! ### Core Cryptography
99//!
100//! - **Zero-knowledge encryption**: All secrets encrypted locally before storage
101//! - **Post-quantum ready**: ML-KEM-1024 and ML-DSA-87 (NIST standards)
102//! - **Hybrid encryption**: Combines classical and post-quantum algorithms
103//! - **Memory-hard KDF**: Argon2id with 64 MiB memory cost
104//! - **Authenticated encryption**: XChaCha20-Poly1305 prevents tampering
105//!
106//! ### Advanced Security
107//!
108//! - **Cryptographic audit logs**: Blockchain-like tamper-proof audit trail
109//! - **Threshold secret sharing**: Split secrets using Shamir's Secret Sharing
110//! - **Memory protection**: Physical RAM locking and automatic zeroization
111//! - **Zero-knowledge proofs**: Prove access without revealing secrets
112//!
113//! ### Developer Experience
114//!
115//! - **CI/CD integration**: Safely inject secrets into build pipelines
116//! - **CLI-first design**: Built for developer workflows and automation
117//! - **Multiple output formats**: JSON, plain text, clipboard
118//! - **Cross-platform**: macOS, Linux, Windows
119//!
120//! ## Security Model
121//!
122//! ### Protected Against
123//!
124//! - ✅ Brute-force attacks (Argon2id makes it computationally infeasible)
125//! - ✅ Quantum computer attacks (ML-KEM-1024, ML-DSA-87)
126//! - ✅ Memory dumps (mlock + zeroization)
127//! - ✅ Swap attacks (memory locking)
128//! - ✅ Core dumps (disabled via RLIMIT_CORE)
129//! - ✅ Timing attacks (constant-time operations)
130//! - ✅ Tampering (Poly1305 MAC + Ed25519 signatures)
131//! - ✅ Rainbow tables (unique salts per secret)
132//!
133//! ### Threat Model
134//!
135//! **Computational Security:**
136//!
137//! Breaking Anubis Vault would require:
138//! - **2^256 operations** to brute-force the master password (with 64 MiB RAM per attempt)
139//! - **2^256 quantum operations** against ML-KEM-1024
140//! - **Time to crack:** 3.67 × 10^59 years (assuming 1 trillion attempts per second)
141//!
142//! **Verdict:** Computationally infeasible to crack, even with future quantum computers.
143//!
144//! ### What This Library Does NOT Protect Against
145//!
146//! - Physical access to unlocked device (use full-disk encryption)
147//! - Keyloggers (use hardware security keys)
148//! - Compromised operating system (use secure boot)
149//!
150//! ## Architecture
151//!
152//! Anubis Vault is organized into several modules:
153//!
154//! - [`crypto`] - Cryptographic primitives (encryption, KDF, signatures, post-quantum)
155//! - [`vault`] - Vault storage, secret management, and audit logging
156//! - [`memory`] - Memory protection (locking and zeroization)
157//! - [`sharing`] - Shamir's Secret Sharing implementation
158//! - [`error`] - Error types and results
159//!
160//! ## Standards Compliance
161//!
162//! - ✅ **NIST FIPS 203** (ML-KEM-1024)
163//! - ✅ **NIST FIPS 204** (ML-DSA-87)
164//! - ✅ **RFC 7539** (ChaCha20-Poly1305)
165//! - ✅ **RFC 9106** (Argon2)
166//! - ✅ **RFC 7748** (Curve25519)
167//! - ✅ **OWASP** password hashing guidelines
168//!
169//! ## Performance
170//!
171//! | Operation | Time | Notes |
172//! |-----------|------|-------|
173//! | Init vault | ~500ms | Argon2id KDF (one-time) |
174//! | Add secret | ~100ms | Includes encryption + audit log |
175//! | Get secret | ~100ms | Includes decryption + verification |
176//! | List secrets | ~50ms | Metadata only (no decryption) |
177//!
178//! ## Examples
179//!
180//! ### Generate Random Secrets
181//!
182//! ```rust,no_run
183//! use anubis_vault::crypto::generate_secret;
184//!
185//! // Generate a 32-character random secret
186//! let secret = generate_secret(32, true); // true = include symbols
187//! println!("Generated: {}", secret);
188//! ```
189//!
190//! ### Shamir Secret Sharing
191//!
192//! ```rust,no_run
193//! use anubis_vault::sharing::{split_secret, recover_secret};
194//!
195//! # fn main() -> anubis_vault::Result<()> {
196//! let secret = b"super-secret-master-password";
197//!
198//! // Split into 5 shares, requiring 3 to recover
199//! let shares = split_secret(secret, 3, 5)?;
200//!
201//! // Recover from any 3 shares
202//! let recovered = recover_secret(&shares[0..3])?;
203//! assert_eq!(secret, &recovered[..]);
204//! # Ok(())
205//! # }
206//! ```
207//!
208//! ### Memory Protection
209//!
210//! ```rust,no_run
211//! use anubis_vault::memory::LockedMemory;
212//!
213//! # fn main() -> anubis_vault::Result<()> {
214//! // Create locked memory buffer for sensitive data
215//! let mut locked = LockedMemory::<32>::new()?;
216//!
217//! // Use the buffer
218//! locked.as_mut().copy_from_slice(b"secret-key-data-here-32-bytes!!");
219//!
220//! // Memory is automatically locked in RAM and zeroized on drop
221//! # Ok(())
222//! # }
223//! ```
224//!
225//! ## Related Projects
226//!
227//! Part of the **Anubis Quantum Cipher** security ecosystem:
228//!
229//! - [**Anubis Rage**](https://github.com/AnubisQuantumCipher/anubis-rage) - Post-quantum file encryption
230//! - [**Anubis Wormhole**](https://github.com/AnubisQuantumCipher/anubis-wormhole) - Quantum-secure file transfer
231//! - [**Quantum Sign**](https://github.com/AnubisQuantumCipher/quantum-sign) - Post-quantum digital signatures
232//!
233//! ## License
234//!
235//! Dual-licensed under **MIT OR Apache-2.0**.
236//!
237//! See [LICENSE-MIT](https://github.com/AnubisQuantumCipher/anubis-vault/blob/main/LICENSE-MIT)
238//! and [LICENSE-APACHE](https://github.com/AnubisQuantumCipher/anubis-vault/blob/main/LICENSE-APACHE)
239//! for details.
240//!
241//! ## Security
242//!
243//! For security vulnerabilities, please see
244//! [SECURITY.md](https://github.com/AnubisQuantumCipher/anubis-vault/blob/main/SECURITY.md)
245//! for responsible disclosure process.
246//!
247//! **Security Contact:** security@anubisquantumcipher.dev
248//!
249//! ---
250//!
251//! **"Like Anubis, the ancient guardian who protected the gates of the underworld and weighed
252//! the hearts of souls, Anubis Vault stands watch over your secrets, ensuring they remain
253//! hidden from all—even the gods themselves, even quantum computers of the future."**
254
255#![warn(
256 missing_docs,
257 rust_2018_idioms,
258 unused_qualifications,
259 missing_debug_implementations
260)]
261// Note: unsafe code is used in memory.rs for platform-specific memory locking (mlock/VirtualLock)
262// This is necessary for security and is carefully reviewed.
263
264pub mod crypto;
265pub mod error;
266pub mod vault;
267pub mod memory;
268pub mod sharing;
269pub mod zkp;
270
271// Re-export common types for convenience
272pub use error::{Error, Result};
273pub use vault::{Vault, Secret};
274
275/// Current vault format version
276pub const VAULT_VERSION: u32 = 1;
277
278/// Minimum supported vault format version
279pub const MIN_VAULT_VERSION: u32 = 1;
280
281/// Magic bytes identifying an Anubis Vault file - "ANBS" (Anubis)
282/// In hex: 41 4E 42 53
283pub const ANUBIS_MAGIC: [u8; 4] = *b"ANBS";
284
285/// The sacred seal - Anubis Quantum Cipher signature
286pub const ANUBIS_SIGNATURE: &str = "Guarded by Anubis - Quantum Cipher Division";
287
288/// Version string with Anubis branding
289pub const VERSION: &str = concat!(
290 "Anubis Vault v",
291 env!("CARGO_PKG_VERSION"),
292 " - Guardian of Secrets"
293);