Signing keys: minisign, SHA256SUMS, Authenticode digests, the household CA, the audit log; v0.9.0 #11

Manually merged
mnovak merged 6 commits from feature/signing into main 2026-11-04 00:45:14 +01:00
Owner

Signing keys for Fabrica Domi · Artifex: releases are signed inside the vault, and the key never leaves it. docs/SIGNING.md is the contract; docs/FORMAT.md gains the optional signing body member. v0.9.0.

What

  • custos-sign (new):
    • minisign, prehashed ED, over a BLAKE2b-512 digest; this is what minisign 0.12 writes by default and what Tauri's updater (minisign-verify) checks;
    • a canonical SHA256SUMS, checked and then signed;
    • Authenticode: RSA PKCS#1 v1.5 over the 32-byte digest signtool sign /dg writes;
    • the household CA: an RSA-3072 root (10 years) and a code-signing leaf (2 years, EKU codeSigning) built with x509-cert.
  • custos-vault: the signing body member.
    • Key sets. A release set (domi-release, domi-root, domi-code-signing) and a test set, whose leaf sits under its own test root that no PC trusts.
    • Scope. Pipelines and repos per key, with * for any.
    • A sign-only API. signing_check, signing_sign, signing_refuse, signing_keys, signing_export_cert. Release keys sign only with Approval::Mark; test keys never sign for a tag trigger.
    • An append-only audit log. Outcomes are approved, auto, refused, expired, out-of-scope and invalid, saved with the vault.
  • tools/signing/interop.ps1: the real minisign, signtool and osslsigncode against custos-sign.

Departure from the Day 3 prompt: the keys are a body member like identity, not new item types.

  • An unknown item type makes an older reader refuse the whole vault (Corrupted), which would be a format change in all but name.
  • Every item path (reveal, copy, QR, share, KeePass export, the editor) would be a way out for a key.

As with identity, an older Custos drops signing when it saves.

Tests: 140 green (cargo test --workspace). The new ones:

  • custos-sign known answers (9). minisign's signature and public key are byte-equal to the real minisign 0.12's (fixtures it made). The Authenticode signature is byte-equal to openssl pkeyutl's. The CA chain verifies, and the canonical-manifest rules and redaction are covered.
  • custos-vault tests/signing.rs (6): every kind signs and verifies; scope is refused even when approved; release keys never auto-sign and test keys never sign a tag; malformed requests and the root are refused; the audit log records every outcome and survives a reopen.
  • A unit test that no API path returns a private key. It searches every output (views, certificates, signatures, refusals, the audit log, errors, Debug) for the seeds and for the RSA private exponents and primes, whole and in 16-byte windows, as hex and base64.

Interop (tools/signing/interop.ps1):

  • minisign -V accepts a signature and a signed SHA256SUMS, and rejects a changed file.
  • signtool /dg → custos-sign → /di → osslsigncode verify -CAfile <test root> succeeds.
  • signtool verify /pa stops only at "not trusted", because the test root is not installed here.

Self-review

  • cost: the browser build grows from 930 KB to 1.2 MB, because the vault links RSA and X.509 that the web vault never uses. A later signing feature could leave them out; the vault would then have to carry the member through untouched.
  • wasm: rsa/x509-cert bring rand_core 0.6 and getrandom 0.2. custos-sign draws from rand's SysRng, and custos-wasm routes getrandom 0.2's custom backend to the same random_fill. Built for wasm32 with the Nix toolchain, and js/test.mjs passes.
  • minor: a minisign request carries the BLAKE2b-512 of the file, and the vault cannot check it against the claimed sha256 (the wrong-file risk in SIGNING.md). The audit log keeps both.
  • minor: RSA key generation is slow unoptimised, so the workspace now builds rsa and num-bigint-dig at opt-level 3 in dev.
  • looked for, found nothing: a function returning secret, which is used only inside signing.rs; a Debug that prints a key (Key, Ed25519Secret and RsaSecret all redact); a refusal recorded as a signature (signing_refuse turns approved/auto into refused).
  • hygiene: cargo fmt --all had reformatted files this branch does not change; that is reverted, and CLAUDE.md now names the trap.
Signing keys for Fabrica Domi · Artifex: releases are signed inside the vault, and the key never leaves it. `docs/SIGNING.md` is the contract; `docs/FORMAT.md` gains the optional `signing` body member. v0.9.0. **What** - `custos-sign` (new): - minisign, prehashed `ED`, over a BLAKE2b-512 digest; this is what minisign 0.12 writes by default and what Tauri's updater (minisign-verify) checks; - a canonical `SHA256SUMS`, checked and then signed; - Authenticode: RSA PKCS#1 v1.5 over the 32-byte digest `signtool sign /dg` writes; - the household CA: an RSA-3072 root (10 years) and a code-signing leaf (2 years, EKU codeSigning) built with `x509-cert`. - `custos-vault`: the `signing` body member. - **Key sets.** A release set (`domi-release`, `domi-root`, `domi-code-signing`) and a test set, whose leaf sits under its own test root that no PC trusts. - **Scope.** Pipelines and repos per key, with `*` for any. - **A sign-only API.** `signing_check`, `signing_sign`, `signing_refuse`, `signing_keys`, `signing_export_cert`. Release keys sign only with `Approval::Mark`; test keys never sign for a `tag` trigger. - **An append-only audit log.** Outcomes are approved, auto, refused, expired, out-of-scope and invalid, saved with the vault. - `tools/signing/interop.ps1`: the real minisign, signtool and osslsigncode against `custos-sign`. **Departure from the Day 3 prompt:** the keys are a body member like `identity`, not new item types. - An unknown item type makes an older reader refuse the whole vault (`Corrupted`), which would be a format change in all but name. - Every item path (reveal, copy, QR, share, KeePass export, the editor) would be a way out for a key. As with `identity`, an older Custos drops `signing` when it saves. **Tests:** 140 green (`cargo test --workspace`). The new ones: - `custos-sign` known answers (9). minisign's signature and public key are byte-equal to the real minisign 0.12's (fixtures it made). The Authenticode signature is byte-equal to `openssl pkeyutl`'s. The CA chain verifies, and the canonical-manifest rules and redaction are covered. - `custos-vault` `tests/signing.rs` (6): every kind signs and verifies; scope is refused even when approved; release keys never auto-sign and test keys never sign a tag; malformed requests and the root are refused; the audit log records every outcome and survives a reopen. - A unit test that no API path returns a private key. It searches every output (views, certificates, signatures, refusals, the audit log, errors, Debug) for the seeds and for the RSA private exponents and primes, whole and in 16-byte windows, as hex and base64. **Interop** (`tools/signing/interop.ps1`): - `minisign -V` accepts a signature and a signed SHA256SUMS, and rejects a changed file. - `signtool /dg` → custos-sign → `/di` → `osslsigncode verify -CAfile <test root>` succeeds. - `signtool verify /pa` stops only at "not trusted", because the test root is not installed here. **Self-review** - *cost*: the browser build grows from 930 KB to 1.2 MB, because the vault links RSA and X.509 that the web vault never uses. A later `signing` feature could leave them out; the vault would then have to carry the member through untouched. - *wasm*: `rsa`/`x509-cert` bring `rand_core` 0.6 and getrandom 0.2. `custos-sign` draws from `rand`'s `SysRng`, and `custos-wasm` routes getrandom 0.2's custom backend to the same `random_fill`. Built for wasm32 with the Nix toolchain, and `js/test.mjs` passes. - *minor*: a minisign request carries the BLAKE2b-512 of the file, and the vault cannot check it against the claimed sha256 (the wrong-file risk in SIGNING.md). The audit log keeps both. - *minor*: RSA key generation is slow unoptimised, so the workspace now builds `rsa` and `num-bigint-dig` at opt-level 3 in dev. - *looked for, found nothing*: a function returning `secret`, which is used only inside `signing.rs`; a `Debug` that prints a key (`Key`, `Ed25519Secret` and `RsaSecret` all redact); a refusal recorded as a signature (`signing_refuse` turns approved/auto into refused). - *hygiene*: `cargo fmt --all` had reformatted files this branch does not change; that is reverted, and CLAUDE.md now names the trap.
mnovak added 6 commits 2026-11-04 00:45:10 +01:00
mnovak manually merged commit bf661a7338 into main 2026-11-04 00:45:14 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#11