decoy.rs

crates/veilvoice-crypto/src/decoy.rs

veilvoice-crypto · 1097 lines · read the source here · or on GitHub

A second passphrase that opens a different, empty VeilVoice.

What this is for, and what it is honestly worth

Somebody can be made to unlock a program. A decoy passphrase gives them something true to say: it opens VeilVoice, the application works, and there is nothing in it.

It does not give you deniability, and anyone who tells you otherwise is selling something. VeilVoice is open source. This file is published. An adversary who knows what they are looking at knows the feature exists, can read exactly how it works, and can simply ask for the other passphrase. What a decoy buys is a way to comply without revealing; what it does not buy is any argument that there is nothing more to reveal. SCOPE says that in the words a front end must show, and it is the most important thing this crate produces.

The destructive duress passphrase is deliberately not here

The roadmap asked for two things: a decoy, and a duress passphrase that destroys data. The second is not shipped, and WHY_NO_DESTRUCTION is the reason in full. In short: VeilVoice cannot promise a file is gone.

On flash storage a write does not overwrite. The controller maps a logical block to a new physical page and leaves the old one holding the data until it is garbage-collected, which may be minutes or may be never, and no program running as an ordinary user can reach it. This project already documents that about its own secure-erase feature and refuses to overstate it there.

A destructive duress passphrase would be believed in exactly the situation where being wrong costs the most. Somebody types it expecting the recordings to be gone; the ciphertext is still in unmapped pages; and they then behave as though it is not. A control people rely on and that does not work is worse than no control at all. So there is not one.

Typing the wrong one by mistake

The other failure the roadmap named, and the reason this shape was chosen. Because the decoy destroys nothing, typing it by accident costs a relaunch and nothing else. There is no state to recover and no decision that cannot be taken back. That is not a happy accident; it is why the destructive design was rejected rather than made safer.

Both passphrases are checked the same way

Which one matched must not be visible in how long the check took. Both are derived with the same Argon2id parameters and compared in constant time, and both are always derived, in every branch: see Store::judge, which is the one place an unlock goes through. Returning as soon as one matched would make that answer measurably faster than the other, and tell an observer with a stopwatch which of the two they had just watched somebody type.

The same applies to having one at all. A copy with no decoy set derives against a record that nothing opens, so the time an unlock takes does not answer "is there a decoy on this machine".

Where it is kept, and what holds the real passphrase

Store keeps one file beside the app lock, under a name derived from the vault's index like the lock's own two copies, so a folder listing does not say which file it is. What is in it is the decoy's verifier and nothing else.

The real passphrase is not in it. It lives in the app lock, once, and setting or removing a decoy proves it against that. A second copy of it here would be two places that have to agree about the same secret with no way for either to notice the other had changed, which is the shape of F-141.

A decoy is not a failed attempt at the real passphrase either. Typing it leaves the failure count alone, so using this feature does not start a cooldown. A cooldown already in force is a different matter: it refuses the decoy exactly as it refuses everything else, because a passphrase that still worked during the wait would be announcing itself as the decoy.

In plain words

You can set a second passphrase, from Settings or with veilvoice decoy set. Typing it opens VeilVoice normally, except that it is empty: no recordings, no projects, no history. It is there for the situation where somebody is standing over you asking you to unlock your computer.

It has to be properly different from your real one, and VeilVoice refuses a pair that is nearly the same. Setting or removing it asks for your real passphrase first, so nobody can do either behind your back at a window you left unlocked.

Two honest warnings, and please read them.

It does not hide the fact that a second passphrase might exist. This program's source code is public and this feature is described in it, so anybody who recognises VeilVoice can ask you for the other one. It buys you a way to hand something over. It does not buy you an argument.

And there is no passphrase that destroys your recordings, deliberately. On modern storage, deleting a file does not reliably remove it, so a feature that claimed to would be lying to you at the worst possible moment.

WHAT THIS FILE CONTAINS

1097 lines defining 17 functions (9 public), 6 types and 6 constants. Everything below is read out of the source, so it cannot disagree with the code.

The types it owns.

  • enum Opened line 103 · Which passphrase was given.
  • struct Verifier line 114 · One passphrase's stored form.
  • enum Refused line 164 · Why a pair was refused.
  • struct Decoy line 248 · A decoy passphrase's stored form, on its own.
  • enum State line 397 · Whether this machine has a decoy passphrase, and whether it can be read.
  • struct Store line 417 · The decoy passphrase as this machine keeps it.

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.

  • Decoy::to_bytes line 323 · The record, for writing: its fields, then random bytes up to the app lock's own length.
  • Decoy::parse line 351 · Read a record.
  • Store::here line 433 · The store for this copy of VeilVoice.
    reaches at
  • Store::state line 439 · Whether a decoy is set, and whether it reads.
  • Store::set line 457 · Set or replace the decoy passphrase.
    reaches create, prove
  • Store::remove line 475 · Remove the decoy passphrase, after proving the real one.
    reaches prove
  • Store::judge line 540 · Which passphrase was typed.
    reaches nothing

WHAT CALLS WHAT

Verifier::create line 127 Verifier::matches line 137 constant_time_eq line 144 Refused::fmt line 185 differences line 223 Decoy::create line 273 Decoy::nothing line 300 Decoy::matches line 313 Decoy::to_bytes line 323 Decoy::parse line 351 Store::at line 426 Store::here line 433 Store::state line 439 Store::set line 457 Store::remove line 475 Store::prove line 492 Store::judge line 540 entry: a way in: public, and nothing in this file calls it api: public, and also used inside this file 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_create["Verifier::create<br/>line 127"]
    n_matches["Verifier::matches<br/>line 137"]
    n_constant_time_eq["constant_time_eq<br/>line 144"]
    n_fmt["Refused::fmt<br/>line 185"]
    n_differences["differences<br/>line 223"]
    n_create["Decoy::create<br/>line 273"]
    n_nothing["Decoy::nothing<br/>line 300"]
    n_matches["Decoy::matches<br/>line 313"]
    n_to_bytes(["Decoy::to_bytes<br/>line 323"])
    n_parse(["Decoy::parse<br/>line 351"])
    n_at["Store::at<br/>line 426"]
    n_here(["Store::here<br/>line 433"])
    n_state(["Store::state<br/>line 439"])
    n_set(["Store::set<br/>line 457"])
    n_remove(["Store::remove<br/>line 475"])
    n_prove["Store::prove<br/>line 492"]
    n_judge(["Store::judge<br/>line 540"])
    n_here --> n_at
    n_judge --> n_nothing
    n_matches --> n_constant_time_eq
    n_remove --> n_prove
    n_set --> n_create
    n_set --> n_prove
    click n_create href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L127" "open the source"
    click n_matches href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L137" "open the source"
    click n_constant_time_eq href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L144" "open the source"
    click n_fmt href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L185" "open the source"
    click n_differences href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L223" "open the source"
    click n_create href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L273" "open the source"
    click n_nothing href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L300" "open the source"
    click n_matches href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L313" "open the source"
    click n_to_bytes href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L323" "open the source"
    click n_parse href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L351" "open the source"
    click n_at href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L426" "open the source"
    click n_here href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L433" "open the source"
    click n_state href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L439" "open the source"
    click n_set href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L457" "open the source"
    click n_remove href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L475" "open the source"
    click n_prove href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L492" "open the source"
    click n_judge href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/decoy.rs#L540" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_to_bytes,n_parse,n_here,n_state,n_set,n_remove,n_judge entry
    classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
    class n_create,n_at api
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_create,n_matches,n_constant_time_eq,n_fmt,n_differences,n_nothing,n_matches,n_prove 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

ItemLineDocumentation
Opened pub enum103Which passphrase was given.
Verifier struct114One passphrase's stored form.
Verifier::create fn127Derive from passphrase once and keep what it produced, with the salt that produced it, so a later attempt can be compared against it.
Verifier::matches pub(crate) fn137Derive and compare.
constant_time_eq fn144Compare without letting the time taken depend on where they differ.
LEAST_DIFFERENCE pub const160How similar two passphrases may be before the pair is refused.
Refused pub enum164Why a pair was refused.
Refused::fmt fn185
differences fn223How many positions two passphrases differ in.
Decoy pub struct248A decoy passphrase's stored form, on its own.
MAGIC const254What a decoy record starts with.
FORMAT_VERSION const257The only format there is so far.
RECORD_LEN pub const261Exactly how long a record is: magic, version, three reserved bytes, the three costs, the salt, the derived key.
Decoy::create pub fn273Make a decoy from the real passphrase and the decoy one.
Decoy::nothing fn300A record no passphrase opens, for the sake of taking the same time.
Decoy::matches pub(crate) fn313Derive and compare.
Decoy::to_bytes pub fn323The record, for writing: its fields, then random bytes up to the app lock's own length.
Decoy::parse pub fn351Read a record.
State pub enum397Whether this machine has a decoy passphrase, and whether it can be read.
Store pub struct417The decoy passphrase as this machine keeps it.
Store::at pub fn426The store under base, which is the folder the app lock lives in.
Store::here pub fn433The store for this copy of VeilVoice.
Store::state pub fn439Whether a decoy is set, and whether it reads.
Store::set pub fn457Set or replace the decoy passphrase.
Store::remove pub fn475Remove the decoy passphrase, after proving the real one.
Store::prove fn492That real really is this machine's passphrase.
Store::judge pub fn540Which passphrase was typed.
SCOPE pub const578What a decoy is worth, in the words a front end must show.
WHY_NO_DESTRUCTION pub const591Why no passphrase destroys anything, and why that is the honest choice.