Files
devvm/testdata/script/install_minisign.txtar
w3cjandClaude Opus 5.5 f3052e5a8e feat(upgrade): releases checked by two of three release keys, bridged from the old key
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.

The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.

- internal/minisign: the one owner of signature checks (moved from
  internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
  compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
  Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
  distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
  blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
  FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
  code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
  but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
  in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
  packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
  none, or three distinct minisign keys, none the old key),
  TestCheckReleaseKeys (fixture keys from minisigntest),
  TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
  empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
  marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
  none or all three of packaging/keys' release keys. With none,
  install.sh's release_<role>_key lines are empty or missing; with all
  three, each is a minisign key, distinct, not the old release key, not
  marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
  and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
  signature only when the script has its key), check_signature,
  signed_by_two, check_legacy; plainer warning without minisign, with
  the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
  upgrade.txtar (-legacy, -keys, and the keys built in, none),
  install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
  (real minisign), release.txtar (none, nolines, nokeyline, old, marked
  and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
  Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
  releases/0.2.0.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00

80 lines
3.2 KiB
Plaintext

# install.sh's check of a release's signatures with the real minisign, as
# minisign signs them, with keys made for the test: two of the three
# release keys, each with its trusted comment devvm-release VERSION, or
# while releases bridge from it, the old release key with devvm VERSION.
# install.txtar checks the rest of the script against a stub minisign.
[!exec:minisign] skip
exec bash keys.sh
# CI's and the co-signer's, and the recovery key's with either.
exec bash check.sh 0.1.0 ci cosign
stdout '^==> signatures checked: two of devvm''s three release keys$'
exec bash check.sh 0.1.0 cosign recovery
stdout '^==> signatures checked: two of devvm''s three release keys$'
exec bash check.sh 0.1.0 ci cosign recovery old
stdout '^==> signatures checked: two of devvm''s three release keys$'
# One key's alone, one in two roles' files, or another release's
# comment: refused.
! exec bash check.sh 0.1.0 ci
stderr '^install: devvm''s SHA256SUMS isn''t signed with devvm''s release keys: not installed$'
! exec bash check.sh 0.1.0 ci ci:cosign
stderr 'isn''t signed with devvm''s release keys'
env COMMENT='devvm-release 0.0.9'
! exec bash check.sh 0.1.0 ci cosign
stderr 'isn''t signed with devvm''s release keys'
env COMMENT='devvm 0.1.0'
! exec bash check.sh 0.1.0 ci cosign
stderr 'isn''t signed with devvm''s release keys'
env COMMENT=
# minisign's legacy signatures, over the file itself rather than its
# BLAKE2b-512 (-S -l), are refused, as devvm upgrade refuses them.
env LEGACY_FORMAT=1
! exec bash check.sh 0.1.0 ci cosign
stderr 'isn''t signed with devvm''s release keys'
! exec bash check.sh 0.1.0 old
stderr 'isn''t signed with devvm''s release keys'
env LEGACY_FORMAT=
# The old release key's alone, with its own comment, as 0.1 and 0.2's
# releases are; with the release keys' comment it's refused.
exec bash check.sh 0.1.0 old
stdout '^==> signature checked: devvm''s old release key$'
env COMMENT='devvm-release 0.1.0'
! exec bash check.sh 0.1.0 old
stderr 'isn''t signed with devvm''s release keys'
env COMMENT=
-- keys.sh --
# Four key pairs, without passwords: the three release keys and the old one.
set -eu
mkdir keys
for k in ci cosign recovery old; do minisign -G -W -p "keys/$k.pub" -s "keys/$k.key" >/dev/null; done
-- check.sh --
# check.sh VERSION SIGNER...: SHA256SUMS signed by each SIGNER, a key's
# name, into its own role's file, or KEY:ROLE into ROLE's, with the
# trusted comment $COMMENT, else the one its role signs with, then
# install.sh's check of it.
set -eu
DEVVM_INSTALL_TEST=1 source "$DEVVM_REPO/install.sh"
v=$1
shift
d=$WORK/dl
rm -rf "$d"
mkdir -p "$d"
echo "0000000000000000000000000000000000000000000000000000000000000000 devvm-$v-x.tar.gz" > "$d/SHA256SUMS"
for s in "$@"; do
k=${s%%:*} role=${s#*:}
case $role in
old) f=SHA256SUMS.minisig c="devvm $v" ;;
*) f=SHA256SUMS.$role.minisig c="devvm-release $v" ;;
esac
l=()
[[ -z ${LEGACY_FORMAT:-} ]] || l=(-l)
minisign -S ${l[@]+"${l[@]}"} -s "$WORK/keys/$k.key" -m "$d/SHA256SUMS" -x "$d/$f" -t "${COMMENT:-$c}" >/dev/null
done
pub() { sed -n 2p "$WORK/keys/$1.pub"; }
release_ci_key=$(pub ci) release_cosign_key=$(pub cosign) release_recovery_key=$(pub recovery) minisign_key=$(pub old)
check_signature "$d" "$v"