reset.rs

crates/veilvoice-crypto/src/reset.rs

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

Putting this machine back to a new install.

What a reset is for

Somebody has a VeilVoice that is wrong. A policy they no longer want, a settings file that has been edited by hand, a folder full of vaults from a job that is finished, a lock whose passphrase they have decided to change by starting over. Until this existed the answer was "find the folder yourself and delete the right things out of it", and that answer is a person deleting the wrong file.

It works by exclusion, and that is the point

A reset that removes a list of things leaves behind whatever was added to the folder after the list was written, which is the failure mode of every uninstaller that has ever left half of itself on a disk. So this removes everything in the folder and keeps only what it was asked to keep.

crate::layout is what puts a name on each thing, so somebody can read what they are about to lose. It does not decide what goes. Anything the layout has never heard of is removed too, and described as one of the files VeilVoice writes.

Nothing happens until somebody has read it

plan only looks. It returns what would go, what would stay, how many files and how many bytes, and whether anything in it is irreplaceable: recordings, and colour schemes somebody wrote. That last answer is what a front end turns into a typed confirmation, because a settings file has defaults to come back to and a recording does not.

carry_out is the half that removes, and it takes a plan rather than a directory, so the thing removed is the thing that was described.

Keeping the keys

Keep::Keys leaves the app lock exactly as it is. That is the common case and it is not a compromise: somebody resetting a misconfigured interface wants their recordings afterwards, and the recordings are sealed with the lock. Losing it would mean losing them, which is the opposite of what they asked for.

What it keeps is the lock and nothing else. The vaults are removed either way, because they are what "start again" means. A person who wants to keep their recordings and their lock is not resetting; they are changing a setting.

What it does not pretend to do

It deletes rather than erases. The bytes go where deleted bytes go on this filesystem, and crate::shred explains at length why overwriting them is not the guarantee it sounds like on flash storage. A reset that spent an hour overwriting a vault and still could not promise the blocks were gone would be buying a feeling. Full-volume encryption is the answer to that threat and it always was.

It only touches this folder. An administrator's copy of the lock, where the platform allowed one, is under /etc and an ordinary user cannot remove it. A reset that quietly left it behind would leave a lock that comes back by itself on the next launch, from crate::vault::Vault::load's own restore, so the plan reports it by name and says what it needs.

In plain words

Puts VeilVoice back to how it was the day you installed it. It shows you everything it is about to remove, with how much of it there is, before it removes anything, and it can leave your password and the recordings' key alone if that is all you wanted.

WHAT THIS FILE CONTAINS

903 lines defining 10 functions (8 public), 5 types and 0 constants. Everything below is read out of the source, so it cannot disagree with the code.

The types it owns.

  • enum Keep line 84 · What a reset leaves behind.
  • struct Doomed line 95 · One thing a reset would remove, in the words somebody can read.
  • struct Plan line 113 · What a reset would do, before it does any of it.
  • struct Report line 164 · What a reset did.
  • struct Keys line 358 · Everything "keep the keys" has to keep, or the reason it cannot be worked out.

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.

  • Plan::bytes line 138 · How much would go altogether.
  • Plan::files line 143 · How many files would go altogether.
  • Plan::irreplaceable line 152 · Whether any of it is something nothing can put back.
  • Plan::is_empty line 157 · Whether there is nothing to do.
  • Report::complete line 177 · Whether everything the plan named is gone.
  • plan line 189 · What this reset would do to the folder this copy is using.
    reaches plan_in, keys_in, measure
  • carry_out line 321 · Remove what the plan named.

WHAT CALLS WHAT

Plan::bytes line 138 Plan::files line 143 Plan::irreplaceable line 152 Plan::is_empty line 157 Report::complete line 177 plan line 189 plan_in line 199 carry_out line 321 keys_in line 392 measure line 445 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_bytes(["Plan::bytes<br/>line 138"])
    n_files(["Plan::files<br/>line 143"])
    n_irreplaceable(["Plan::irreplaceable<br/>line 152"])
    n_is_empty(["Plan::is_empty<br/>line 157"])
    n_complete(["Report::complete<br/>line 177"])
    n_plan(["plan<br/>line 189"])
    n_plan_in["plan_in<br/>line 199"]
    n_carry_out(["carry_out<br/>line 321"])
    n_keys_in["keys_in<br/>line 392"]
    n_measure["measure<br/>line 445"]
    n_plan --> n_plan_in
    n_plan_in --> n_keys_in
    n_plan_in --> n_measure
    click n_bytes href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L138" "open the source"
    click n_files href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L143" "open the source"
    click n_irreplaceable href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L152" "open the source"
    click n_is_empty href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L157" "open the source"
    click n_complete href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L177" "open the source"
    click n_plan href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L189" "open the source"
    click n_plan_in href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L199" "open the source"
    click n_carry_out href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L321" "open the source"
    click n_keys_in href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L392" "open the source"
    click n_measure href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-crypto/src/reset.rs#L445" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_bytes,n_files,n_irreplaceable,n_is_empty,n_complete,n_plan,n_carry_out entry
    classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
    class n_plan_in api
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_keys_in,n_measure 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
Keep pub enum84What a reset leaves behind.
Doomed pub struct95One thing a reset would remove, in the words somebody can read.
Plan pub struct113What a reset would do, before it does any of it.
Plan::bytes pub fn138How much would go altogether.
Plan::files pub fn143How many files would go altogether.
Plan::irreplaceable pub fn152Whether any of it is something nothing can put back.
Plan::is_empty pub fn157Whether there is nothing to do.
Report pub struct164What a reset did.
Report::complete pub fn177Whether everything the plan named is gone.
plan pub fn189What this reset would do to the folder this copy is using.
plan_in pub fn199The same, for a folder named outright.
carry_out pub fn321Remove what the plan named.
Keys struct358Everything "keep the keys" has to keep, or the reason it cannot be worked out.
keys_in fn392The app lock's own files: the index, the two copies it names, the decoy record and the single file the vault replaced.
measure fn445How many files and how many bytes, counting inside a folder.