[core] Vault file v1 and generators (v0.1.0) #1

Manually merged
mnovak merged 0 commits from feature/core into main 2026-10-31 10:14:17 +01:00
Owner

The public core of Custos Domi, v0.1.0: the vault file and the generators.

What

  • docs/FORMAT.md (written first): header CUSTOS v1, 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).
  • Default KDF: 64 MiB, 20 passes, 1 lane = 0.75 s per unlock on the dev machine (measured with
    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 .bak always open), crash on
    first 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 title
    drops {Name} and its separator, 10,000 strict-site samples never violate the template, no repeats in
    10,000 memorable/random/strict samples, generated values redacted in Debug.
  • doctest: 1 passed. Total 25 passed, 0 failed.

Self-review

What an attacker with the file can do:

  • Guess passwords offline at one Argon2id(64 MiB, t=20) per guess. A memorable master password (~65 bits)
    holds; a weak one does not. Nothing else in the file helps them: titles, URLs and usernames are encrypted.
  • See the KDF parameters, the number of key slots and the approximate size of the vault.
  • Destroy the file, or replace it with an older copy (rollback is not detected; documented).
  • Not: change, add, drop or reorder anything unnoticed — the header is the body's AAD and each slot's
    parameters are the wrap's AAD (the bit-flip test covers every byte).
  • Not: make the reader allocate huge memory with a crafted header — limits are checked first (tested).

What I did not verify:

  • No independent cryptographic review, and no fuzzing of the header parser (only the exhaustive single-byte flips).
  • Zeroization is best-effort: serde_json and Vec growth can leave copies; to_bytes serializes from
    borrowed items to avoid one clone of every secret. Documented in the threat model.
  • clippy is not installed for this toolchain and was not run (installing it writes to C:, which is off limits
    on this machine). rustfmt was run.
  • On Windows the final rename relies on std::fs::rename (replace-existing); the folder is not fsynced there.
  • Not tested on Linux or macOS.
  • Nickname word lists were written by hand for this project (CC0); their size (294 nouns) makes nicknames
    ~15 bits — fine for a name, not a secret.

yo-yo in the EFF list becomes yoyos because the list already has yoyo and the generator removes hyphens;
documented in wordlists/SOURCES.md.

The public core of Custos Domi, v0.1.0: the vault file and the generators. ## What - `docs/FORMAT.md` (written first): header `CUSTOS` v1, 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). - Default KDF: 64 MiB, 20 passes, 1 lane = 0.75 s per unlock on the dev machine (measured with `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 `.bak` always open), crash on first 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 title drops `{Name}` and its separator, 10,000 strict-site samples never violate the template, no repeats in 10,000 memorable/random/strict samples, generated values redacted in `Debug`. - doctest: 1 passed. Total **25 passed, 0 failed**. ## Self-review **What an attacker with the file can do:** - Guess passwords offline at one Argon2id(64 MiB, t=20) per guess. A memorable master password (~65 bits) holds; a weak one does not. Nothing else in the file helps them: titles, URLs and usernames are encrypted. - See the KDF parameters, the number of key slots and the approximate size of the vault. - Destroy the file, or replace it with an older copy (rollback is not detected; documented). - Not: change, add, drop or reorder anything unnoticed — the header is the body's AAD and each slot's parameters are the wrap's AAD (the bit-flip test covers every byte). - Not: make the reader allocate huge memory with a crafted header — limits are checked first (tested). **What I did not verify:** - No independent cryptographic review, and no fuzzing of the header parser (only the exhaustive single-byte flips). - Zeroization is best-effort: `serde_json` and `Vec` growth can leave copies; `to_bytes` serializes from borrowed items to avoid one clone of every secret. Documented in the threat model. - `clippy` is not installed for this toolchain and was not run (installing it writes to C:, which is off limits on this machine). `rustfmt` was run. - On Windows the final rename relies on `std::fs::rename` (replace-existing); the folder is not fsynced there. - Not tested on Linux or macOS. - Nickname word lists were written by hand for this project (CC0); their size (294 nouns) makes nicknames ~15 bits — fine for a name, not a secret. `yo-yo` in the EFF list becomes `yoyos` because the list already has `yoyo` and the generator removes hyphens; documented in `wordlists/SOURCES.md`.
mnovak added 4 commits 2026-10-31 10:13:39 +01:00
mnovak manually merged commit fac0184e46 into main 2026-10-31 10:14:17 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#1