vault_store.rs

crates/veilvoice-gui/src/vault_store.rs

veilvoice-gui · 945 lines · read the source here · or on GitHub

Where the desktop application keeps its own files, and what the app lock buys for them.

The short version, and it is the honest one

With an app lock set, the records listed in records::ALL live in veilvoice_crypto::hoard: encrypted, padded to a few fixed sizes, under filenames derived from the lock passphrase, with decoy files sown among them. Today that is one record, the measurements file, and nothing writes it yet. The settings and the integrity record are still written in the open, owner-only, under their own names, and the lock card says so.

With no app lock, none of that is possible and none of it is claimed. There is no passphrase, so there is no key, so there is nothing to derive a name from or encrypt with. The files sit in the open under their own names, exactly as they did before this module existed, and the security tab says so in those words.

That is the bargain this module is built for, and the answer it was written to give to a fair question about the app lock: what is it actually for, if it is only a password prompt on a window whose files anybody can read? It can only give that answer for the records that have moved in, so until the settings and the integrity record do, the honest answer is still "mostly the window".

What it still does not buy

Repeated here rather than left in the crypto crate, because this is the module the application calls and the place somebody looks:

  • It does not hide that VeilVoice is installed. The folder is named veilvoice and the lock file is in it under its own name -- it has to be, since it is what checks the passphrase.
  • It does not stop anybody deleting the folder.
  • It is no protection at all while the application is open and unlocked.
  • Anybody who has the passphrase has everything.

Moving in, and the risk that comes with it

The first unlock after a lock is set migrates the existing plain files in: each is read, written as a hoard record, and the original securely erased.

This is the moment to be plain about a consequence that is easy to under-state. Once the files are in the hoard, the passphrase is the only way back to them. Losing it does not lock you out of a window whose files you could still read by hand; it loses the settings, the integrity record and the policies for good. veilvoice_crypto::lock keeps a second copy of the lock for exactly this reason, and the setup screen says the sentence out loud rather than burying it.

WHAT THIS FILE CONTAINS

945 lines defining 15 functions (13 public), 3 types and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.

The types it owns.

  • enum Plain line 140 · Whether an unlock moves the plain records in, or leaves them alone.
  • struct VaultStore line 156 · The application's own storage, locked or not.
  • struct Measured line 796 · What the application measured about its own running, kept between sessions.

What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.

  • VaultStore::new line 174 · Point at the program folder.
  • VaultStore::dir line 183 · The program folder, if this platform has one.
  • VaultStore::is_obfuscated line 192 · Whether records are currently obfuscated.
  • VaultStore::start_unlocking line 207 · Take the key from an unlock and start opening the hoard with it.
    reaches open_with
  • VaultStore::is_opening line 226 · Whether an unlock is still being carried out.
  • VaultStore::poll line 234 · Collect a finished unlock, installing the key.
  • VaultStore::unlocked line 266 · Open the hoard here and now, for tests only.
    reaches open_with
  • VaultStore::locked line 283 · Forget the key.
  • VaultStore::read line 290 · Read a record, from the hoard if it is open and from the plain file if it is not.
    reaches plain_path
  • VaultStore::write line 305 · Write a record, obfuscated if there is a key and plain if there is not.
    reaches plain_path
  • Measured::load line 813 · Read it back, or the defaults if nothing has been recorded.
  • Measured::save line 836 · Write it, obfuscated when there is a key and plain when there is not.
  • Measured::record line 850 · Fold this session's numbers in.

WHAT CALLS WHAT

VaultStore::new line 174 VaultStore::dir line 183 VaultStore::is_obfuscated line 192 VaultStore::start_unlocking line 207 VaultStore::is_opening line 226 VaultStore::poll line 234 VaultStore::unlocked line 266 VaultStore::locked line 283 VaultStore::read line 290 VaultStore::write line 305 VaultStore::plain_path line 320 open_with line 359 Measured::load line 813 Measured::save line 836 Measured::record line 850 entry: a way in: public, and nothing in this file calls it helper: private to this file dashed: a call that goes back up, or across a wrapped rank The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
    n_new(["VaultStore::new<br/>line 174"])
    n_dir(["VaultStore::dir<br/>line 183"])
    n_is_obfuscated(["VaultStore::is_obfuscated<br/>line 192"])
    n_start_unlocking(["VaultStore::start_unlocking<br/>line 207"])
    n_is_opening(["VaultStore::is_opening<br/>line 226"])
    n_poll(["VaultStore::poll<br/>line 234"])
    n_unlocked(["VaultStore::unlocked<br/>line 266"])
    n_locked(["VaultStore::locked<br/>line 283"])
    n_read(["VaultStore::read<br/>line 290"])
    n_write(["VaultStore::write<br/>line 305"])
    n_plain_path["VaultStore::plain_path<br/>line 320"]
    n_open_with["open_with<br/>line 359"]
    n_load(["Measured::load<br/>line 813"])
    n_save(["Measured::save<br/>line 836"])
    n_record(["Measured::record<br/>line 850"])
    n_read --> n_plain_path
    n_start_unlocking --> n_open_with
    n_unlocked --> n_open_with
    n_write --> n_plain_path
    click n_new href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L174" "open the source"
    click n_dir href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L183" "open the source"
    click n_is_obfuscated href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L192" "open the source"
    click n_start_unlocking href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L207" "open the source"
    click n_is_opening href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L226" "open the source"
    click n_poll href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L234" "open the source"
    click n_unlocked href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L266" "open the source"
    click n_locked href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L283" "open the source"
    click n_read href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L290" "open the source"
    click n_write href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L305" "open the source"
    click n_plain_path href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L320" "open the source"
    click n_open_with href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L359" "open the source"
    click n_load href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L813" "open the source"
    click n_save href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L836" "open the source"
    click n_record href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/vault_store.rs#L850" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_new,n_dir,n_is_obfuscated,n_start_unlocking,n_is_opening,n_poll,n_unlocked,n_locked,n_read,n_write,n_load,n_save,n_record entry
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_plain_path,n_open_with helper
    subgraph chart_key ["Key"]
        direction LR
        key_entry["entry: a way in: public, and nothing in this file calls it"]
        key_helper["helper: private to this file"]
    end
    class key_entry entry
    class key_helper helper

This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.

ITEMS

ItemLineDocumentation
records pub mod87The logical names of every record the application keeps.
DECOYS const122How many decoys a folder is kept stocked with.
Plain pub enum140Whether an unlock moves the plain records in, or leaves them alone.
VaultStore pub struct156The application's own storage, locked or not.
VaultStore::new pub fn174Point at the program folder.
VaultStore::dir pub fn183The program folder, if this platform has one.
VaultStore::is_obfuscated pub fn192Whether records are currently obfuscated.
VaultStore::start_unlocking pub fn207Take the key from an unlock and start opening the hoard with it.
VaultStore::is_opening pub fn226Whether an unlock is still being carried out.
VaultStore::poll pub fn234Collect a finished unlock, installing the key.
VaultStore::unlocked pub fn266Open the hoard here and now, for tests only.
VaultStore::locked pub fn283Forget the key.
VaultStore::read pub fn290Read a record, from the hoard if it is open and from the plain file if it is not.
VaultStore::write pub fn305Write a record, obfuscated if there is a key and plain if there is not.
VaultStore::plain_path fn320Where a record sits when nothing is obfuscating it.
open_with fn359Open the hoard in dir with key, migrating and auditing.
Measured pub struct796What the application measured about its own running, kept between sessions.
Measured::load pub fn813Read it back, or the defaults if nothing has been recorded.
Measured::save pub fn836Write it, obfuscated when there is a key and plain when there is not.
Measured::record pub fn850Fold this session's numbers in.
measured_tests mod861