AGENTS.md #
Guidance for coding agents working in this repo.
The attestation contract lives in bootproof, not here #
All attestation knowledge (the bundle schema, generation, verification, the
nonce→bundle socket protocol, the fact schemas, the browser service-worker
verifier, the identity pin) is owned by the bootproof crate
(../bootproof, see its AGENTS.md). wardend is a plugin consumer: seald
holds the HSM key + supplies evidence and calls bootproof::engine::produce;
bastiond serves the bytes on :443; posternd is the :22 SSH back door +
admin proxy; wardenctl is a CLI consumer of engine::verify_bundle +
spki::spki_pin. Do NOT re-implement attestation logic in wardend — add a
channel/verifier in the bootproof-platform-wardend crate instead. The System
Health browser page (docs/system-health.md) renders a bootproof-defined
envelope; the verifier bundle is embedded from bootproof's system-health
feature.
Build + test #
export PATH="$HOME/.cargo/bin:$PATH"before any cargo command.- Build:
cargo build --features gvisor,container(must exit 0). - Test:
cargo test --features gvisor,container(must be all green, no hang). The seal crate alone:cargo test -p seal --lib(235 tests). - Do NOT run
cargo fmt. Format by hand to match the surrounding style.
Style contract #
#![deny(unsafe_code)]in the crypto + HSM modules (seal::ec,seal::ecdsa,seal::hsm). No external crypto deps — the P-256 is hand-rolled.- No panics in library code paths (fail closed to the bus), no
unwrap/expectin non-test code.SealdError(aStringmessage) is the whole error surface in the seal crate — a reported fact, not a control-flow taxonomy. - Focused commits, format
component: summary(e.g.seal: the HSM sign/decrypt ops + the per-unit ACL). - Refusals are clean + bounded (never a hang): a wrong-protocol request is a protocol-mismatch error, an out-of-ACL key is an ACL refusal, a gate-locked persist key is a fail-closed gate-fail.
The seald HSM invariants (do not break) #
- Non-extractability: the
sign/decryptops (wire codes 6 / 7)peekthe sealed key in-process (in seald, never internet-connected), use it, and return only the RESULT (the 64-byter || ssignature / the decrypted block). The raw key bytes never cross the socket. A compromised bastiond can make seald sign; it cannot extract the key. - Per-unit ACL: a unit gets a socket only if it declared
secrets=<key1,key2>; the socket's ACL is exactly those keys, enforced by unit identity (the socket is bound to the unit). A unit declaring no keys gets no socket. - Three protocol surfaces: a unit's key socket speaks exactly one of
pkcs11 / pgp / webauthn (the per-unit
proto=declaration, default pkcs11). A wrong-protocol request is a clean protocol-mismatch error. - PIN gate + TPM monotonic counter: the per-unit PIN is a gate on using the key; the retry counter is hardware-backed + hardware-isolated (the TPM monotonic counter — a compromised seald cannot reset it; a lock survives a seald crash / restart).
- The
peekvsunsealdistinction:unsealis once-per-boot (the read gate);peekis a repeatable read that still enforces the key-lifecycle gate (a gate-locked persist key fails closed) but does not mark the name served. The HSM sign/decrypt ops usepeek.
The three keys (seald) #
- ephemeral — this boot only; destroyed at shutdown.
- persist — a single TPM key slot bound to a policy requiring all configured attestations to pass; secrets under it are recovered on every qualifying boot.
- quorum — reconstructed from m-of-n shares; re-sealed to the persist key at the m-th share.
Layout #
src/seal/— seald (the evidence daemon + the HSM): thehsmmodule is the HSM core (key registry, sign/decrypt/generate ops, per-unit ACL, PIN gate, the three protocol surfaces);ec/ecdsaare the hand-rolled P-256 + ECDSA (ES256);storeis the generic secret store (thepeek+unsealread paths);tpm2is the raw TPM2 client;snpis the in-process SEV-SNP channel.src/bastion/— bastiond (the wire owner): the ACME account key is anchored via seal.sock (the delegated-sign op). The content digest (digest.rs) is hand-rolled with no external deps: SHA-256 (the OCI store'ssha256:<hex>primitive) + SHA-384 (the FIPS 180-4 128-byte block + the 16-byte bit-length padding, the SHA-384 initial values). The seal crate does NOT use the bastion digest — seald signs over its own SHA-256 (tpm2::sha256), so a bastion digest change never touches the HSM or the latch.- Per-crate READMEs state the status (proven prior-art vs. new work).