lib.rs

crates/veilvoice-verify/src/lib.rs

veilvoice-verify · 2639 lines · read the source here · or on GitHub

The portable verifier: check a VeilVoice release without GnuPG installed.

What this is for

Verifying a download by hand needs GnuPG and a SHA-256 tool. That is four commands and two dependencies, and on Windows it is usually neither. This is one binary that does the same checks with nothing else installed: the signing key and its fingerprint are compiled into it.

The one thing it cannot embed

It cannot carry the expected hash of the file it is checking. A file cannot contain its own digest -- writing the digest in changes the file, which changes the digest. So the hash has to come from outside, and there are exactly two places it can come from. They prove different things, and this tool is careful never to blur them:

From the published SHA256SUMS -- whose signature this tool checks against the embedded key. A match proves the download is intact: it is byte-for-byte the file that was published, not a corrupted or substituted one. It says nothing about whether that file corresponds to the source, because whoever published it produced both the file and the list.

Typed in by hand, from a hash somebody else produced by building the same tagged source themselves. A match proves something strictly stronger: that the published binary is what that source compiles to, on a machine that is not the publisher's. That is reproducibility, and it is the only check that does not ultimately rest on trusting whoever signed the release.

Most people want the first. The second is what makes the first worth anything, and it needs somebody other than the author to have done a build. docs/REPRODUCIBLE_BUILDS.md says how.

What it does not do

It does not install anything, and it writes nothing outside the directory it is pointed at. veilvoice verify file does not download anything either: fetch the files however you like and it reads them from disk.

veilvoice verify release does fetch, and it is the one thing here that does. There is still no HTTP client in the dependency graph, which is the claim the front page makes and a CI job enforces; the download is done by the transfer tool the operating system already ships, as a subprocess. fetch.rs says why at length.

In plain words

This is the small program you can check a download with before trusting anything else here.

It is deliberately tiny and it is on its own: no window, no other pieces, and it does not need any other software installed -- not even the usual signature program. That matters because it is the first thing you run, and the point of it is to be small enough to be worth reading.

Double-click it and it looks for a downloaded release nearby and checks it. Give it arguments and it does exactly what you asked.

WHAT THIS FILE CONTAINS

2639 lines defining 41 functions (2 public), 2 types and 2 constants. Everything below is read out of the source, so it cannot disagree with the code.

The types it owns.

  • enum Manifest line 1095 · What the release said is inside its archives, if anything usable.
  • enum Asked line 2338 · A question about this program, rather than something for it to do.

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.

  • help_text line 173 · The verifier's own help, with its verbosity and exit-status tables.
  • run line 2397 · Run the verifier over args, which are the words after veilvoice verify.
    reaches asked_for, command_archive, command_auto, command_build, command_deps, command_file_against_hash, command_file_against_sums, command_gnupg, command_hash, command_install, command_key, command_machine

WHAT CALLS WHAT

embedded_key line 148 sha256_file line 159 verify_detached line 164 good line 419 fail line 430 deny line 446 incomplete_deny line 463 cannot line 481 usage line 501 read_text line 523 command_key line 532 command_sums line 555 command_file_against_sums line 598 command_file_against_hash line 694 command_hash line 750 take_value line 768 command_release line 784 command_auto line 865 report_extracted line 1031 manifest line 1111 report_against_manifest line 1142 run line 2397 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. 22 of 41 functions are drawn; the diagram is bounded at 22 so it stays readable.

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 41 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_embedded_key["embedded_key<br/>line 148"]
    n_sha256_file["sha256_file<br/>line 159"]
    n_verify_detached["verify_detached<br/>line 164"]
    n_good["good<br/>line 419"]
    n_fail["fail<br/>line 430"]
    n_deny["deny<br/>line 446"]
    n_incomplete_deny["incomplete_deny<br/>line 463"]
    n_cannot["cannot<br/>line 481"]
    n_usage["usage<br/>line 501"]
    n_read_text["read_text<br/>line 523"]
    n_command_key["command_key<br/>line 532"]
    n_command_sums["command_sums<br/>line 555"]
    n_command_file_against_sums["command_file_against_sums<br/>line 598"]
    n_command_file_against_hash["command_file_against_hash<br/>line 694"]
    n_command_hash["command_hash<br/>line 750"]
    n_take_value["take_value<br/>line 768"]
    n_command_release["command_release<br/>line 784"]
    n_command_auto["command_auto<br/>line 865"]
    n_report_extracted["report_extracted<br/>line 1031"]
    n_manifest["manifest<br/>line 1111"]
    n_report_against_manifest["report_against_manifest<br/>line 1142"]
    n_run(["run<br/>line 2397"])
    n_command_auto --> n_command_file_against_sums
    n_command_auto --> n_incomplete_deny
    n_command_auto --> n_manifest
    n_command_auto --> n_report_extracted
    n_command_file_against_hash --> n_cannot
    n_command_file_against_hash --> n_deny
    n_command_file_against_hash --> n_good
    n_command_file_against_hash --> n_sha256_file
    n_command_file_against_hash --> n_usage
    n_command_file_against_sums --> n_cannot
    n_command_file_against_sums --> n_deny
    n_command_file_against_sums --> n_embedded_key
    n_command_file_against_sums --> n_good
    n_command_file_against_sums --> n_read_text
    n_command_file_against_sums --> n_sha256_file
    n_command_file_against_sums --> n_verify_detached
    n_command_hash --> n_cannot
    n_command_hash --> n_sha256_file
    n_command_key --> n_deny
    n_command_key --> n_embedded_key
    n_command_release --> n_command_file_against_sums
    n_command_release --> n_command_sums
    n_command_release --> n_fail
    n_command_release --> n_usage
    n_command_sums --> n_cannot
    n_command_sums --> n_deny
    n_command_sums --> n_embedded_key
    n_command_sums --> n_good
    n_command_sums --> n_read_text
    n_command_sums --> n_verify_detached
    n_manifest --> n_read_text
    n_report_against_manifest --> n_good
    n_report_extracted --> n_manifest
    n_report_extracted --> n_report_against_manifest
    n_run --> n_command_auto
    n_run --> n_command_file_against_hash
    n_run --> n_command_file_against_sums
    n_run --> n_command_hash
    n_run --> n_command_key
    n_run --> n_command_release
    n_run --> n_command_sums
    n_run --> n_take_value
    n_run --> n_usage
    click n_embedded_key href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L148" "open the source"
    click n_sha256_file href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L159" "open the source"
    click n_verify_detached href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L164" "open the source"
    click n_good href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L419" "open the source"
    click n_fail href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L430" "open the source"
    click n_deny href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L446" "open the source"
    click n_incomplete_deny href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L463" "open the source"
    click n_cannot href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L481" "open the source"
    click n_usage href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L501" "open the source"
    click n_read_text href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L523" "open the source"
    click n_command_key href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L532" "open the source"
    click n_command_sums href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L555" "open the source"
    click n_command_file_against_sums href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L598" "open the source"
    click n_command_file_against_hash href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L694" "open the source"
    click n_command_hash href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L750" "open the source"
    click n_take_value href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L768" "open the source"
    click n_command_release href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L784" "open the source"
    click n_command_auto href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L865" "open the source"
    click n_report_extracted href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L1031" "open the source"
    click n_manifest href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L1111" "open the source"
    click n_report_against_manifest href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L1142" "open the source"
    click n_run href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/lib.rs#L2397" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_run entry
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_embedded_key,n_sha256_file,n_verify_detached,n_good,n_fail,n_deny,n_incomplete_deny,n_cannot,n_usage,n_read_text,n_command_key,n_command_sums,n_command_file_against_sums,n_command_file_against_hash,n_command_hash,n_take_value,n_command_release,n_command_auto,n_report_extracted,n_manifest,n_report_against_manifest 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
embedded_key fn148The embedded key, with its fingerprint checked against FINGERPRINT.
sha256_file fn159SHA-256 of a file, as this program's Result<_, String>.
verify_detached fn164Verify a detached signature, as this program's Result<_, String>.
help_text pub fn173The verifier's own help, with its verbosity and exit-status tables.
USAGE const188The help screen for veilvoice verify, written out rather than derived.
EXPLAIN const371The longer explanation, printed when a reader asks for it.
good fn419One line of a passing check, in the shape every other line here uses.
fail fn430A failure that is not a refusal: something did not happen, rather than something was checked and found wrong.
deny fn446Every refusal goes through here, so every refusal names the check.
incomplete_deny fn463Nothing could be checked, with the same shape of detail as a refusal.
cannot fn481A file this program was told to read could not be read.
usage fn501The command line could not be understood, so nothing was attempted.
read_text fn523A file as text, with the path in the error rather than just the reason.
command_key fn532veilvoice verify key: what the key compiled into this binary is.
command_sums fn555veilvoice verify sums: the signature over a hash list, and nothing else.
command_file_against_sums fn598veilvoice verify file: the whole chain for one download.
command_file_against_hash fn694veilvoice verify file --sha256: one file against one hash typed by hand.
command_hash fn750veilvoice verify hash: print a file's SHA-256 and stop.
take_value fn768The value after a flag, or a message naming the flag that is missing one.
command_release fn784Fetch a release and check it, in one step.
command_auto fn865Find a release near the user and check it, with nothing else to type.
report_extracted fn1031Roadmap item 97.
Manifest enum1095What the release said is inside its archives, if anything usable.
manifest fn1111Read CONTENTS.sha256, having first proved it is the published one.
report_against_manifest fn1142Check one extracted folder against the section of the list that covers it.
digest_for fn1216The published hash for one path, for a --verbose line.
report_runnable fn1231Whether the operating system will run the programs that are there.
report_presence_only fn1255The old report, for a release that published no contents list.
report_gnupg fn1298Roadmap item 97.
report_carried fn1385Roadmap item 164.
report_inside fn1445Roadmap item 164.
command_archive fn1560Roadmap item 164.
published_on_this_machine fn1693Roadmap item 164.
command_machine fn1720Roadmap item 164.
report_what_moved fn1863Roadmap item 164.
command_gnupg fn1907Roadmap item 91.
command_deps fn1952What this machine needs before it can build VeilVoice.
command_build fn2024Build the workspace from source and hash what came out.
do_build fn2042Everything both build commands do before they differ.
command_reproduce fn2111Build here, and compare against the published hashes for this platform.
command_install fn2220Put binaries where a shell will find them.
asked_for fn2318Print something the reader asked for by name, at any level.
Asked enum2338A question about this program, rather than something for it to do.
Asked::in_args fn2355Which of these, if any, the arguments ask for.
run pub fn2397Run the verifier over args, which are the words after veilvoice verify.