crates/veilvoice-gui/src/security.rs
veilvoice-gui · 3258 lines · read the source here · or on GitHub
The application lock, and the at-rest encryption of what VeilVoice writes.
Two passwords, and why
There are two, deliberately:
- the app lock, which decides whether VeilVoice will open at all, and
- the recording passphrase, which encrypts the files it produces.
Collapsing them into one would mean that unlocking the app also unseals every recording it has ever written, which is the opposite of what a lock is for. veilvoice_crypto::lock additionally domain-separates its verifier, so even a user who types the same string in both places does not end up with two copies of one value.
What the lock is worth
Not much against an attacker with the disk, and the UI says so in veilvoice_crypto::lock::SCOPE, shown on the unlock screen itself rather than buried in an about page. It stops the person who picks up your unlocked laptop. It does not stop someone who takes the drive.
A limitation of typing a password into a window
A text field owns a String, so a passphrase exists as ordinary heap bytes while it is being typed. That window cannot be removed, because something has to receive the keystrokes, but it can be kept short, and it is:
- the typing buffer is wiped the moment the passphrase is confirmed;
- the confirmed passphrase is held only as a
veilvoice_crypto::Secret, page-locked and zeroized on drop, for the rest of the session; - locking the app, or changing the passphrase, wipes both.
It used to be kept as a plain String for the whole session, which was a much larger window for no benefit.
None of this defends against someone who can read this process's memory. If they can, they have already won, and docs/WHITEPAPER.md §7 says so rather than implying otherwise. What it does is stop a passphrase lingering in a heap allocation long after it was needed, where a core dump or a swapped page could pick it up.
In plain words
The lock on the window, and the encryption of the files VeilVoice writes.
There are two passphrases and they do different jobs. One opens the application. The other encrypts a recording, and it is asked for separately because they protect different things and losing one should not mean losing the other.
The panel says what the lock is worth and what it is not: it stops somebody who picks up your unlocked computer, and it does not stop somebody who has the disk. Encrypting the recording is what protects the recording.
WHAT THIS FILE CONTAINS
3258 lines defining 54 functions (29 public), 4 types and 5 constants. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
enum Sealingline 82 · How the recording that comes out of a job is protected.enum Opline 107 · What a background lock operation was trying to do.struct Securityline 142 · Everything about locking the app and sealing its output.enum Planline 1723 · What a finished job should do with its bytes.
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.
Security::loadline 325 · Read the lock file for this machine and start locked if one is set.
reachesdefaultSecurity::take_unlock_passphraseline 368 · Take the passphrase that just opened the lock, once.Security::take_unlock_store_keyline 377 · Collect the obfuscated store's key from the unlock that just happened.Security::prefer_app_lock_sealingline 398 · Start in Sealing::AppLock, because the user asked for that last time.
reachesapply_preferred_sealingSecurity::app_lock_sealing_is_waitingline 426 · Whether the stored preference is still waiting for a lock to apply to.Security::seals_with_app_lockline 432 · Whether the app-lock sealing mode is currently chosen, so the window can have the choice remembered.Security::tamperedline 440 · Whether the lock reported having been interfered with.Security::is_lockedline 445 · Whether the unlock screen should be shown instead of the app.Security::set_lock_from_setupline 455 · Whether a lock is configured at all.
reachesspawn,run_op,decoy_store,reopenSecurity::has_recording_passphraseline 462 · Whether a recording passphrase is held for this session.Security::set_recording_passphraseline 471 · Take a recording passphrase from the first-run setup.
reachesinto_secretSecurity::lock_after_idleline 499 · Lock because nobody has touched the window for a while.
reacheslock_inner,wipe_secretsSecurity::blocked_reasonline 563 · Why a job cannot start yet, for the button's tooltip.
reachesready_to_writeSecurity::planline 581 · How the next job should protect its output.Security::opened_with_decoyline 793 · Whether this session was opened with the decoy passphrase.Security::decoy_can_be_setline 802 · Whether a decoy could be set on this machine.
reacheshas_lockSecurity::is_busyline 844 · Whether a lock operation is running, so the window keeps repainting and the indicator beside the field keeps moving.
reachesbusySecurity::unlock_screenline 849 · The full-window unlock screen.
reachesbegin_unlock,busy,poll,unlock_row,spawn,apply_preferred_sealing,finish_unlock,refresh_decoy_state,wipe_form,run_op,into_secret,decoy_storeSecurity::tabline 1054 · The security tab: manage the lock, and see what it is worth.
reachesbusy,button_column,decoy_panel,has_lock,interference_banner,lock_now,password_row,poll,spawn,refresh_decoy_state,lock_inner,apply_preferred_sealingSecurity::load_mandateline 1374 · Read the baseline from disk and apply it to the checkbox.Security::mandate_requires_app_lockline 1389 · Whether the baseline insists on the app lock.Security::mandate_requires_encryptionline 1394 · Whether the baseline insists on encryption at rest.Security::mandate_historyline 1399 · The change log, for the panel that shows it.Security::recording_controlsline 1422 · The at-rest controls that sit inside the file tab.
reachesinto_secret,mandate_history_panel,password_row,record,mandate_history_rowsSecurity::disable_dialogueline 1642 · The dialogue shown when the user turns at-rest encryption off.
reachesrecordPlan::writeline 1748 · Seal wav if the plan says to, and write it.
WHAT CALLS WHAT
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. 22 of 54 functions are drawn; the diagram is bounded at 22 so it stays readable.
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_into_secret["into_secret<br/>line 73"]
n_default["Security::default<br/>line 275"]
n_drop["Security::drop<br/>line 318"]
n_load(["Security::load<br/>line 325"])
n_prefer_app_lock_sealing(["Security::<br/>prefer_app_lock_sealing<br/>line 398"])
n_apply_preferred_sealing["Security::<br/>apply_preferred_sealing<br/>line 413"]
n_set_lock_from_setup(["Security::set_lock_from_setup<br/>line 455"])
n_set_recording_passphrase(["Security::<br/>set_recording_passphrase<br/>line 471"])
n_has_lock["Security::has_lock<br/>line 480"]
n_lock_now["Security::lock_now<br/>line 489"]
n_lock_after_idle(["Security::lock_after_idle<br/>line 499"])
n_lock_inner["Security::lock_inner<br/>line 508"]
n_wipe_secrets["Security::wipe_secrets<br/>line 517"]
n_ready_to_write["Security::ready_to_write<br/>line 551"]
n_blocked_reason(["Security::blocked_reason<br/>line 563"])
n_spawn["Security::spawn<br/>line 613"]
n_decoy_can_be_set(["Security::decoy_can_be_set<br/>line 802"])
n_is_busy(["Security::is_busy<br/>line 844"])
n_unlock_screen(["Security::unlock_screen<br/>line 849"])
n_tab(["Security::tab<br/>line 1054"])
n_recording_controls(["Security::recording_controls<br/>line 1422"])
n_disable_dialogue(["Security::disable_dialogue<br/>line 1642"])
n_blocked_reason --> n_ready_to_write
n_decoy_can_be_set --> n_has_lock
n_drop --> n_wipe_secrets
n_load --> n_default
n_lock_after_idle --> n_lock_inner
n_lock_inner --> n_wipe_secrets
n_lock_now --> n_lock_inner
n_prefer_app_lock_sealing --> n_apply_preferred_sealing
n_recording_controls --> n_into_secret
n_set_lock_from_setup --> n_spawn
n_set_recording_passphrase --> n_into_secret
n_tab --> n_has_lock
n_tab --> n_lock_now
n_tab --> n_spawn
click n_into_secret href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L73" "open the source"
click n_default href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L275" "open the source"
click n_drop href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L318" "open the source"
click n_load href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L325" "open the source"
click n_prefer_app_lock_sealing href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L398" "open the source"
click n_apply_preferred_sealing href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L413" "open the source"
click n_set_lock_from_setup href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L455" "open the source"
click n_set_recording_passphrase href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L471" "open the source"
click n_has_lock href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L480" "open the source"
click n_lock_now href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L489" "open the source"
click n_lock_after_idle href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L499" "open the source"
click n_lock_inner href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L508" "open the source"
click n_wipe_secrets href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L517" "open the source"
click n_ready_to_write href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L551" "open the source"
click n_blocked_reason href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L563" "open the source"
click n_spawn href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L613" "open the source"
click n_decoy_can_be_set href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L802" "open the source"
click n_is_busy href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L844" "open the source"
click n_unlock_screen href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L849" "open the source"
click n_tab href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L1054" "open the source"
click n_recording_controls href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L1422" "open the source"
click n_disable_dialogue href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/security.rs#L1642" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_load,n_prefer_app_lock_sealing,n_set_lock_from_setup,n_set_recording_passphrase,n_lock_after_idle,n_blocked_reason,n_decoy_can_be_set,n_is_busy,n_unlock_screen,n_tab,n_recording_controls,n_disable_dialogue entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_has_lock,n_lock_now,n_ready_to_write api
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_into_secret,n_default,n_drop,n_apply_preferred_sealing,n_lock_inner,n_wipe_secrets,n_spawn helper
subgraph chart_key ["Key"]
direction LR
key_entry["entry: a way in: public, and nothing in this file calls it"]
key_api["api: public, and also used inside this file"]
key_helper["helper: private to this file"]
end
class key_entry entry
class key_api api
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
| Item | Line | Documentation |
|---|---|---|
into_secret fn | 73 | Move a typed passphrase out of its String and into page-locked storage, wiping the buffer it came from. |
Sealing pub enum | 82 | How the recording that comes out of a job is protected. |
Op enum | 107 | What a background lock operation was trying to do. |
OpResult type | 130 | A finished lock operation: the store as it now stands, and how it went. |
Security pub struct | 142 | Everything about locking the app and sealing its output. |
Security::default fn | 275 | The safe state, and deliberately free of I/O so tests and VeilVoiceApp::default() never touch the real lock file. |
Security::drop fn | 318 | |
Security::load pub fn | 325 | Read the lock file for this machine and start locked if one is set. |
Security::take_unlock_passphrase pub fn | 368 | Take the passphrase that just opened the lock, once. |
Security::take_unlock_store_key pub fn | 377 | Collect the obfuscated store's key from the unlock that just happened. |
Security::prefer_app_lock_sealing pub fn | 398 | Start in Sealing::AppLock, because the user asked for that last time. |
Security::apply_preferred_sealing fn | 413 | Turn the remembered preference into the sealing mode, once. |
Security::app_lock_sealing_is_waiting pub fn | 426 | Whether the stored preference is still waiting for a lock to apply to. |
Security::seals_with_app_lock pub fn | 432 | Whether the app-lock sealing mode is currently chosen, so the window can have the choice remembered. |
Security::tampered pub fn | 440 | Whether the lock reported having been interfered with. |
Security::is_locked pub fn | 445 | Whether the unlock screen should be shown instead of the app. |
Security::set_lock_from_setup pub fn | 455 | Whether a lock is configured at all. |
Security::has_recording_passphrase pub fn | 462 | Whether a recording passphrase is held for this session. |
Security::set_recording_passphrase pub fn | 471 | Take a recording passphrase from the first-run setup. |
Security::has_lock pub fn | 480 | Whether an app lock is configured on this machine. |
Security::lock_now pub fn | 489 | Lock the app now, wiping the session passphrase with it. |
Security::lock_after_idle pub fn | 499 | Lock because nobody has touched the window for a while. |
Security::lock_inner fn | 508 | Lock, remembering whether the person did it or the idle timer did. |
Security::wipe_secrets fn | 517 | Wipe every plaintext secret this struct is holding. |
Security::ready_to_write pub fn | 551 | Whether a job may start: either encryption is off, or there is something to encrypt with. |
Security::blocked_reason pub fn | 563 | Why a job cannot start yet, for the button's tooltip. |
Security::plan pub fn | 581 | How the next job should protect its output. |
Security::spawn fn | 613 | Run a lock operation on a thread, so the window keeps drawing. |
Security::begin_unlock fn | 638 | Check what was typed into the unlock field, on a worker. |
Security::poll fn | 643 | Collect a finished lock operation. |
Security::finish_unlock fn | 758 | Open the window after an unlock, with the decoy taken into account. |
Security::opened_with_decoy pub fn | 793 | Whether this session was opened with the decoy passphrase. |
Security::decoy_can_be_set pub fn | 802 | Whether a decoy could be set on this machine. |
Security::refresh_decoy_state fn | 813 | Read what is on disk, once, so the tab does not open a file per frame. |
Security::wipe_form fn | 827 | Clear what was typed, so a passphrase does not sit in a field after use. |
Security::busy fn | 838 | Whether an operation is in flight, so the panel can refuse a second one. |
Security::is_busy pub fn | 844 | Whether a lock operation is running, so the window keeps repainting and the indicator beside the field keeps moving. |
Security::unlock_screen pub fn | 849 | The full-window unlock screen. |
Security::interference_banner fn | 998 | The standing report that the lock file was interfered with. |
Security::tab pub fn | 1054 | The security tab: manage the lock, and see what it is worth. |
Security::decoy_panel fn | 1244 | The decoy passphrase, set, changed and removed from the window. |
Security::load_mandate pub fn | 1374 | Read the baseline from disk and apply it to the checkbox. |
Security::mandate_requires_app_lock pub fn | 1389 | Whether the baseline insists on the app lock. |
Security::mandate_requires_encryption pub fn | 1394 | Whether the baseline insists on encryption at rest. |
Security::mandate_history pub fn | 1399 | The change log, for the panel that shows it. |
Security::record fn | 1409 | Record a change to the baseline, and write it down. |
Security::recording_controls pub fn | 1422 | The at-rest controls that sit inside the file tab. |
Security::mandate_history_panel fn | 1612 | The log of every time a requirement was turned off or back on. |
Security::mandate_history_rows fn | 1631 | One coloured line per change, newest concern last: green for a requirement put back, yellow for one turned off. |
Security::disable_dialogue pub fn | 1642 | The dialogue shown when the user turns at-rest encryption off. |
KEEP_ENCRYPTED pub const | 1698 | The two answers to that question, as data. |
WRITE_UNENCRYPTED pub const | 1701 | The other answer. |
DISABLE_WARNING pub const | 1707 | What the user is told before recordings stop being encrypted. |
Plan pub enum | 1723 | What a finished job should do with its bytes. |
Plan::write pub fn | 1748 | Seal wav if the plan says to, and write it. |
Plan::fmt fn | 1795 | |
decoy_store fn | 1809 | The decoy store that sits beside the lock file at path. |
run_op fn | 1816 | Run one lock operation, off the UI thread. |
reopen fn | 1935 | Re-open the lock store from disk, or None when there is nothing to open. |
PASSWORD_LABEL_WIDTH const | 1942 | The width every passphrase label is given, so every field starts level. |
PASSWORD_FIELD_WIDTH const | 1947 | How wide every passphrase field is drawn, on this tab and on the lock screen. |
button_column fn | 1981 | One labelled passphrase field, with the field in the same place every time. |
password_row fn | 1996 | One passphrase field with its label, at the shared width. |
unlock_row fn | 2041 | The password row on the lock screen: the label, the field and the button. |