1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! # keres
//!
//! Encrypted vaults and single-file encryption with strong, opt-in metadata
//! protection, built on AES-256-GCM and Argon2id.
//!
//! ## Highlights
//!
//! * **Authenticated encryption** — every byte of ciphertext is covered by a
//! GCM tag; headers are bound through key derivation and AAD.
//! * **Memory-hard key derivation** — Argon2id (64 MiB, t=4) with parameters
//! stored inside each container so they can evolve without breaking old
//! files.
//! * **Per-object subkeys** — HKDF-SHA256 derives an independent content key
//! per file; deterministic counter nonces eliminate random-nonce collision
//! risk on large files.
//! * **Streaming** — 64 KiB chunks with constant memory use for files of any
//! size.
//! * **Metadata privacy** — original filenames and directory structure never
//! appear unencrypted, neither in `.krs` containers nor inside vaults.
//! Opt-in size padding ([`padding::Padding`]) hides exact file sizes behind
//! buckets; by default sizes remain observable.
//! * **Crash safety** — configs, manifests and outputs are staged and
//! committed atomically. The vault index is an authenticated snapshot plus
//! an append-only log, with journaled compaction and rotation.
//! * **Hardened memory** — keys live in [`zeroize::Zeroizing`] buffers and
//! are scrubbed on drop.
//!
//! ## Quick start
//!
//! ```no_run
//! use std::path::Path;
//!
//! // Single file round trip.
//! let out = keres::encrypt_file("correct horse", Path::new("document.pdf"), None).unwrap();
//! let name = keres::decrypt_file("correct horse", &out, Path::new("restored.pdf")).unwrap();
//! assert_eq!(name, "document.pdf");
//!
//! // Multi-file vault.
//! let mut vault = keres::Vault::new("myvault".into());
//! vault.init("correct horse").unwrap();
//! vault.unlock("correct horse").unwrap();
//! vault.add(Path::new("secret.pdf"), None).unwrap();
//! for e in vault.list().unwrap() {
//! println!("{} ({} bytes)", e.name, e.size);
//! }
//! vault.lock();
//! ```
//!
//! ## Choosing an API
//!
//! * **One file in, one file out?** Use [`encrypt_file`] / [`decrypt_file`].
//! The container is self-contained: it carries the KDF parameters and the
//! original filename inside the encryption boundary.
//! * **Many files with one password?** Use [`Vault`]. Entries keep their
//! names encrypted, whole directory trees can be stored and restored, and
//! the password can be changed later without re-encrypting data.
//! * **Building blocks only?** The [`crypto`] module exposes the AEAD, key
//! type and derivation functions used internally.
//!
//! ## Error handling
//!
//! All fallible operations return [`Result`] with a small [`Error`] enum.
//! Wrong passwords and tampered ciphertext deliberately map to the same
//! [`Error::Authentication`] variant so error messages never leak which one
//! occurred:
//!
//!
//! ```
//! use keres::{decrypt_file, Error};
//! use std::path::Path;
//!
//! match decrypt_file("pw", Path::new("backup.krs"), Path::new("out.bin")) {
//! Ok(original_name) => println!("restored {original_name}"),
//! Err(Error::Authentication) => eprintln!("wrong password or corrupted data"),
//! Err(e) => eprintln!("failed: {e}"),
//! }
//! ```
//!
//! ## Security model
//!
//! See `SECURITY.md` in the repository for the full write-up including
//! threat model and known limitations. In short: confidentiality and
//! integrity against attackers with read/write access to the stored files,
//! as long as the password remains secret.
//!
//! The default (L1) hides names and directory structure but leaves entry
//! counts and exact sizes observable. Opt-in size padding raises this to
//! L2+ by bucketing file sizes; it does not hide access patterns or timing,
//! and Keres does not claim full metadata protection. It provides no
//! plausible deniability, and — as with all password-based encryption —
//! security ultimately rests on password strength.
/// Universal encrypted container format shared by all objects.
pub
/// Cryptographic primitives: keys, AEAD, KDF.
/// Error types.
/// Hidden entrance points for the fuzz targets in `fuzz/`.
/// Argon2id parameter types.
/// Opt-in size padding policies.
/// Entry-name validation helpers.
/// Single-file `.krs` containers.
/// Chunked streaming encryption engine.
/// Public `Read`/`Write` streaming adapters.
/// Deterministic containers that pin the wire format.
/// Multi-file encrypted vaults.
/// Convenience re-exports covering everyday use.
pub use ;
pub use Padding;
pub use ;
pub use ;
pub use ;
/// Crate version, handy for CLI `--version` output.
pub const VERSION: &str = env!;