Skip to main content

Module trust

Module trust 

Source
Expand description

Trusted keys, and the signature check every consumer path begins with.

The caller decides which public keys it accepts, and that decision is the whole basis of every guarantee below it. This crate never discovers a key, never fetches one, and never treats a key shipped beside an archive as trusted because it arrived.

Where those keys come from is the caller’s business rather than this crate’s, and the difference is a security property, not an ergonomic one. A trust file on disk suits a command line, whose operator is also its administrator. An application shipped to someone else’s machine usually wants the opposite: anchors compiled into the binary with include_str!, so that editing a file cannot substitute a key, sign a box with it, and have the application accept the result. Both reach verification as TrustAnchors, and everything past this module sees the same resolved slice — there is one verification path, not one per source.

A document is accepted when any one of its signatures verifies against a trusted key. That is what lets a document signed by both an outgoing and an incoming key stay valid across a rotation, and it is why a signature naming an unknown key is skipped rather than treated as an attack — a build that carries only one of the two keys must still be able to verify. Compiled-in anchors do not change that rule, but they do change who pays for it: rotating a key an application carries means releasing the application, so an application that may ever rotate should compile in the bundle shape and not the single key.

Structs§

TrustedKey
One public key a caller is willing to accept signatures from.
VerifiedPayload
The payload of a document whose signature has verified.

Enums§

TrustAnchors
Where the keys a caller accepts come from.

Functions§

load_trusted_keys
Reads a trust file holding either a single key or a { "keys": [...] } bundle.
parse_trusted_keys
The same two shapes, from bytes the caller already holds.
verify_signed_document
Verifies a signed document against a set of trusted keys and returns its payload.
verify_signed_document_with_anchors
Verifies a signed document against anchors from either source.