[core] Vault file v1 and generators (v0.1.0) #1
Reference in New Issue
Block a user
Delete Branch "feature/core"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The public core of Custos Domi, v0.1.0: the vault file and the generators.
What
docs/FORMAT.md(written first): headerCUSTOSv1, key slots, Argon2id → KEK → wrapped 256-bit vault key,body = XChaCha20-Poly1305 over JSON with the whole header as AAD, limits checked before Argon2 runs,
atomic save, the item templates, and the planned KDBX 4 / KeePassXC field mapping.
docs/THREAT_MODEL.md: what the file protects against, and a plain list of what it does not.custos-vault:Vault::{create, open, to_bytes, save, change_password},save_atomic(tmp + fsync +rename, previous version kept as
.bak), typed items for the six templates with password history,SecretString(zeroized, prints[redacted]).custos-gen: memorable password (EFF large list, 3–10 words, digit per word, capitals, 7 separators),nickname from a template (
{Name}.{Word}.{Number}, diacritics stripped, leetspeak toggle), random,PIN, strict site (required/allowed/excluded classes, rejection sampling). Entropy is computed from the
template, counting only random choices (strict: exact count by inclusion–exclusion).
examples/kdf_timing.rs; 3 passes was only 0.10 s).Tests (all written before the code,
cargo test --workspace --release)custos-vault: 10 passed — round-trip (memory and file), fresh nonce per save, wrong password(clear error, no data, no password in the message), every byte of the file flipped with 0x01 and 0x80
(2 × ~1,100 opens, all refused) plus truncation and extension, tampered KDF parameters refused before
Argon2, wrong magic/version, crash at 4 points during save (original and
.bakalways open), crash onfirst save, password change (old fails, new works, same items, same vault key), no secret in
Debug/Display.custos-gen: 14 passed — EFF list complete and plain, memorable shape for every slider value ×separator × digit × capital option, entropy = words × (log2 7776 + log2 10), nickname template incl.
Česká spořitelna→^CeskaSporitelna\.[A-Z][a-z]+\.[0-9]{2}$, word from the chosen kinds, empty titledrops
{Name}and its separator, 10,000 strict-site samples never violate the template, no repeats in10,000 memorable/random/strict samples, generated values redacted in
Debug.Self-review
What an attacker with the file can do:
holds; a weak one does not. Nothing else in the file helps them: titles, URLs and usernames are encrypted.
parameters are the wrap's AAD (the bit-flip test covers every byte).
What I did not verify:
serde_jsonandVecgrowth can leave copies;to_bytesserializes fromborrowed items to avoid one clone of every secret. Documented in the threat model.
clippyis not installed for this toolchain and was not run (installing it writes to C:, which is off limitson this machine).
rustfmtwas run.std::fs::rename(replace-existing); the folder is not fsynced there.~15 bits — fine for a name, not a secret.
yo-yoin the EFF list becomesyoyosbecause the list already hasyoyoand the generator removes hyphens;documented in
wordlists/SOURCES.md.