Skip to content

eBPF-based security platform

testing: cover signing key rotation

KP Singh7b4d3dcd02ea
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 3df5317f..aa50a51d 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -198,6 +198,14 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
generation unless the same manifest, naming the recorded parent
when the next generation, with the node's cursor between its base
and head; without a state, one that starts at 0
+ * - ``bpm-tree-signers``
+ - ``tree_fetch_publication()``
+ - Active or inactive image config; every signing-set count through
+ capacity, every unvouched count through the set size, and parse,
+ allocation, load, check and fetch failures
+ - An active image fetch receives the same set whose load and check
+ succeeded, only when it is nonempty and fully vouched; preflight
+ failures refuse the fetch and every allocated set is released
* - ``bpm-tree-sync-model``
- ``cmd_bpm_tree_sync()``, ``tree_recover_pending()``,
``tree_publication_check()``, ``tree_publication_follows()``
@@ -473,6 +481,13 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
- A bounded set of certificates under the runtime directory; a PCR
only one the config accepts; nothing changes the runtime outside
the initial settings
+ * - ``image-bootstrap-certificates``
+ - ``bootstrap_add_certificate()``
+ - Every earlier key count through capacity, present or absent paths,
+ paths outside the runtime and parent traversal
+ - Only a distinct runtime path joins a non-full set; duplicates,
+ invalid paths and overflow leave the count unchanged; earlier
+ paths keep their order
* - ``image-path``
- ``image_path_valid()``
- Up to 8 bytes
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index ba65f5cb..27fd3bb8 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -119,7 +119,8 @@ signed config image.
keys, a one-bit change in the signed bytes
* - ``t2003-keys-set``
- The trusted set and its digest, revoked certificates left out,
- ``attest predict`` agreement
+ ``attest predict`` agreement, signatures accepted from either
+ active signer and refused after that signer is revoked
* - ``t2004-keys-vouch``
- ``keys vouch``, and ``keys add`` admitting only vouched
certificates
@@ -243,7 +244,7 @@ signed config image.
* - ``t5001-config-image``
- Image builder and ``veritysetup`` format, superblock and size
checks, the ML-DSA-87 root signature, runtime acceptance by the
- exact root, the generator scripts
+ exact root, the generator scripts and multiple config certificates
* - ``t5002-image-config``
- Settings a config may set, symbolic links and special files
* - ``t5003-image-keys``
@@ -254,16 +255,26 @@ signed config image.
* - ``t5005-image-cleanup``
- Candidate removal and its ``EBUSY`` retries
* - ``t5006-image-bootstrap``
- - Bootstrap settings in the initrd
+ - Bootstrap settings in the initrd, ordered config verification keys,
+ duplicate paths and too many keys
* - ``t5007-config-update``
- Activation events, the pending latch, interruption, locks,
symbolic links in state
* - ``t5008-text-lines``
- Long lines and NUL bytes in settings files
+ * - ``t5009-config-stage``
+ - Staging without activation or measurement, selection on the next
+ TPM boot, cancellation, stale parents, malformed records and
+ process death while replacing a staged selection
+ * - ``t5100-verity-stage``
+ - A new signer may be staged without live enrollment, activation or
+ measurement; same-boot init leaves it staged and cancellation is
+ idempotent
* - ``t5101-verity-boot-signers``
- The ``.dm-verity`` keyring, boot enrollment of a vouched signer
* - ``t5102-verity-config``
- - Config classification, corruption, live activation from A to B
+ - Config classification, corruption, live activation from A to B,
+ refusal of a kernel-trusted config signer not named by the runtime
* - ``t5103-verity-cli``
- Key and repository changes require a signed config
* - ``t5104-verity-revocation``
@@ -424,7 +435,8 @@ signed config image.
scriptlets, as text
* - ``t7005-bpm-publish``
- ``bpm build``, ``bpm push`` with a signed index, ``bpm tree
- append``
+ append``, A-to-B tree signing-key rotation with explicit
+ predecessor verification
* - ``t7006-policy-labels``
- Beefile policy declarations are serialized into the signed
upatch section
@@ -807,12 +819,8 @@ Most of these attacks are open threats in
Tests that assert behavior the threat model lists as a threat to
resolve. They change when that threat is resolved:
-- ``t5102`` asserts that a config root signed under a kernel built-in
- certificate is accepted.
- ``t2003`` and ``t5003`` assert that a revoked signer's earlier
vouches stay valid.
-- ``t5004`` asserts that tree publications verify against the runtime
- trust anchor.
- ``t7003`` adds a certificate from an OCI reference without a
fingerprint to compare it with.
diff --git a/testing/functional/bpm/t7005-bpm-publish.sh b/testing/functional/bpm/t7005-bpm-publish.sh
index 76a0a30e..b7607ba2 100644
--- a/testing/functional/bpm/t7005-bpm-publish.sh
+++ b/testing/functional/bpm/t7005-bpm-publish.sh
@@ -159,7 +159,7 @@ REGISTRY="127.0.0.1:$PORT"
# Verify a detached CMS blob against the operator certificate.
cms_verify() {
openssl cms -verify -binary -inform DER -in "$1" -content "$2" \
- -certfile "$WORK/cert.pem" -CAfile "$WORK/cert.pem" -purpose any \
+ -certfile "${3:-$WORK/cert.pem}" -CAfile "${3:-$WORK/cert.pem}" -purpose any \
-out /dev/null 2>/dev/null
}
@@ -381,4 +381,44 @@ test_expect_success 'tree append needs readable signing material' '
--key "$WORK/missing.pem" --cert "$WORK/keys/cert.der" >/dev/null 2>&1
'
+test_expect_success 'a new signing key does not silently replace the previous tree signer' '
+ "$S" genkey --keys-dir "$WORK/next-key" >/dev/null &&
+ openssl x509 -inform DER -in "$WORK/next-key/cert.der" -out "$WORK/next-key.pem" &&
+ cp "$REG/ns/tree/manifests/stable" "$WORK/before-rotation.manifest" &&
+ ! "$S" bpm tree append "$WORK/t7005-1.0.0.bee" "oci://$REGISTRY/ns/tree" \
+ --keys-dir "$WORK/next-key" >/dev/null 2>&1 &&
+ cmp "$REG/ns/tree/manifests/stable" "$WORK/before-rotation.manifest"
+'
+
+test_expect_success 'previous-cert verifies A while B signs the next publication' '
+ "$S" bpm tree append "$WORK/t7005-1.0.0.bee" "oci://$REGISTRY/ns/tree" \
+ --keys-dir "$WORK/next-key" --previous-cert "$WORK/keys/cert.der" >/dev/null &&
+ split_layers "$REG/ns/tree/manifests/stable" "$REG/ns/tree" "$WORK/rotated" &&
+ cms_verify "$WORK/rotated.sig" "$WORK/rotated.payload" "$WORK/next-key.pem" &&
+ ! cms_verify "$WORK/rotated.sig" "$WORK/rotated.payload" &&
+ python3 - "$WORK/rotated.payload" "$WORK/before-rotation.manifest" <<"PYTEST"
+import hashlib, json, pathlib, sys
+publication = json.loads(pathlib.Path(sys.argv[1]).read_bytes())
+parent = pathlib.Path(sys.argv[2]).read_bytes()
+assert publication["parent_manifest_digest"] == "sha256:" + hashlib.sha256(parent).hexdigest()
+assert publication["generation"] == 3 and publication["head"] == {"seq": 3}
+PYTEST
+'
+
+test_expect_success 'later B publications use B to verify the predecessor by default' '
+ "$S" bpm tree append "$WORK/t7005-1.0.0.bee" "oci://$REGISTRY/ns/tree" \
+ --keys-dir "$WORK/next-key" >/dev/null &&
+ split_layers "$REG/ns/tree/manifests/stable" "$REG/ns/tree" "$WORK/after-rotation" &&
+ cms_verify "$WORK/after-rotation.sig" "$WORK/after-rotation.payload" "$WORK/next-key.pem" &&
+ python3 -c "import json, sys; p=json.load(open(sys.argv[1])); assert p[\"generation\"] == 4" \
+ "$WORK/after-rotation.payload"
+'
+
+test_expect_success 'a wrong explicit predecessor certificate leaves the tree unchanged' '
+ cp "$REG/ns/tree/manifests/stable" "$WORK/rotated.manifest" &&
+ ! "$S" bpm tree append "$WORK/t7005-1.0.0.bee" "oci://$REGISTRY/ns/tree" \
+ --keys-dir "$WORK/next-key" --previous-cert="$WORK/keys/cert.der" >/dev/null 2>&1 &&
+ cmp "$REG/ns/tree/manifests/stable" "$WORK/rotated.manifest"
+'
+
test_done
diff --git a/testing/functional/image/t5001-config-image.sh b/testing/functional/image/t5001-config-image.sh
index 623e4635..6ed41202 100755
--- a/testing/functional/image/t5001-config-image.sh
+++ b/testing/functional/image/t5001-config-image.sh
@@ -298,6 +298,54 @@ if command -v mkfs.ext4 >/dev/null 2>&1 && command -v debugfs >/dev/null 2>&1; t
>"$W/extracted.der" 2>/dev/null &&
cmp "$W/extracted.der" "$W/other/cert.der"
'
+ test_expect_success 'runtime generator packages both config verification keys and their settings' '
+ ../tools/gen-image/shirudo-gen-runtime --binary "$W/static-probe" \
+ --bootstrap-conf "$W/bootstrap.conf" --cert "$W/keys/cert.der" \
+ --config-cert "$W/keys/cert.der" --config-cert "$W/other/cert.der" \
+ --keys-dir "$W/keys" --builder "$B" --output "$W/runtime-overlap" --size 8 &&
+ verify "$W/runtime-overlap" "$W/keys/cert.der" &&
+ debugfs -R "cat /etc/shirudo/shirudo.conf" "$W/runtime-overlap.img" \
+ >"$W/overlap.conf" 2>/dev/null &&
+ sed -n "s/^[[:space:]]*config.verification_key[[:space:]]*=[[:space:]]*//p" \
+ "$W/overlap.conf" >"$W/config-keys" &&
+ printf "%s\n" \
+ /run/shirudo/runtime/etc/shirudo/config-cert.der \
+ /run/shirudo/runtime/etc/shirudo/config-cert-2.der >"$W/expected-keys" &&
+ cmp "$W/config-keys" "$W/expected-keys" &&
+ debugfs -R "cat /etc/shirudo/config-cert.der" "$W/runtime-overlap.img" \
+ >"$W/first.der" 2>/dev/null &&
+ debugfs -R "cat /etc/shirudo/config-cert-2.der" "$W/runtime-overlap.img" \
+ >"$W/second.der" 2>/dev/null &&
+ cmp "$W/first.der" "$W/keys/cert.der" &&
+ cmp "$W/second.der" "$W/other/cert.der"
+ '
+
+ test_expect_success 'retired runtime keeps only its supplied config key' '
+ ../tools/gen-image/shirudo-gen-runtime --binary "$W/static-probe" \
+ --bootstrap-conf "$W/overlap.conf" --cert "$W/keys/cert.der" \
+ --config-cert "$W/other/cert.der" \
+ --keys-dir "$W/keys" --builder "$B" --output "$W/runtime-retired" --size 8 &&
+ verify "$W/runtime-retired" "$W/keys/cert.der" &&
+ debugfs -R "cat /etc/shirudo/shirudo.conf" "$W/runtime-retired.img" \
+ >"$W/retired.conf" 2>/dev/null &&
+ sed -n "s/^[[:space:]]*config.verification_key[[:space:]]*=[[:space:]]*//p" \
+ "$W/retired.conf" >"$W/retired-keys" &&
+ printf "%s\n" /run/shirudo/runtime/etc/shirudo/config-cert.der \
+ >"$W/expected-retired-key" &&
+ cmp "$W/retired-keys" "$W/expected-retired-key" &&
+ debugfs -R "cat /etc/shirudo/config-cert.der" "$W/runtime-retired.img" \
+ >"$W/retired.der" 2>/dev/null &&
+ cmp "$W/retired.der" "$W/other/cert.der"
+ '
+
+ test_expect_success 'runtime generator refuses the same config certificate twice' '
+ ! ../tools/gen-image/shirudo-gen-runtime --binary "$W/static-probe" \
+ --bootstrap-conf "$W/bootstrap.conf" --cert "$W/keys/cert.der" \
+ --config-cert "$W/keys/cert.der" --config-cert "$W/keys/cert.der" \
+ --keys-dir "$W/keys" --builder "$B" --output "$W/runtime-duplicate" --size 8 &&
+ ! test -e "$W/runtime-duplicate.img"
+ '
+
test_expect_success 'static runtime images run directly without a packaged loader' '
../tools/gen-image/shirudo-gen-runtime --binary "$W/static-probe" \
--bootstrap-conf "$W/bootstrap.conf" --cert "$W/keys/cert.der" \
diff --git a/testing/functional/image/t5006-image-bootstrap.sh b/testing/functional/image/t5006-image-bootstrap.sh
index 487a9fa0..4643cd39 100755
--- a/testing/functional/image/t5006-image-bootstrap.sh
+++ b/testing/functional/image/t5006-image-bootstrap.sh
@@ -27,6 +27,46 @@ test_expect_success 'runtime settings preserve the root authenticated by the ini
grep -qx "pcr=15" "$WORK/result"
'
+test_expect_success 'two config verification keys preserve their order and runtime root' '
+ cp "$WORK/runtime.conf" "$WORK/overlap.conf" &&
+ printf "config.verification_key = /run/shirudo/runtime/etc/shirudo/config-cert-2.der\n" \
+ >>"$WORK/overlap.conf" &&
+ "$H" bootstrap "$WORK/initrd.conf" "$WORK/overlap.conf" >"$WORK/result" &&
+ grep -qx "root=$root" "$WORK/result" &&
+ grep -qx "certificates=2" "$WORK/result" &&
+ sed -n "s/^certificate=//p" "$WORK/result" >"$WORK/certificates" &&
+ printf "%s\n" /run/shirudo/runtime/etc/shirudo/config-cert.der \
+ /run/shirudo/runtime/etc/shirudo/config-cert-2.der >"$WORK/expected" &&
+ cmp "$WORK/certificates" "$WORK/expected"
+'
+
+test_expect_success 'duplicate config verification paths are rejected' '
+ cp "$WORK/runtime.conf" "$WORK/bad.conf" &&
+ printf "config.verification_key = /run/shirudo/runtime/etc/shirudo/config-cert.der\n" \
+ >>"$WORK/bad.conf" &&
+ ! "$H" bootstrap "$WORK/initrd.conf" "$WORK/bad.conf"
+'
+
+test_expect_success 'an invalid later verification key rejects the whole bootstrap config' '
+ cp "$WORK/runtime.conf" "$WORK/bad.conf" &&
+ printf "config.verification_key = /etc/attacker.der\n" >>"$WORK/bad.conf" &&
+ ! "$H" bootstrap "$WORK/initrd.conf" "$WORK/bad.conf"
+'
+
+test_expect_success 'config verification keys have a bounded count' '
+ python3 - ../util/keys.h "$WORK/max.conf" "$WORK/too-many.conf" <<"PYTEST" &&
+import re, sys
+from pathlib import Path
+limit = int(re.search(r"#define KEYS_MAX\s+(\d+)", Path(sys.argv[1]).read_text())[1])
+lines = [f"config.verification_key = /run/shirudo/runtime/keys/config-{i}.der\n"
+ for i in range(limit + 1)]
+Path(sys.argv[2]).write_text("".join(lines[:-1]))
+Path(sys.argv[3]).write_text("".join(lines))
+PYTEST
+ "$H" bootstrap "$WORK/initrd.conf" "$WORK/max.conf" >/dev/null &&
+ ! "$H" bootstrap "$WORK/initrd.conf" "$WORK/too-many.conf"
+'
+
test_expect_success 'runtime settings cannot replace the executable image or its root' '
for setting in "runtime.image = /var/lib/shirudo/other" \
"runtime.root_hash = $root"; do
diff --git a/testing/functional/image/t5009-config-stage.sh b/testing/functional/image/t5009-config-stage.sh
new file mode 100755
index 00000000..5d97f1f4
--- /dev/null
+++ b/testing/functional/image/t5009-config-stage.sh
@@ -0,0 +1,138 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")/../.."
+. ./test-lib.sh
+
+H=${SHIRUDO_TEST_CONFIG_HELPER:-$(pwd)/helper/test-config-update}
+[ -x "$H" ] || test_skip_all "test-config-update helper not built"
+WORK=$(mktemp -d)
+trap 'rm -rf "$WORK"' EXIT HUP INT TERM
+
+fresh() {
+ mkdir -m 700 "$WORK/$1" &&
+ "$H" "$WORK/$1" boot A >"$WORK/$1.out"
+}
+
+field() {
+ sed -n "s/^$2=//p" "$1"
+}
+
+save_active() {
+ (cd "$WORK/$1" && sha256sum state events simulator) >"$WORK/$1.active"
+}
+
+unchanged() {
+ (cd "$WORK/$1" && sha256sum -c "$WORK/$1.active") >/dev/null
+}
+
+test_expect_success 'staging B leaves A, its PCR and its event log unchanged' '
+ fresh stage && save_active stage &&
+ "$H" "$WORK/stage" stage B >"$WORK/staged" &&
+ unchanged stage &&
+ grep -qx "stage_prefix=/verified/config-B" "$WORK/staged" &&
+ "$H" "$WORK/stage" staged >"$WORK/eligible" &&
+ grep -qx "eligible=0" "$WORK/eligible" &&
+ ! "$H" "$WORK/stage" boot B >/dev/null &&
+ "$H" "$WORK/stage" check >/dev/null
+'
+
+for action in reset restart; do
+ test_expect_success "$action selects B only on the next TPM boot and measures it once" '
+ fresh boot-'"$action"' &&
+ "$H" "$WORK/boot-'"$action"'" stage B >/dev/null &&
+ "$H" "$WORK/boot-'"$action"'" '"$action"' >/dev/null &&
+ "$H" "$WORK/boot-'"$action"'" staged >"$WORK/eligible" &&
+ grep -qx "eligible=1" "$WORK/eligible" &&
+ grep -qx "candidate=/verified/config-B" "$WORK/eligible" &&
+ "$H" "$WORK/boot-'"$action"'" boot B >"$WORK/selected" &&
+ grep -qx "prefix=/verified/config-B" "$WORK/selected" &&
+ grep -qx "extends=2" "$WORK/selected" &&
+ [ ! -e "$WORK/boot-'"$action"'/next-boot" ] &&
+ "$H" "$WORK/boot-'"$action"'" boot B >"$WORK/repeated" &&
+ grep -qx "extends=2" "$WORK/repeated"
+ '
+done
+
+test_expect_success 'canceling a staged config is idempotent and leaves A active' '
+ fresh cancel && save_active cancel &&
+ "$H" "$WORK/cancel" stage B >/dev/null &&
+ "$H" "$WORK/cancel" cancel-stage >/dev/null &&
+ "$H" "$WORK/cancel" cancel-stage >/dev/null &&
+ [ ! -e "$WORK/cancel/next-boot" ] && unchanged cancel
+'
+
+test_expect_success 'updating to the current root preserves the staged selection' '
+ fresh same-root && "$H" "$WORK/same-root" stage B >/dev/null &&
+ save_active same-root && cp "$WORK/same-root/next-boot" "$WORK/same-root.before" &&
+ "$H" "$WORK/same-root" update A >/dev/null &&
+ cmp "$WORK/same-root.before" "$WORK/same-root/next-boot" &&
+ unchanged same-root
+'
+
+test_expect_success 'a completed live update removes an obsolete staged config' '
+ fresh live && "$H" "$WORK/live" stage B >/dev/null &&
+ "$H" "$WORK/live" update C >"$WORK/live.out" &&
+ grep -qx "prefix=/verified/config-C" "$WORK/live.out" &&
+ [ ! -e "$WORK/live/next-boot" ]
+'
+
+test_expect_success 'a staged record restored after its parent changed is ignored' '
+ fresh stale && "$H" "$WORK/stale" stage B >/dev/null &&
+ cp "$WORK/stale/next-boot" "$WORK/saved-stage" &&
+ "$H" "$WORK/stale" update C >/dev/null &&
+ cp "$WORK/saved-stage" "$WORK/stale/next-boot" &&
+ "$H" "$WORK/stale" reset >/dev/null &&
+ "$H" "$WORK/stale" staged >"$WORK/eligible" &&
+ grep -qx "eligible=0" "$WORK/eligible" &&
+ ! "$H" "$WORK/stale" boot B >/dev/null &&
+ "$H" "$WORK/stale" boot C >/dev/null &&
+ [ ! -e "$WORK/stale/next-boot" ]
+'
+
+test_expect_success 'a pending update or PCR drift cannot stage another config' '
+ fresh pending &&
+ ! SHIRUDO_TEST_CONFIG_EXTEND=before "$H" "$WORK/pending" update B >/dev/null &&
+ ! "$H" "$WORK/pending" stage C >/dev/null &&
+ [ ! -e "$WORK/pending/next-boot" ] &&
+ fresh drift && "$H" "$WORK/drift" drift >/dev/null &&
+ ! "$H" "$WORK/drift" stage B >/dev/null &&
+ [ ! -e "$WORK/drift/next-boot" ]
+'
+
+test_expect_success 'process death while writing a replacement preserves the previous stage' '
+ fresh interrupted && "$H" "$WORK/interrupted" stage B >/dev/null &&
+ save_active interrupted && cp "$WORK/interrupted/next-boot" "$WORK/stage-before" &&
+ SHIRUDO_TEST_CONFIG_STAGE_CRASH=1 "$H" "$WORK/interrupted" stage C >/dev/null;
+ rc=$? && [ "$rc" = 99 ] &&
+ unchanged interrupted && cmp "$WORK/stage-before" "$WORK/interrupted/next-boot" &&
+ "$H" "$WORK/interrupted" stage C >"$WORK/replacement" &&
+ grep -qx "stage_prefix=/verified/config-C" "$WORK/replacement" &&
+ unchanged interrupted
+'
+
+test_expect_success 'an incomplete temporary record is ignored at the next boot' '
+ fresh temporary && printf incomplete >"$WORK/temporary/.next-boot.tmp" &&
+ "$H" "$WORK/temporary" reset >/dev/null &&
+ "$H" "$WORK/temporary" boot A >"$WORK/temporary.out" &&
+ grep -qx "prefix=/verified/config-A" "$WORK/temporary.out"
+'
+
+for invalid in malformed oversize symlink fifo; do
+ test_expect_success "$invalid staged record fails without extending the PCR" '
+ fresh invalid-'"$invalid"' &&
+ case '"$invalid"' in
+ malformed) printf invalid >"$WORK/invalid-'"$invalid"'/next-boot" ;;
+ oversize) head -c 65536 /dev/zero >"$WORK/invalid-'"$invalid"'/next-boot" ;;
+ symlink) ln -s state "$WORK/invalid-'"$invalid"'/next-boot" ;;
+ fifo) mkfifo "$WORK/invalid-'"$invalid"'/next-boot" ;;
+ esac &&
+ "$H" "$WORK/invalid-'"$invalid"'" reset >/dev/null &&
+ save_active invalid-'"$invalid"' &&
+ ! "$H" "$WORK/invalid-'"$invalid"'" staged >"$WORK/invalid.out" &&
+ unchanged invalid-'"$invalid"'
+ '
+done
+
+test_done
diff --git a/testing/functional/image/t5100-verity-stage.py b/testing/functional/image/t5100-verity-stage.py
new file mode 100755
index 00000000..cdbe39d6
--- /dev/null
+++ b/testing/functional/image/t5100-verity-stage.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+import importlib.util
+from pathlib import Path
+import subprocess
+
+
+spec = importlib.util.spec_from_file_location(
+ "boot_signers", Path(__file__).with_name("t5101-verity-boot-signers.py"))
+boot = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(boot)
+config = boot.config
+require = config.require
+candidate = config.IMAGES / "config-live-new-key"
+
+
+def active(snapshot):
+ snapshot["journal"].pop("next-boot", None)
+ snapshot["status"].pop("next_boot_root_hash", None)
+ return snapshot
+
+
+before = config.snapshot("stage-before")
+keys_before = boot.keyring()
+require(before["status"]["next_boot_root_hash"] is None,
+ "test started with an existing staged selection")
+config.run("stage-live-refused", "image", "update", candidate, success=False)
+require(before == config.snapshot("stage-live-refused-after"),
+ "refusing live signer enrollment changed the current selection")
+config.run("stage", "image", "stage", candidate)
+staged = config.snapshot("stage-after")
+require(staged["status"]["next_boot_root_hash"] == config.root(candidate.name),
+ "status does not name the staged config")
+require("next-boot" in staged["journal"], "staged selection is not durable")
+require(active(staged) == active(before),
+ "staging changed a live mount, key set, measurement or config history")
+require(boot.keyring() == keys_before, "staging enrolled a key during this boot")
+result = subprocess.run([config.BINARY, "init"], capture_output=True, text=True,
+ timeout=120)
+(config.RESULTS / "stage-init.stdout").write_text(result.stdout)
+(config.RESULTS / "stage-init.stderr").write_text(result.stderr)
+require(result.returncode in (0, 1), f"unexpected init result: {result}")
+after_init = config.snapshot("stage-init-after")
+require(after_init["status"]["next_boot_root_hash"] == config.root(candidate.name),
+ "same-boot init consumed the staged config")
+require(active(after_init) == active(before),
+ "same-boot init activated or measured the staged config")
+require(boot.keyring() == keys_before, "same-boot init enrolled the staged signer")
+config.run("stage-cancel", "image", "stage", "--cancel")
+config.run("stage-cancel-again", "image", "stage", "--cancel")
+after_cancel = config.snapshot("stage-cancel-after")
+require(after_cancel["status"]["next_boot_root_hash"] is None,
+ "cancel did not remove the staged config")
+require(active(after_cancel) == active(before),
+ "canceling changed a live mount, key set or measurement")
+require(boot.keyring() == keys_before, "canceling changed the BPF key set")
diff --git a/testing/functional/image/t5100-verity-stage.sh b/testing/functional/image/t5100-verity-stage.sh
new file mode 100755
index 00000000..49b3b742
--- /dev/null
+++ b/testing/functional/image/t5100-verity-stage.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")/../.."
+. ./integration-lib.sh
+target_guard
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT HUP INT TERM
+export SHIRUDO_BIN
+
+test_expect_success 'staging a new BPF signer leaves this boot unchanged until canceled' '
+ python3 functional/image/t5100-verity-stage.py stage "$work"
+'
+
+test_done
diff --git a/testing/functional/image/t5101-verity-boot-signers.py b/testing/functional/image/t5101-verity-boot-signers.py
index 6f8cd631..899aac73 100644
--- a/testing/functional/image/t5101-verity-boot-signers.py
+++ b/testing/functional/image/t5101-verity-boot-signers.py
@@ -110,6 +110,17 @@ def config_keyring():
require(0 < length <= len(buffer) and length % 4 == 0,
"dm-verity keyring has no boot certificate")
before = buffer.raw[:length]
+ members = {key: describe(key) for (key,) in struct.iter_unpack("=i", before)}
+ expected = {certificate_description(FIXTURES / name)
+ for name in ("config-c.der", "config-d.der")}
+ require(len(expected) == 2 and
+ {fields[4] for fields in members.values()} == expected,
+ f"wrong config verification keys: {members}")
+ for key in members:
+ expect_error(errno.EACCES, KEYCTL, 2, key, 0, 0, 0) # REVOKE
+ expect_error(errno.EACCES, KEYCTL, 21, key, 0, 0, 0) # INVALIDATE
+ expect_error(errno.EACCES, KEYCTL, 5, key, 0, 0, 0) # SETPERM
+ expect_error(errno.EACCES, KEYCTL, 9, key, special, 0, 0) # UNLINK
live = certificate_description(FIXTURES / "live.der")
require(all(describe(key)[4] != live for (key,) in
struct.iter_unpack("=i", before)),
diff --git a/testing/functional/image/t5102-verity-config.py b/testing/functional/image/t5102-verity-config.py
index 43be47dd..9e9e2891 100644
--- a/testing/functional/image/t5102-verity-config.py
+++ b/testing/functional/image/t5102-verity-config.py
@@ -209,14 +209,34 @@ def main():
after = snapshot(mode + "-after")
differences = [key for key in before if before[key] != after[key]]
require(not differences, f"{mode} changed state: {differences}")
+ elif mode == "config-keys":
+ public = Path(os.environ["SHIRUDO_TEST_KEY_FIXTURES"])
+ status = json.loads(run("config-keys", "status", "--json"))
+ keys = status["dm_verity_keyring"]
+ expected = {hashlib.sha256((public / name).read_bytes()).hexdigest()
+ for name in ("config-c.der", "config-d.der")}
+ require(len(expected) == 2, "config key fixtures are not distinct")
+ require({cert["sha256"] for cert in keys["certs"]} == expected,
+ "runtime did not enroll both designated config certificates")
+ require(keys["other_links"] == [] and keys["serial_matches"], keys)
+ require(all(cert["frozen"] and cert["config"] and cert["key_serial"]
+ for cert in keys["certs"]), keys)
+ elif mode == "untrusted":
+ before = snapshot("untrusted-before")
+ run("untrusted-update", "image", "update", IMAGES / "config-untrusted",
+ success=False)
+ after = snapshot("untrusted-after")
+ require(before == after, "unapproved signer changed config state")
elif mode == "builtin":
before = snapshot("builtin-before")
public = Path(os.environ["SHIRUDO_TEST_KEY_FIXTURES"])
require((public / "builtin.der").read_bytes() !=
(RUNTIME / "etc/shirudo/config-cert.der").read_bytes(),
"built-in certificate duplicates the boot-enrolled config certificate")
- run("builtin-update", "image", "update", IMAGES / "config-builtin")
- changed(before, snapshot("builtin-after"), "config-builtin")
+ run("builtin-update", "image", "update", IMAGES / "config-builtin",
+ success=False)
+ after = snapshot("builtin-after")
+ require(before == after, "non-designated signer changed config state")
elif mode in ("corrupt-data", "corrupt-hash", "corrupt-root", "corrupt-signature"):
before = snapshot(mode + "-before")
with tempfile.TemporaryDirectory(prefix="shirudo-image-") as directory:
diff --git a/testing/functional/image/t5102-verity-config.sh b/testing/functional/image/t5102-verity-config.sh
index 12f04c01..a233d8b1 100755
--- a/testing/functional/image/t5102-verity-config.sh
+++ b/testing/functional/image/t5102-verity-config.sh
@@ -13,7 +13,7 @@ target_guard
mountpoint -q /run/shirudo/runtime && mountpoint -q /run/shirudo/config ||
verity_required "dm-verity image mode is not active"
command -v python3 >/dev/null 2>&1 || verity_required "no python3"
-for name in config-a config-b config-bad; do
+for name in config-a config-b config-bad config-untrusted; do
for suffix in img verity roothash p7s; do
[ -r "/var/lib/shirudo/images/$name.$suffix" ] ||
verity_required "missing signed CONFIG fixture: $name.$suffix"
@@ -34,6 +34,14 @@ test_expect_success 'current CONFIG and PCR evidence verify' '
python3 functional/image/t5102-verity-config.py initial "$work"
'
+test_expect_success 'both config certificates are enrolled and frozen' '
+ python3 functional/image/t5102-verity-config.py config-keys "$work"
+'
+
+test_expect_success 'a config signed by an unapproved certificate leaves state unchanged' '
+ python3 functional/image/t5102-verity-config.py untrusted "$work"
+'
+
test_expect_success 'trusted caller without a root nomination gets no CONFIG classification' '
python3 functional/image/t5102-verity-config.py root-missing "$work"
'
@@ -47,7 +55,7 @@ test_expect_success 'exact root nomination classifies CONFIG once and is cleared
'
if [ -f "$SHIRUDO_TEST_KEY_FIXTURES/builtin.der" ]; then
- test_expect_success 'kernel built-in certificate accepts a signed config root' '
+ test_expect_success 'kernel built-in trust alone cannot authorize a config signer' '
python3 functional/image/t5102-verity-config.py builtin "$work"
'
else
@@ -63,12 +71,12 @@ test_expect_success 'hash padding corruption fails before PCR or journal changes
python3 functional/image/t5102-verity-config.py corrupt-hash "$work"
'
-test_expect_success 'kernel rejects a modified root or detached root signature' '
+test_expect_success 'a modified root or detached root signature is rejected' '
python3 functional/image/t5102-verity-config.py corrupt-root "$work" &&
python3 functional/image/t5102-verity-config.py corrupt-signature "$work"
'
-test_expect_success 'live CONFIG A to B extends PCR once and replaces config' '
+test_expect_success 'config signed by the second key extends PCR once and replaces config' '
python3 functional/image/t5102-verity-config.py update "$work"
'
diff --git a/testing/functional/signing/t2003-keys-set.sh b/testing/functional/signing/t2003-keys-set.sh
index 3eba7571..1022aa0b 100755
--- a/testing/functional/signing/t2003-keys-set.sh
+++ b/testing/functional/signing/t2003-keys-set.sh
@@ -55,6 +55,27 @@ test_expect_success 'the set digest is order-free and attest predict agrees' '
[ "$p1" != "$p3" ]
'
+test_expect_success 'either active key verifies an exact detached signature' '
+ python3 - "$W/c/cert.der" "$W/payload" <<"PYTEST" &&
+from pathlib import Path
+import sys
+Path(sys.argv[2]).write_bytes(b"shirudo-key-vouch\0" + Path(sys.argv[1]).read_bytes())
+PYTEST
+ $SHB keys vouch "$W/c/cert.der" --keys-dir "$W/a" -o "$W/signed-a" >/dev/null &&
+ $SHB keys vouch "$W/c/cert.der" --keys-dir "$W/b" -o "$W/signed-b" >/dev/null &&
+ ./$H verify-signature "$W/keys" "$W/payload" "$W/signed-a" >"$W/verified-a" &&
+ ./$H verify-signature "$W/keys" "$W/payload" "$W/signed-b" >"$W/verified-b" &&
+ grep -qx "$(../shirudo bpm key fingerprint "$W/a/cert.der")" "$W/verified-a" &&
+ grep -qx "$fp_b" "$W/verified-b"
+'
+
+test_expect_success 'a valid signature from outside the active key set is rejected' '
+ mkdir "$W/primary-only" && cp "$W/a/cert.der" "$W/primary-only/cert.der" &&
+ ! ./$H verify-signature "$W/primary-only" "$W/payload" "$W/signed-b" &&
+ cp "$W/payload" "$W/changed-payload" && printf changed >>"$W/changed-payload" &&
+ ! ./$H verify-signature "$W/keys" "$W/changed-payload" "$W/signed-b"
+'
+
test_expect_success 'a revoked certificate is left out of the set' '
cp "$W/c/cert.der" "$W/keys/revoked/$fp_c.der" &&
./$H load "$W/keys" >"$W/set2" &&
@@ -87,5 +108,12 @@ test_expect_success 'image revocation preserves historical vouches while excludi
! grep -q "^$(sha "$W/b/cert.der") " "$W/image-set"
'
+test_expect_success 'revoking A leaves B signatures valid and refuses earlier A signatures' '
+ rm "$W/keys/revoked/$fp_b.der" &&
+ ./$H verify-signature "$W/keys" "$W/payload" "$W/signed-b" >"$W/remaining" &&
+ grep -qx "$fp_b" "$W/remaining" &&
+ ! ./$H verify-signature "$W/keys" "$W/payload" "$W/signed-a"
+'
+
test_done
diff --git a/testing/functional/signing/t2101-keys.sh b/testing/functional/signing/t2101-keys.sh
index 99ad4312..bf03856d 100755
--- a/testing/functional/signing/t2101-keys.sh
+++ b/testing/functional/signing/t2101-keys.sh
@@ -5,7 +5,7 @@
# t2101 -- the enrolled certificate set: the bundle's own-keyring
# certificate was installed as a second trusted certificate before
# init, so the bpf keyring holds two keys, keys lists them and the
-# dm-verity keyring's config key as init froze them, and a upatch signed
+# dm-verity keyring's two config keys as init froze them, and a upatch signed
# by either loads.
cd "$(dirname "$0")/../.."
@@ -58,7 +58,7 @@ test_expect_success 'keys lists both keyrings, every member frozen' '
python3 - "$W/keys" <<"PY"
import re, subprocess, sys
text = open(sys.argv[1], encoding="utf-8").read()
-for label, members in ((".bpf", 2), (".dm-verity", 1)):
+for label, members in ((".bpf", 2), (".dm-verity", 2)):
section = text.split("Keyring (%s):\n" % label, 1)[1].split("\n\n", 1)[0]
ring = int(re.search(r"^ Serial: +(\d+)$", section, re.M).group(1))
assert re.search(r"^ Frozen serial: +%d \(matches\)$" % ring, section,
diff --git a/testing/functional/tamperproof/t6004-conditions.sh b/testing/functional/tamperproof/t6004-conditions.sh
index 3f87a67d..5e73db70 100755
--- a/testing/functional/tamperproof/t6004-conditions.sh
+++ b/testing/functional/tamperproof/t6004-conditions.sh
@@ -69,7 +69,7 @@ test_expect_success 'a config key that is gone is tampered' '
out=$(SHIRUDO_TEST_DMV_KEY=missing ./$H 1 bpf 100 100 match) &&
echo "$out" | grep -qx "status=tampered" &&
echo "$out" | grep -qx "reason=the config key init froze is gone" &&
- echo "$out" | grep -qx "KeyringSealed ALERT the config key init froze is gone from the dm-verity keyring"
+ echo "$out" | grep -qx "KeyringSealed ALERT a config key init froze is gone from the dm-verity keyring"
'
test_expect_success 'a bpf keyring swap is reported before the dm-verity state' '
diff --git a/testing/functional/tamperproof/t6112-key-permission.sh b/testing/functional/tamperproof/t6112-key-permission.sh
index d667d203..148ba4cd 100755
--- a/testing/functional/tamperproof/t6112-key-permission.sh
+++ b/testing/functional/tamperproof/t6112-key-permission.sh
@@ -19,22 +19,53 @@ case "$RING" in
esac
KEYS=$(keyctl rlist "$RING" 2>/dev/null)
[ -n "$KEYS" ] || test_skip_all "cannot list the anchor keyring $RING"
-KEY=$(set -- $KEYS; echo "$1")
N_BEFORE=$(set -- $KEYS; echo $#)
keys_now() { set -- $(keyctl rlist "$RING" 2>/dev/null); echo $#; }
W=$(mktemp -d)
trap 'rm -rf "$W"' EXIT
-test_expect_success 'the anchor keyring and its keys are visible' '
+bpf_keys_visible()
+{
+ for bpf_key in $KEYS; do
+ keyctl describe "$bpf_key" >/dev/null || return 1
+ keyctl rlist "$RING" | grep -qw "$bpf_key" || return 1
+ grep -q "^0*$(printf %08x "$bpf_key") " /proc/keys || return 1
+ done
+}
+
+bpf_keys_unlink_protected()
+{
+ for bpf_key in $KEYS; do
+ ! keyctl unlink "$bpf_key" "$RING" 2>"$W/err" || return 1
+ grep -qi "permission denied" "$W/err" || return 1
+ done
+}
+
+bpf_keys_revoke_protected()
+{
+ for bpf_key in $KEYS; do
+ ! keyctl revoke "$bpf_key" 2>/dev/null || return 1
+ ! keyctl invalidate "$bpf_key" 2>/dev/null || return 1
+ keyctl describe "$bpf_key" >/dev/null || return 1
+ done
+}
+
+bpf_keys_permissions_protected()
+{
+ for bpf_key in $KEYS; do
+ ! keyctl setperm "$bpf_key" 0x3f3f3f3f 2>/dev/null || return 1
+ ! keyctl timeout "$bpf_key" 1 2>/dev/null || return 1
+ ! keyctl chown "$bpf_key" 1 2>/dev/null || return 1
+ done
+}
+
+test_expect_success 'the anchor keyring and all its keys are visible' '
keyctl describe "$RING" >/dev/null &&
- keyctl describe "$KEY" >/dev/null &&
- keyctl rlist "$RING" | grep -q "$KEY" &&
- grep -q "^0*$(printf %08x "$KEY") " /proc/keys
+ bpf_keys_visible
'
-test_expect_success 'root cannot unlink a key from the anchor keyring' '
- ! keyctl unlink "$KEY" "$RING" 2>"$W/err" &&
- grep -qi "permission denied" "$W/err" &&
+test_expect_success 'root cannot unlink any key from the anchor keyring' '
+ bpf_keys_unlink_protected &&
[ "$(keys_now)" = "$N_BEFORE" ]
'
@@ -43,21 +74,17 @@ test_expect_success 'root cannot clear the anchor keyring' '
[ "$(keys_now)" = "$N_BEFORE" ]
'
-test_expect_success 'root cannot revoke or invalidate a key' '
- ! keyctl revoke "$KEY" 2>/dev/null &&
- ! keyctl invalidate "$KEY" 2>/dev/null &&
+test_expect_success 'root cannot revoke or invalidate any key' '
+ bpf_keys_revoke_protected &&
! keyctl invalidate "$RING" 2>/dev/null &&
- keyctl describe "$KEY" >/dev/null &&
[ "$(keys_now)" = "$N_BEFORE" ]
'
-test_expect_success 'root cannot change the permissions or the timeout' '
- ! keyctl setperm "$KEY" 0x3f3f3f3f 2>/dev/null &&
+test_expect_success 'root cannot change any key permissions or timeout' '
+ bpf_keys_permissions_protected &&
! keyctl setperm "$RING" 0x3f3f3f3f 2>/dev/null &&
- ! keyctl timeout "$KEY" 1 2>/dev/null &&
- ! keyctl chown "$KEY" 1 2>/dev/null &&
sleep 2 &&
- keyctl describe "$KEY" >/dev/null
+ bpf_keys_visible
'
test_expect_success 'root cannot link a key into the anchor keyring' '
@@ -69,32 +96,53 @@ test_expect_success 'root cannot link a key into the anchor keyring' '
DM_RING=$(awk '$8 == "keyring" && $9 == ".dm-verity:" { print $1 }' /proc/keys)
[ -n "$DM_RING" ] && DM_RING=$((0x$DM_RING))
-DM_KEY=$([ -n "$DM_RING" ] && keyctl rlist "$DM_RING" 2>/dev/null)
+DM_KEYS=$([ -n "$DM_RING" ] && keyctl rlist "$DM_RING" 2>/dev/null)
dm_keys_now() { set -- $(keyctl rlist "$DM_RING" 2>/dev/null); echo $#; }
-test_expect_success 'the dm-verity keyring holds the config key alone' '
- [ -n "$DM_RING" ] && [ -n "$DM_KEY" ] &&
- [ "$(dm_keys_now)" = 1 ] &&
- keyctl rdescribe "$DM_KEY" | grep -q "^asymmetric;"
+dm_keys_describe()
+{
+ for dm_key in $DM_KEYS; do
+ keyctl rdescribe "$dm_key" | grep -q "^asymmetric;" || return 1
+ done
+}
+
+dm_keys_protected()
+{
+ for dm_key in $DM_KEYS; do
+ ! keyctl unlink "$dm_key" "$DM_RING" 2>/dev/null || return 1
+ ! keyctl revoke "$dm_key" 2>/dev/null || return 1
+ ! keyctl invalidate "$dm_key" 2>/dev/null || return 1
+ keyctl describe "$dm_key" >/dev/null || return 1
+ done
+}
+
+dm_keys_permissions_protected()
+{
+ for dm_key in $DM_KEYS; do
+ ! keyctl setperm "$dm_key" 0x3f3f3f3f 2>/dev/null || return 1
+ ! keyctl timeout "$dm_key" 1 2>/dev/null || return 1
+ done
+}
+
+test_expect_success 'the dm-verity keyring holds both config keys' '
+ [ -n "$DM_RING" ] && [ -n "$DM_KEYS" ] &&
+ [ "$(dm_keys_now)" = 2 ] &&
+ dm_keys_describe
'
-test_expect_success 'root cannot unlink, clear, revoke or invalidate it' '
- [ -n "$DM_RING" ] && [ -n "$DM_KEY" ] &&
- ! keyctl unlink "$DM_KEY" "$DM_RING" 2>/dev/null &&
+test_expect_success 'root cannot unlink, clear, revoke or invalidate either key' '
+ [ -n "$DM_RING" ] && [ -n "$DM_KEYS" ] &&
+ dm_keys_protected &&
! keyctl clear "$DM_RING" 2>/dev/null &&
- ! keyctl revoke "$DM_KEY" 2>/dev/null &&
! keyctl revoke "$DM_RING" 2>/dev/null &&
- ! keyctl invalidate "$DM_KEY" 2>/dev/null &&
! keyctl invalidate "$DM_RING" 2>/dev/null &&
- keyctl describe "$DM_KEY" >/dev/null &&
- [ "$(dm_keys_now)" = 1 ]
+ [ "$(dm_keys_now)" = 2 ]
'
-test_expect_success 'root cannot re-permission it or link into it' '
- [ -n "$DM_RING" ] && [ -n "$DM_KEY" ] &&
- ! keyctl setperm "$DM_KEY" 0x3f3f3f3f 2>/dev/null &&
+test_expect_success 'root cannot change either key or link into the keyring' '
+ [ -n "$DM_RING" ] && [ -n "$DM_KEYS" ] &&
+ dm_keys_permissions_protected &&
! keyctl setperm "$DM_RING" 0x3f3f3f3f 2>/dev/null &&
- ! keyctl timeout "$DM_KEY" 1 2>/dev/null &&
! keyctl timeout "$DM_RING" 1 2>/dev/null &&
! keyctl chown "$DM_RING" 1 2>/dev/null &&
k=$(keyctl add user shirudo-test-t6112 x @s) &&
@@ -102,7 +150,8 @@ test_expect_success 'root cannot re-permission it or link into it' '
keyctl unlink "$k" @s &&
sleep 2 &&
keyctl describe "$DM_RING" >/dev/null &&
- [ "$(dm_keys_now)" = 1 ]
+ dm_keys_describe &&
+ [ "$(dm_keys_now)" = 2 ]
'
test_expect_success 'status still finds the anchor it froze' '
diff --git a/testing/functional/tamperproof/t6140-status-keyrings.sh b/testing/functional/tamperproof/t6140-status-keyrings.sh
index d0e575fd..baf430a9 100644
--- a/testing/functional/tamperproof/t6140-status-keyrings.sh
+++ b/testing/functional/tamperproof/t6140-status-keyrings.sh
@@ -24,7 +24,7 @@ esac
DM_RING=$(awk '$8 == "keyring" && $9 == ".dm-verity:" { print $1 }' /proc/keys)
[ -n "$DM_RING" ] || test_skip_all "no dm-verity keyring"
DM_RING=$((0x$DM_RING))
-CONFIG_CERT=/run/shirudo/runtime/etc/shirudo/config-cert.der
+RUNTIME_CONF=/run/shirudo/runtime/etc/shirudo/shirudo.conf
test_expect_success 'both keyrings are the ones init froze, with nothing added' '
python3 - "$W/status.json" "$RING" "$DM_RING" <<"PY"
@@ -62,21 +62,26 @@ for c in bpf["certs"]:
assert c["frozen"] is (True if c["key_serial"] else None), c
assert c["subject"] and c["algorithm"] and c["not_before"], c
dmv = d["dm_verity_keyring"]
-assert len(dmv["certs"]) == 1, dmv["certs"]
-c = dmv["certs"][0]
-assert c["config"] and c["frozen"] is True, c
-assert [c["key_serial"]] == links(sys.argv[3]), (c, links(sys.argv[3]))
+assert dmv["certs"], dmv["certs"]
+for c in dmv["certs"]:
+ assert c["config"] and c["frozen"] is True, c
+held = sorted(c["key_serial"] for c in dmv["certs"])
+assert held == links(sys.argv[3]), (held, links(sys.argv[3]))
PY
'
-test_expect_success 'the config certificate is the one the runtime image carries' '
- [ -s "$CONFIG_CERT" ] &&
- python3 - "$W/status.json" "$CONFIG_CERT" <<"PY"
+test_expect_success 'config certificates are the exact set the runtime image designates' '
+ [ -s "$RUNTIME_CONF" ] &&
+ python3 - "$W/status.json" "$RUNTIME_CONF" <<"PY"
import hashlib, json, sys
+from pathlib import Path
d = json.load(open(sys.argv[1], encoding="utf-8"))
-with open(sys.argv[2], "rb") as stream:
- digest = hashlib.sha256(stream.read()).hexdigest()
-assert d["dm_verity_keyring"]["certs"][0]["sha256"] == digest, digest
+paths = [line.split("=", 1)[1].strip()
+ for line in Path(sys.argv[2]).read_text().splitlines()
+ if line.split("=", 1)[0].strip() == "config.verification_key"]
+expected = {hashlib.sha256(Path(path).read_bytes()).hexdigest() for path in paths}
+actual = {cert["sha256"] for cert in d["dm_verity_keyring"]["certs"]}
+assert expected and len(expected) == len(paths) and expected == actual, (expected, actual)
PY
'
diff --git a/testing/fuzz/corpus/image/config-key-capacity b/testing/fuzz/corpus/image/config-key-capacity
new file mode 100644
index 00000000..1c1ad731
--- /dev/null
+++ b/testing/fuzz/corpus/image/config-key-capacity
@@ -0,0 +1,17 @@
+config.verification_key = /run/shirudo/runtime/keys/config-0.der
+config.verification_key = /run/shirudo/runtime/keys/config-1.der
+config.verification_key = /run/shirudo/runtime/keys/config-2.der
+config.verification_key = /run/shirudo/runtime/keys/config-3.der
+config.verification_key = /run/shirudo/runtime/keys/config-4.der
+config.verification_key = /run/shirudo/runtime/keys/config-5.der
+config.verification_key = /run/shirudo/runtime/keys/config-6.der
+config.verification_key = /run/shirudo/runtime/keys/config-7.der
+config.verification_key = /run/shirudo/runtime/keys/config-8.der
+config.verification_key = /run/shirudo/runtime/keys/config-9.der
+config.verification_key = /run/shirudo/runtime/keys/config-10.der
+config.verification_key = /run/shirudo/runtime/keys/config-11.der
+config.verification_key = /run/shirudo/runtime/keys/config-12.der
+config.verification_key = /run/shirudo/runtime/keys/config-13.der
+config.verification_key = /run/shirudo/runtime/keys/config-14.der
+config.verification_key = /run/shirudo/runtime/keys/config-15.der
+config.verification_key = /run/shirudo/runtime/keys/config-16.der
diff --git a/testing/fuzz/corpus/image/config-key-duplicate b/testing/fuzz/corpus/image/config-key-duplicate
new file mode 100644
index 00000000..0c73d63a
--- /dev/null
+++ b/testing/fuzz/corpus/image/config-key-duplicate
@@ -0,0 +1,2 @@
+config.verification_key = /run/shirudo/runtime/keys/config-A.der
+config.verification_key = /run/shirudo/runtime/keys/config-A.der
diff --git a/testing/fuzz/corpus/image/config-key-overlap b/testing/fuzz/corpus/image/config-key-overlap
new file mode 100644
index 00000000..1831cc01
--- /dev/null
+++ b/testing/fuzz/corpus/image/config-key-overlap
@@ -0,0 +1,2 @@
+config.verification_key = /run/shirudo/runtime/keys/config-A.der
+config.verification_key = /run/shirudo/runtime/keys/config-B.der
diff --git a/testing/fuzz/fuzz-config-update.c b/testing/fuzz/fuzz-config-update.c
index 72424169..ab81b2d1 100644
--- a/testing/fuzz/fuzz-config-update.c
+++ b/testing/fuzz/fuzz-config-update.c
@@ -22,6 +22,7 @@ static int dir_fd = -1;
static void remove_dir(void)
{
unlinkat(dir_fd, "events", 0);
+ unlinkat(dir_fd, "next-boot", 0);
rmdir(dir);
}
@@ -58,5 +59,12 @@ int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
close(fd);
events_scan(&update, &last, value, NULL, false, NULL, NULL);
events_scan(&update, &last, value, NULL, true, NULL, NULL);
+ fd = openat(dir_fd, "next-boot", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
+ 0600);
+ if (fd < 0)
+ return 0;
+ if (!write_complete(fd, data, size))
+ config_update_stage_read(&update, &record);
+ close(fd);
return 0;
}
diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.c
index ab65e6dc..c10a75fe 100644
--- a/testing/helper/test-config-update.c
+++ b/testing/helper/test-config-update.c
@@ -37,6 +37,7 @@ struct test_context {
struct simulated_tpm sim;
struct tpm *tpm;
const char *directory;
+ bool staging;
};
static int simulator_save(struct test_context *ctx)
@@ -195,6 +196,10 @@ static int test_activate(void *opaque,
static int test_seal(void *opaque, int fd)
{
+ struct test_context *ctx = opaque;
+
+ if (ctx->staging && getenv("SHIRUDO_TEST_CONFIG_STAGE_CRASH"))
+ _exit(99);
return getenv("SHIRUDO_TEST_CONFIG_SEAL_FAIL") ? -EPERM : 0;
}
@@ -271,6 +276,11 @@ static void inspect(struct test_context *ctx)
hex_encode(record.target.root_hash, 32, hex);
printf("root_hash=%s\n", hex);
}
+ ret = config_update_stage_read(ctx->update, &record);
+ printf("stage_rc=%d\n", ret);
+ if (!ret)
+ printf("stage_prefix=%s\nstage_sequence=%llu\n",
+ record.target.prefix, (__u64)record.sequence);
ret = config_update_events(ctx->update, show_event, &count);
printf("events_rc=%d\nevents=%u\n", ret, count);
}
@@ -331,6 +341,24 @@ int main(int argc, char **argv)
ret = config_update_complete_boot(&update);
} else if (!strcmp(argv[2], "update")) {
ret = config_update_begin(&update, &target, pcr);
+ } else if (!strcmp(argv[2], "stage")) {
+ ctx.staging = true;
+ ret = config_update_stage(&update, &target);
+ } else if (!strcmp(argv[2], "cancel-stage")) {
+ ret = config_update_clear_staged(&update);
+ } else if (!strcmp(argv[2], "staged")) {
+ struct config_update_record previous;
+
+ ret = config_update_read(&update, &previous);
+ if (!ret)
+ ret = config_update_staged(&update, &previous,
+ ctx.sim.reset_count,
+ ctx.sim.restart_count, &target);
+ printf("eligible=%d\n", ret);
+ if (ret == 1) {
+ printf("candidate=%s\n", target.prefix);
+ ret = 0;
+ }
} else if (!strcmp(argv[2], "complete")) {
ret = config_update_complete_boot(&update);
} else if (!strcmp(argv[2], "check")) {
diff --git a/testing/helper/test-image-config.c b/testing/helper/test-image-config.c
index c6a07811..003ad98f 100644
--- a/testing/helper/test-image-config.c
+++ b/testing/helper/test-image-config.c
@@ -16,6 +16,7 @@ static int read_bootstrap(int argc, char **argv)
{
struct image_bootstrap boot = {};
char root[65];
+ size_t i;
int ret;
ret = image_bootstrap_read(argv[2], &boot, true);
@@ -23,9 +24,11 @@ static int read_bootstrap(int argc, char **argv)
ret = image_bootstrap_read(argv[3], &boot, false);
if (!ret) {
hex_encode(boot.runtime_root, 32, root);
- printf("runtime=%s\nroot=%s\nconfig=%s\ncertificate=%s\npcr=%u\n",
- boot.runtime, root, boot.config, boot.certificates[0],
- boot.pcr);
+ printf("runtime=%s\nroot=%s\nconfig=%s\npcr=%u\n",
+ boot.runtime, root, boot.config, boot.pcr);
+ printf("certificates=%zu\n", boot.n_certificates);
+ for (i = 0; i < boot.n_certificates; i++)
+ printf("certificate=%s\n", boot.certificates[i]);
}
printf("rc=%d\n", ret);
return ret ? 1 : 0;
diff --git a/testing/helper/test-keys.c b/testing/helper/test-keys.c
index 27a3e8f5..c8778394 100644
--- a/testing/helper/test-keys.c
+++ b/testing/helper/test-keys.c
@@ -19,6 +19,8 @@
#include "crypto.h"
#include "hex.h"
#include "keys.h"
+#include "io.h"
+#include "malloc.h"
#include "upatch.h"
static void puthex(const __u8 *b, size_t n)
@@ -29,6 +31,38 @@ static void puthex(const __u8 *b, size_t n)
puts(h);
}
+static noinline_for_stack int verify_signature(const char *directory,
+ const char *payload_path,
+ const char *signature_path)
+{
+ struct trusted_set set;
+ __u8 *payload = NULL, *signature = NULL;
+ size_t payload_sz = 0, signature_sz = 0;
+ __u8 signer[32];
+ char primary[PATH_MAX];
+ int root, ret;
+
+ snprintf(primary, sizeof(primary), "%s/cert.der", directory);
+ root = open(directory, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (root < 0)
+ return 1;
+ ret = keys_load_image_at(primary, root, true, &set);
+ close(root);
+ if (!ret)
+ ret = read_file(payload_path, 1024 * 1024, &payload, &payload_sz);
+ if (!ret)
+ ret = read_file(signature_path, 65536, &signature, &signature_sz);
+ if (!ret)
+ ret = keys_verify_signature(&set, payload, payload_sz, signature,
+ signature_sz, signer);
+ if (!ret)
+ puthex(signer, sizeof(signer));
+ xfree(payload, payload_sz + 1);
+ xfree(signature, signature_sz + 1);
+ printf("rc=%d\n", ret);
+ return ret ? 1 : 0;
+}
+
int main(int argc, char **argv)
{
struct trusted_set set;
@@ -42,6 +76,8 @@ int main(int argc, char **argv)
" | signer <upatch> <cert.der>\n", argv[0]);
return 2;
}
+ if (!strcmp(argv[1], "verify-signature"))
+ return argc == 5 ? verify_signature(argv[2], argv[3], argv[4]) : 2;
if (strcmp(argv[1], "signer") == 0) {
struct cert cert = {};
struct upatch u;
diff --git a/testing/proofs/cbmc/bpm-tree-signers.c b/testing/proofs/cbmc/bpm-tree-signers.c
new file mode 100644
index 00000000..eab58f3f
--- /dev/null
+++ b/testing/proofs/cbmc/bpm-tree-signers.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2026 Authors of shirudo
+ *
+ * Prove that tree_fetch_publication() checks the active image's signing set
+ * before fetching a tree, and releases the set on every path that allocates it.
+ */
+
+#define __NO_CTYPE 1
+
+#include <dirent.h>
+#include <ftw.h>
+#include <sys/file.h>
+#include <zlib.h>
+#include <curl/curl.h>
+#include <openssl/bio.h>
+#include <openssl/evp.h>
+#include <openssl/pem.h>
+#include <openssl/x509.h>
+
+#include "proof.h"
+#include "../../../builtin-bpm.c"
+
+static struct trusted_set signing_set;
+static bool active, parse_fail, alloc_fail, load_fail, check_fail, fetch_fail;
+static bool allocated, loaded, checked, fetched, freed;
+static __u32 n_signers, n_unvouched;
+
+int bpm_oci_parse_tree_repo(const char *raw, struct bpm_oci_client *c,
+ char *repository, size_t repository_sz)
+{
+ __CPROVER_assert(raw[0] == 'e' && repository_sz >= 2,
+ "the configured tree endpoint is parsed");
+ if (parse_fail)
+ return -EINVAL;
+ repository[0] = 'r';
+ repository[1] = '\0';
+ return 0;
+}
+
+void bpm_oci_client_clear(struct bpm_oci_client *c)
+{
+}
+
+bool image_config_active(void)
+{
+ return active;
+}
+
+void *xcalloc(size_t nmemb, size_t size)
+{
+ __CPROVER_assert(nmemb == 1 && size == sizeof(signing_set),
+ "the active signing set is allocated");
+ if (alloc_fail)
+ return NULL;
+ allocated = true;
+ return &signing_set;
+}
+
+const char *get_cert_path(void)
+{
+ return "cert";
+}
+
+int image_config_root_fd(void)
+{
+ return 7;
+}
+
+int keys_load_image_root(const char *primary, int root_fd,
+ bool with_trusted, struct trusted_set *set)
+{
+ __CPROVER_assert(active && allocated && set == &signing_set &&
+ !strcmp(primary, "cert") && root_fd == 7 &&
+ with_trusted, "the image root supplies the complete set");
+ loaded = true;
+ set->n = n_signers;
+ set->n_unvouched = n_unvouched;
+ return load_fail ? -EIO : 0;
+}
+
+int keys_check_image_set(const struct trusted_set *set)
+{
+ __CPROVER_assert(loaded && !load_fail && set == &signing_set &&
+ set->n && !set->n_unvouched,
+ "only a nonempty vouched set is checked");
+ checked = true;
+ return check_fail ? -EKEYREJECTED : 0;
+}
+
+int bpm_tree_fetch_publication(struct bpm_oci_client *c,
+ const char *repository, const char *reference,
+ const char *cert_path,
+ const struct trusted_set *set,
+ struct tree_publication *pub,
+ char *manifest_digest, size_t digest_sz)
+{
+ __CPROVER_assert(!parse_fail && repository[0] == 'r' &&
+ reference[0] == 'f' && !strcmp(cert_path, "cert") &&
+ digest_sz == BPM_MAX_DIGEST,
+ "fetch uses the configured tree and certificate");
+ __CPROVER_assert(!active ||
+ (allocated && loaded && checked && !load_fail &&
+ !check_fail && n_signers && !n_unvouched),
+ "an active image is checked before fetch");
+ __CPROVER_assert(set == (active ? &signing_set : NULL),
+ "fetch receives the checked signing set");
+ fetched = true;
+ return fetch_fail ? -EIO : 0;
+}
+
+void xfree(void *p, size_t size)
+{
+ __CPROVER_assert(!freed && size == sizeof(signing_set) &&
+ p == (allocated ? &signing_set : NULL),
+ "the owned signing set is released once");
+ freed = true;
+}
+
+void harness(void)
+{
+ struct bpm_tree_config cfg = {};
+ struct tree_publication pub = {};
+ struct {
+ __u32 signers, unvouched;
+ bool active, parse_fail, alloc_fail;
+ bool load_fail, check_fail, fetch_fail;
+ } input;
+ char manifest[BPM_MAX_DIGEST] = {};
+ bool should_fetch, should_check, should_free;
+ int ret;
+
+ active = input.active;
+ parse_fail = input.parse_fail;
+ alloc_fail = input.alloc_fail;
+ load_fail = input.load_fail;
+ check_fail = input.check_fail;
+ fetch_fail = input.fetch_fail;
+ n_signers = input.signers;
+ n_unvouched = input.unvouched;
+ __CPROVER_assume(n_signers <= KEYS_MAX && n_unvouched <= n_signers);
+ cfg.endpoint[0] = 'e';
+ cfg.reference[0] = 'f';
+ ret = tree_fetch_publication(&cfg, &pub, manifest, sizeof(manifest));
+
+ should_check = !parse_fail && active && !alloc_fail &&
+ !load_fail && n_signers && !n_unvouched;
+ should_fetch = !parse_fail &&
+ (!active || (should_check && !check_fail));
+ __CPROVER_assert(loaded == (!parse_fail && active && !alloc_fail),
+ "image keys load only after allocation");
+ __CPROVER_assert(checked == should_check,
+ "a valid loaded set is always checked");
+ __CPROVER_assert(fetched == should_fetch,
+ "fetch occurs exactly after successful preflight");
+ should_free = !parse_fail && (!active || !alloc_fail);
+ __CPROVER_assert(freed == should_free,
+ "every allocated set is released");
+ if (!should_fetch)
+ __CPROVER_assert(ret < 0, "preflight failures refuse the tree");
+ else
+ __CPROVER_assert(ret == (fetch_fail ? -EIO : 0),
+ "fetch result is returned");
+ if (!parse_fail && active && !alloc_fail && !load_fail &&
+ (!n_signers || n_unvouched))
+ __CPROVER_assert(ret == -EKEYREJECTED,
+ "empty or unvouched signing sets are refused");
+}
diff --git a/testing/proofs/cbmc/image-bootstrap-certificates.c b/testing/proofs/cbmc/image-bootstrap-certificates.c
new file mode 100644
index 00000000..e205c9aa
--- /dev/null
+++ b/testing/proofs/cbmc/image-bootstrap-certificates.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/* Copyright (c) 2026 Authors of shirudo */
+
+#define PROOF_MEMCPY_BYTEWISE
+#include "proof.h"
+#include "../../../util/string.c"
+#include "../../../util/image_bootstrap.c"
+
+#ifndef LEN
+#define LEN KEYS_MAX
+#endif
+
+static struct image_bootstrap boot;
+
+void harness(void)
+{
+ char candidate[] = RUNTIME_DIR "/key-A";
+ char previous[] = RUNTIME_DIR "/key-A";
+ const char *path = candidate;
+ __u32 key, invalid;
+ const __u32 count = LEN;
+ size_t i;
+ int ret;
+
+ __CPROVER_assume(count <= KEYS_MAX && key <= KEYS_MAX && invalid <= 2);
+ boot.n_certificates = count;
+ for (i = 0; i < count; i++) {
+ previous[sizeof(previous) - 2] = (char)('A' + i);
+ memcpy(boot.certificates[i], previous, sizeof(previous));
+ }
+ candidate[sizeof(candidate) - 2] = (char)('A' + key);
+ if (invalid == 1)
+ path = "/outside/cert.der";
+ if (invalid == 2)
+ path = RUNTIME_DIR "/../cert.der";
+ ret = bootstrap_add_certificate(&boot, path);
+ if (invalid)
+ __CPROVER_assert(ret == -EPERM,
+ "certificates cannot escape the runtime");
+ else if (count == KEYS_MAX)
+ __CPROVER_assert(ret == -E2BIG, "a full set cannot grow");
+ else if (key < count)
+ __CPROVER_assert(ret == -EEXIST, "duplicate paths are refused");
+ else
+ __CPROVER_assert(!ret, "a distinct path can join a non-full set");
+ __CPROVER_assert(boot.n_certificates == count + (ret == 0),
+ "only a successful append changes the count");
+ __CPROVER_assert(boot.n_certificates <= KEYS_MAX,
+ "the set never exceeds its capacity");
+ for (i = 0; i < count; i++) {
+ previous[sizeof(previous) - 2] = (char)('A' + i);
+ __CPROVER_assert(!strcmp(boot.certificates[i], previous),
+ "earlier certificates keep their order and paths");
+ }
+ if (!ret)
+ __CPROVER_assert(!strcmp(boot.certificates[count], candidate),
+ "the new path is appended exactly once");
+}
diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.list
index 777df347..2877317f 100644
--- a/testing/proofs/cbmc/proofs.list
+++ b/testing/proofs/cbmc/proofs.list
@@ -27,6 +27,7 @@ string-number-model --unwind 6
measured-fold-model --unwind 7
bpm-tree-follows --unwind 4
bpm-tree-sync-model --object-bits 10 --unwind 60 --max-field-sensitivity-array-size 257 LEN=0-2
+bpm-tree-signers --unwind 8
bpm-upatch-member --unwind 30 LEN=0-18
tpm-reader --unwind 1
tpm-signature --unwind 1 --unwindset bytes_at.0:33
@@ -41,6 +42,7 @@ config-image --unwind 6 --unwindset memcmp.0:89,harness.0:33 LEN=0,511,512,4096
config-auth --unwind 18 LEN=0-16
config-hosts --unwind 9 LEN=0-7
config-update-follows --unwind 33
+image-bootstrap-certificates --unwind 64 --max-field-sensitivity-array-size 32 LEN=0-16
image-bootstrap --unwind 12 --unwindset bootstrap_parse.0:2,hex_decode.0:1 LEN=0-8
image-path --unwind 11
dm-names --unwind 10
diff --git a/testing/vm/bundle-images.sh b/testing/vm/bundle-images.sh
index 5d44d2b8..f40ca3ab 100755
--- a/testing/vm/bundle-images.sh
+++ b/testing/vm/bundle-images.sh
@@ -19,7 +19,8 @@ sed 's/@config_image@/config-boot-keys/g' "$templates/runtime.conf.in" \
"$source_dir/tools/gen-image/shirudo-gen-runtime" \
--binary "$bundle/root/usr/local/bin/shirudo" \
--bootstrap-conf "$work/runtime.conf" --cert "$keys/cert.der" \
- --config-cert "$keys/cert.der" --output "$bundle/verity/runtime" \
+ --config-cert "$work/verity/public/config-c.der" \
+ --config-cert "$work/verity/public/config-d.der" --output "$bundle/verity/runtime" \
--keys-dir "$keys" --builder "$source_dir/tools/shirudo-build/shirudo-build" \
--size 64 \
--extra-binary "$source_dir/build/verity-tests/shirudo-policy-probe" \
diff --git a/testing/vm/image-fixtures.sh b/testing/vm/image-fixtures.sh
index 31dd3e75..84c181b2 100755
--- a/testing/vm/image-fixtures.sh
+++ b/testing/vm/image-fixtures.sh
@@ -63,12 +63,18 @@ live_fp=$(cat "$output/public/live.fingerprint")
[[ "$boot_fp" =~ ^[a-f0-9]{64}$ ]] && [[ "$live_fp" =~ ^[a-f0-9]{64}$ ]]
[ "$boot_fp" != "$live_fp" ]
cp "$keys_dir/cert.der" "$output/public/primary.der"
+primary_fp=$("$operator" bpm key fingerprint "$keys_dir/cert.der")
+for name in config-c config-d config-untrusted; do
+ "$operator" genkey --keys-dir "$output/private/$name" \
+ >"$output/$name-genkey.log" 2>&1
+ cp "$output/private/$name/cert.der" "$output/public/$name.der"
+done
-for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \
+for name in config-boot-keys config-live-new-key config-live-revoke-a config-a config-b config-bad config-revoke \
config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \
config-tree-kconfig config-tree-reloaded \
config-otel config-jsonl config-jsonl-bad config-interrupted config-end2end \
- config-builtin; do
+ config-builtin config-untrusted; do
[ "$name" != config-builtin ] || [ -n "$builtin_key" ] || continue
root="$output/source/$name"
mkdir -p "$root/etc/shirudo" "$root/keys/trusted" "$root/keys/revoked"
@@ -100,14 +106,16 @@ for name in config-boot-keys config-live-new-key config-a config-b config-bad co
"$builder" keys vouch "$output/public/boot.der" \
-o "$root/keys/trusted/$boot_fp.vouch" --keys-dir "$keys_dir" \
>"$output/$name-boot-vouch.log" 2>&1
- if [ "$name" = config-live-new-key ]; then
+ if [[ "$name" == config-live-new-key || "$name" == config-live-revoke-a ]]; then
cp "$output/public/live.der" "$root/keys/trusted/$live_fp.der"
"$builder" keys vouch "$output/public/live.der" \
-o "$root/keys/trusted/$live_fp.vouch" \
--keys-dir "$output/private/boot" \
>"$output/$name-live-vouch.log" 2>&1
fi
- if [[ "$name" == config-revoke || "$name" == config-interrupted ]]; then
+ if [ "$name" = config-live-revoke-a ]; then
+ cp "$output/public/primary.der" "$root/keys/revoked/$primary_fp.der"
+ elif [[ "$name" == config-revoke || "$name" == config-interrupted ]]; then
cp "$output/public/boot.der" "$root/keys/revoked/$boot_fp.der"
elif [ "$name" = config-bad ]; then
printf 'invalid certificate\n' >"$root/keys/revoked/$boot_fp.der"
@@ -117,9 +125,15 @@ for name in config-boot-keys config-live-new-key config-a config-b config-bad co
expected=2
[[ "$name" != config-revoke && "$name" != config-interrupted ]] || expected=1
[ "$name" != config-live-new-key ] || expected=3
+ [ "$name" != config-live-revoke-a ] || expected=2
grep -q "signers=$expected" "$output/$name-validation.log"
fi
- verify_cert="$keys_dir/cert.der"
+ signing_keys="$output/private/config-c"
+ case "$name" in
+ config-b|config-live-revoke-a) signing_keys="$output/private/config-d" ;;
+ config-untrusted) signing_keys="$output/private/config-untrusted" ;;
+ esac
+ verify_cert="$signing_keys/cert.der"
if [ "$name" = config-builtin ]; then
truncate -s 8M "$output/private/builtin.img"
mkfs.ext4 -q -F -b 4096 -O '^has_journal' -E root_owner=0:0 \
@@ -131,7 +145,7 @@ for name in config-boot-keys config-live-new-key config-a config-b config-bad co
cp "$builtin_cert" "$output/public/builtin.der"
else
"$source_dir/tools/gen-image/shirudo-gen-image" --source "$root" \
- --output "$output/public/$name" --keys-dir "$keys_dir" \
+ --output "$output/public/$name" --keys-dir "$signing_keys" \
--builder "$builder" >"$output/$name-build.log" 2>&1
fi
SHIRUDO_BUILD="$builder" "$operator" image verify "$output/public/$name" \
@@ -147,6 +161,14 @@ done
--key "$output/private/boot/signing_key.pem" \
--cert "$output/public/boot.der"
+"$builder" "$source_dir/testing/fixtures/basic.bpf.c" \
+ -o "$output/public/shirudo-test-live-key.upatch" \
+ --name shirudo-test-live-key \
+ --vmlinux "$source_dir/vendor/linux/vmlinux.h" \
+ --extra-cflags "-I$source_dir/vendor/libbpf" \
+ --key "$output/private/live/signing_key.pem" \
+ --cert "$output/public/live.der"
+
# These host checks validate the fixture graph before the real target test.
mkdir "$output/check-live" "$output/check-boot"
"$validator" "$keys_dir/cert.der" "$output/source/config-boot-keys" \