eBPF-based security platform
testing: check config history in attestation reports
KP Singhfea70c9e7ff5
diff --git a/Makefile.shirudo b/Makefile.shirudoindex df75646c..9b544d6f 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -579,6 +579,7 @@ TEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-image-config \testing/helper/test-config-image \testing/helper/test-config-update \+ testing/helper/test-config-attest \testing/helper/test-image-keys \testing/helper/test-json-parser \testing/helper/test-string \@@ -768,6 +769,10 @@ testing/helper/test-config-update: testing/helper/test-config-update.c \@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) -o $@ $^ $(REGISTER_LIBS)+testing/helper/test-config-attest: testing/helper/test-config-attest.c \+ util/attest.o $(REGISTER_OBJS)+ @printf ' CC $@\n'+ $(Q)$(CC) $(CFLAGS) -o $@ $^ $(REGISTER_LIBS)testing/helper/test-image-keys: testing/helper/test-image-keys.c \util/image_keys.o util/keys.o $(REGISTER_OBJS)diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.cnew file mode 100644index 00000000..12f1750a--- /dev/null+++ b/testing/helper/test-config-attest.c@@ -0,0 +1,188 @@+// SPDX-License-Identifier: BSD-2-Clause+/* Copyright (c) 2026 Authors of shirudo */++#include <shirudo/misc.h>++#include <errno.h>+#include <fcntl.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/stat.h>+#include <unistd.h>++#include "util/attest.h"+#include "util/config_attest.h"+#include "util/config_measure.h"+#include "util/hex.h"+#include "util/io.h"+#include "util/json.h"+#include "util/malloc.h"+#include "util/tpm.h"++static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)+{+ struct shirudo_tpm *tpm = NULL;+ int rc;++ (void)ctx;+ rc = tpm_open(&tpm);+ if (!rc)+ rc = shirudo_tpm_boot_identity(tpm, reset, restart);+ tpm_close(tpm);+ return rc;+}++static int pcr_read(void *ctx, __u32 pcr, __u8 out[32])+{+ struct shirudo_tpm *tpm = NULL;+ int rc;++ (void)ctx;+ rc = tpm_open(&tpm);+ if (!rc)+ rc = tpm_pcr_read(tpm, pcr, out);+ tpm_close(tpm);+ return rc;+}++static int no_extend(void *ctx, __u32 pcr, const __u8 event[32])+{+ (void)ctx;+ (void)pcr;+ (void)event;+ return -EPERM;+}++static int no_activate(void *ctx,+ const struct shirudo_config_update_target *target)+{+ (void)ctx;+ (void)target;+ return -EPERM;+}++static int no_seal(void *ctx, int fd)+{+ (void)ctx;+ (void)fd;+ return 0;+}++static const struct shirudo_config_update_ops ops = {+ .boot_identity = boot_identity,+ .pcr_read = pcr_read,+ .pcr_extend = no_extend,+ .prepare = no_activate,+ .activate = no_activate,+ .seal = no_seal,+};++static int render(const char *directory, const char *nonce)+{+ struct shirudo_config_update update = { .dir_fd = -1, .lock_fd = -1 };+ __u8 bytes[SHIRUDO_ATTEST_NONCE_MAX];+ char *document = NULL;+ size_t length = 0, capacity = 0, nonce_length;+ int rc;++ nonce_length = strlen(nonce) / 2;+ if (strlen(nonce) % 2 || nonce_length > sizeof(bytes) ||+ hex_decode(nonce, bytes, nonce_length))+ return -EINVAL;+ rc = shirudo_config_update_open(directory, &ops, NULL, &update);+ if (!rc)+ rc = shirudo_attest_evidence_config(bytes, nonce_length,+ SHIRUDO_CHAIN_PCR_MASK,+ NULL, &update, &document,+ &length, &capacity);+ if (!rc)+ rc = write_complete(STDOUT_FILENO, document, length);+ xfree(document, capacity);+ shirudo_config_update_close(&update);+ return rc;+}++static int read_document(const char *path, char **out, size_t *length)+{+ struct stat st;+ ssize_t got;+ int fd;++ fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);+ if (fd < 0)+ return -errno;+ if (fstat(fd, &st) || st.st_size <= 0 ||+ st.st_size > SHIRUDO_JSON_MAX_BYTES) {+ close(fd);+ return -EINVAL;+ }+ *out = xmalloc(st.st_size + 1);+ if (!*out) {+ close(fd);+ return -ENOMEM;+ }+ got = read(fd, *out, st.st_size);+ close(fd);+ if (got != st.st_size) {+ xfree(*out, st.st_size + 1);+ *out = NULL;+ return -EIO;+ }+ (*out)[got] = 0;+ *length = got;+ return 0;+}++int main(int argc, char **argv)+{+ struct shirudo_config_evidence config = {};+ __u8 pcrs[24][32] = {}, root[32];+ const char *reason = NULL;+ const __u8 *expected;+ __u32 mask, reset, restart;+ char *document = NULL;+ size_t length = 0;+ int pcr, rc;++ if (argc == 4 && !strcmp(argv[1], "render")) {+ rc = render(argv[2], argv[3]);+ if (rc)+ fprintf(stderr, "render failed: %d\n", rc);+ return rc ? 1 : 0;+ }+ if (argc != 3 && argc != 8)+ return 2;+ rc = read_document(argv[2], &document, &length);+ if (!rc)+ rc = shirudo_config_evidence_parse(document, length, &config);+ if (rc)+ goto out;+ if (argc == 8 && !strcmp(argv[1], "replay")) {+ pcr = !strcmp(argv[4], "-") ? -1 : atoi(argv[4]);+ if (config.pcr >= 24 ||+ (!strcmp(argv[3], "-") ?+ 0 :+ hex_decode(argv[3], root, 32)) ||+ hex_decode(argv[7], pcrs[config.pcr], 32)) {+ rc = -EINVAL;+ goto out;+ }+ mask = 1u << (pcr < 0 ? config.pcr : (__u32)pcr);+ reset = strtoul(argv[5], NULL, 10);+ restart = strtoul(argv[6], NULL, 10);+ expected = !strcmp(argv[3], "-") ? NULL : root;+ rc = shirudo_config_evidence_verify(&config, mask, reset,+ restart, pcrs, expected,+ pcr, &reason);+ } else if (strcmp(argv[1], "parse")) {+ rc = -EINVAL;+ }+out:+ if (reason)+ printf("reason=%s\n", reason);+ printf("rc=%d\n", rc);+ shirudo_config_evidence_clear(&config);+ xfree(document, document ? length + 1 : 0);+ return rc ? 1 : 0;+}diff --git a/testing/t0048-config-attest.sh b/testing/t0048-config-attest.shnew file mode 100755index 00000000..5aae8eb7--- /dev/null+++ b/testing/t0048-config-attest.sh@@ -0,0 +1,187 @@+#!/bin/sh+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo++cd "$(dirname "$0")"+. ./test-lib.sh++H=${SHIRUDO_TEST_CONFIG_ATTEST_HELPER:-$(pwd)/helper/test-config-attest}+U=${SHIRUDO_TEST_CONFIG_HELPER:-$(pwd)/helper/test-config-update}+R=$(pwd)/helper/test-register+SIM=$(pwd)/helper/tpmsim-cmd+S=${SHIRUDO_IMAGE_TEST_SHIRUDO:-../shirudo}+for helper in "$H" "$U" "$R" "$SIM" "$S"; do+ [ -x "$helper" ] || test_skip_all "missing helper: $helper"+done+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"+WORK=$(mktemp -d)+trap 'rm -rf "$WORK"' EXIT HUP INT TERM+mkdir -m 700 "$WORK/config" "$WORK/keys"+head -c 700 /dev/urandom >"$WORK/keys/cert.der"+: >"$WORK/initrd-release"+export SHIRUDO_TPM_TCTI="cmd:$SIM $WORK/tpm"+export SHIRUDO_EVENTLOG_PATH="$WORK/eventlog"+export SHIRUDO_KEYS_DIR="$WORK/keys"+export SHIRUDO_INITRD_RELEASE="$WORK/initrd-release"+NONCE=0102030405060708090a0b0c0d0e0f10+ROOT_A=$(python3 -c 'print("41" * 32)')+ROOT_B=$(python3 -c 'print("42" * 32)')++field() {+ python3 -c 'import json,sys; d=json.load(open(sys.argv[1]));+for key in sys.argv[2].split("."): d=d[int(key)] if isinstance(d, list) else d[key]+print(d)' "$1" "$2"+}++verify() {+ "$S" attest verify --evidence="$1" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/b.json" ak.name)" \+ --expect-chain="$CHAIN" --strict-anchor --require-initrd \+ --expect-config-root="$ROOT_B" --expect-config-pcr=15+}++fixture_failed() {+ test_expect_success "$*" "false"+ test_done+}++INIT=$("$S" attest predict --cert="$WORK/keys/cert.der" | sed -n 's/^init_event: //p')+[ -n "$INIT" ] && "$R" init "$INIT" >"$WORK/nv-init" ||+ fixture_failed "TPM register fixture initialization failed"+CHAIN=$(sed -n 's/^value=//p' "$WORK/nv-init")+SHIRUDO_TEST_CONFIG_TPM=1 "$U" "$WORK/config" boot A >/dev/null ||+ fixture_failed "TPM config fixture boot failed"+"$H" render "$WORK/config" "$NONCE" >"$WORK/a.json" ||+ fixture_failed "config evidence fixture collection failed"+SHIRUDO_TEST_CONFIG_TPM=1 "$U" "$WORK/config" update B >/dev/null ||+ fixture_failed "TPM config fixture update failed"+"$H" render "$WORK/config" "$NONCE" >"$WORK/b.json" ||+ fixture_failed "updated config evidence fixture collection failed"++RESET=$(field "$WORK/b.json" config.reset_count)+RESTART=$(field "$WORK/b.json" config.restart_count)+PCR_VALUE=$(field "$WORK/b.json" pcrs.2.value)++test_expect_success 'collector adds the reserved config PCR and includes this boot selections' '+ python3 - "$WORK/b.json" <<"PY"+import json, sys+d = json.load(open(sys.argv[1])); c = d["config"]+assert d["pcr_mask"] == (1 << 9) | (1 << 11) | (1 << 15)+assert c["pcr"] == 15 and c["schema"] == 1+assert set(c) == {"schema", "pcr", "reset_count", "restart_count", "initial_pcr", "events"}+assert [event["kind"] for event in c["events"]] == [1, 2]+assert c["events"][-1]["root_hash"] == "42" * 32+PY+'++test_expect_success 'genuine TPM evidence verifies against the operator root and PCR choice' '+ verify "$WORK/b.json" >"$WORK/verified" &&+ grep -q "^ok: config: config root history matches the quoted PCR" "$WORK/verified" &&+ grep -qx "verdict: ok" "$WORK/verified"+'++test_expect_success 'the standalone bounded parser replays the same signed-PCR selection' '+ "$H" replay "$WORK/b.json" "$ROOT_B" 15 "$RESET" "$RESTART" "$PCR_VALUE" >/dev/null+'++test_expect_success 'the earlier boot selection also verifies against its correct expected root' '+ "$S" attest verify --evidence="$WORK/a.json" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/a.json" ak.name)" --expect-chain="$CHAIN" \+ --expect-config-root="$ROOT_A" --expect-config-pcr=15 >"$WORK/a-verified" &&+ grep -qx "verdict: ok" "$WORK/a-verified"+'++test_expect_success 'wrong expected roots, PCR choices and incomplete approval flags are refused' '+ ! "$S" attest verify --evidence="$WORK/b.json" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/b.json" ak.name)" --expect-chain="$CHAIN" \+ --expect-config-root="$ROOT_A" --expect-config-pcr=15 >/dev/null &&+ ! "$S" attest verify --evidence="$WORK/b.json" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/b.json" ak.name)" --expect-chain="$CHAIN" \+ --expect-config-root="$ROOT_B" --expect-config-pcr=14 >/dev/null &&+ ! "$S" attest verify --evidence="$WORK/b.json" --nonce="$NONCE" \+ --expect-config-root="$ROOT_B" >/dev/null+'++test_expect_success 'without operator approval the report names its limit explicitly' '+ "$S" attest verify --evidence="$WORK/b.json" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/b.json" ak.name)" --expect-chain="$CHAIN" \+ >"$WORK/unapproved" &&+ grep -q "^note: config root has no operator approval" "$WORK/unapproved" &&+ grep -q "direct TPM writer protection is deferred" "$WORK/unapproved"+'++python3 - "$WORK/b.json" "$WORK" <<'PY'+from copy import deepcopy+from pathlib import Path+import json, sys+base = json.load(open(sys.argv[1])); root = Path(sys.argv[2])++def save(name, change):+ d = deepcopy(base); change(d); (root / ("bad-" + name + ".json")).write_text(json.dumps(d))++def event(d):+ return d["config"]["events"][-1]++def flip_hex(value):+ return ("0" if value[0] != "0" else "1") + value[1:]++save("event-root", lambda d: event(d).__setitem__("root_hash", flip_hex(event(d)["root_hash"])))+for key in ("sequence", "kind"):+ save("event-" + key, lambda d, key=key: event(d).__setitem__(key, event(d)[key] + 1))+for key in ("schema", "reset_count", "restart_count", "pcr"):+ save("meta-" + key, lambda d, key=key: d["config"].__setitem__(key, d["config"][key] + 1))+save("initial-pcr", lambda d: d["config"].__setitem__("initial_pcr", "55" * 32))+save("missing-field", lambda d: event(d).pop("root_hash"))+save("missing-config", lambda d: d.pop("config"))+save("missing-boot", lambda d: d["config"]["events"].pop(0))+save("duplicate", lambda d: d["config"]["events"].append(deepcopy(event(d))))+save("reordered", lambda d: d["config"]["events"].reverse())+save("null", lambda d: d.__setitem__("config", None))+save("trailing-root", lambda d: event(d).__setitem__("root_hash", event(d)["root_hash"] + "00"))+save("too-many", lambda d: d["config"].__setitem__("events", d["config"]["events"] * 2049))+save("quoted-pcr", lambda d: next(p for p in d["pcrs"] if p["index"] == 15).__setitem__("value", "55" * 32))+PY++for document in "$WORK"/bad-*.json; do+ label=${document##*/}+ test_expect_success "tampered evidence $label is refused" '+ ! verify '"$document"' >/dev/null &&+ if [ '"$label"' != bad-quoted-pcr.json ]; then+ ! "$H" replay '"$document"' "$ROOT_B" 15 "$RESET" "$RESTART" "$PCR_VALUE" >/dev/null+ fi+ '+done++test_expect_success 'pending effects prevent evidence collection despite a measured selection' '+ ! SHIRUDO_TEST_CONFIG_TPM=1 SHIRUDO_TEST_CONFIG_ACTIVATE_FAIL=1 \+ "$U" "$WORK/config" update C >/dev/null &&+ ! "$H" render "$WORK/config" "$NONCE" >"$WORK/pending.json" &&+ test ! -s "$WORK/pending.json" &&+ ! SHIRUDO_TEST_CONFIG_TPM=1 "$U" "$WORK/config" boot C >/dev/null &&+ ! SHIRUDO_TEST_CONFIG_TPM=1 "$U" "$WORK/config" update C >/dev/null+'++test_expect_success 'legacy evidence remains valid and does not imply config approval' '+ "$R" evidence "$NONCE" >"$WORK/legacy.json" &&+ "$S" attest verify --evidence="$WORK/legacy.json" --nonce="$NONCE" \+ --ak-name="$(field "$WORK/legacy.json" ak.name)" \+ --expect-chain="$CHAIN" >"$WORK/legacy-report" &&+ grep -qx "verdict: ok" "$WORK/legacy-report" &&+ ! verify "$WORK/legacy.json" >/dev/null+'++test_expect_success 'real TPM reset exports only the fresh BOOT selection' '+ rm "$WORK/tpm/volatile" &&+ "$R" init "$INIT" >"$WORK/nv-reset" &&+ SHIRUDO_TEST_CONFIG_TPM=1 "$U" "$WORK/config" boot C >/dev/null &&+ "$H" render "$WORK/config" "$NONCE" >"$WORK/fresh.json" &&+ python3 - "$WORK/fresh.json" <<"PY"+import json, sys+d = json.load(open(sys.argv[1])); c = d["config"]+assert len(c["events"]) == 1 and c["events"][0]["kind"] == 1+assert c["initial_pcr"] == "00" * 32+assert c["events"][0]["root_hash"] == "43" * 32+PY+'++test_donediff --git a/testing/tamperproof/t1154-verity-config.py b/testing/tamperproof/t1154-verity-config.pyindex 440a43d7..b03e68f6 100644--- a/testing/tamperproof/t1154-verity-config.py+++ b/testing/tamperproof/t1154-verity-config.py@@ -94,8 +94,10 @@ def mapping_inventory():def snapshot(label):+ # Capture effects before a subsequent command can collect stale mappings.effects = {- "mount": mount(CONFIG), "runtime_mount": mount(RUNTIME),+ "mount": mount(CONFIG),+ "runtime_mount": mount(RUNTIME),"settings": (CONFIG / "etc/shirudo/shirudo.conf").read_text(),"journal": {p.name: p.read_bytes().hex()for p in sorted(JOURNAL.iterdir()) if p.is_file()},@@ -103,31 +105,62 @@ def snapshot(label):}status = json.loads(run(label + "-status", "image", "status"))require(status["consistent"] and not status["pending"], status)- records = [json.loads(line) for line in (JOURNAL / "events").read_text().splitlines()]- records = [r for r in records if r["reset_count"] == status["reset_count"] and- r["restart_count"] == status["restart_count"]]- require(records and records[0]["kind"] == 1, "missing boot event")- events = [{k: r[k] for k in ("sequence", "kind", "root_hash")} for r in records]- view = {"events": events, "initial_pcr": records[0]["initial_pcr"]}- result = subprocess.run(["tpm2_pcrread", "sha256:" + str(status["pcr"])],- capture_output=True, text=True, timeout=30)- require(result.returncode == 0, result.stderr)- (RESULTS / (label + ".pcr.stdout")).write_text(result.stdout)- import re- match = re.search(r"\b" + str(status["pcr"]) + r"\s*:\s*0x([0-9a-fA-F]{64})", result.stdout)- require(match is not None, "missing PCR value")- pcr = match.group(1).lower()+ require(status["pcr"] == 14, status)+ selected = next((name for name in NAMES+ if (IMAGES / (name + ".roothash")).exists() and+ root(name) == status["root_hash"]), None)+ require(selected is not None, f"unexpected current root: {status}")+ tenant = "tenant-config-0000" if selected == "config-otel" else selected+ require(f"map_export.tenant_id = {tenant}\n" in effects["settings"],+ "mounted settings do not match the selected root")+ nonce = secrets.token_hex(32)+ evidence = json.loads(run(label + "-evidence", "attest",+ "--pcrs=0,9", "--nonce=" + nonce))+ save(label + "-evidence", evidence)+ require(evidence["nonce"] == nonce, "nonce mismatch")+ require(evidence["pcr_bank"] == "sha256", "wrong PCR bank")+ require(evidence["pcr_mask"] == (1 | (1 << 9) | (1 << 14)),+ "CONFIG PCR was not added to requested quote selection")+ view = evidence["config"]+ require(view["schema"] == 1, "invalid config evidence schema")+ for field in ("pcr", "reset_count", "restart_count"):+ require(view[field] == status[field], f"status/evidence mismatch: {field}")+ events = view["events"]+ require(bool(events), "missing BOOT event")value = bytes.fromhex(view["initial_pcr"])- for event in events:+ previous = None+ for index, event in enumerate(events):+ require(event["kind"] == (2 if index else 1), "bad BOOT/UPDATE order")+ if previous is not None:+ require(event["sequence"] == previous["sequence"] + 1,+ "discontinuous history")+ require(event["root_hash"] in tuple(root(name) for name in NAMES+ if (IMAGES / (name + ".roothash")).exists()),+ "event does not describe a signed test fixture")digest = hashlib.sha256(b"shirudo-config-root-v1\0" +struct.pack(">I", event["kind"]) +bytes.fromhex(event["root_hash"])).digest()value = hashlib.sha256(value + digest).digest()- require(value.hex() == pcr, "journal replay differs from direct PCR read")- require(events[-1]["root_hash"] == status["root_hash"] and- events[-1]["sequence"] == status["sequence"], "history/status mismatch")- report = json.loads(run(label + "-register", "status", "--json"))- effects.update(status=status, config=view, pcr=pcr, chain=report["tpm"]["chain"])+ previous = event+ require(previous["sequence"] == status["sequence"] and+ previous["root_hash"] == root(selected),+ "history does not end at current root")+ pcrs = {p["index"]: p["value"] for p in evidence["pcrs"]}+ require(value.hex() == pcrs[14], "replay differs from quoted PCR")+ anchor_path = RESULTS / "anchor.json"+ anchor = load("anchor") if anchor_path.exists() else {+ "ak": evidence["ak"]["name"], "chain": evidence["register"]["value"]}+ # Pin this test session; deployment enrollment is outside this fixture.+ run(label + "-verify", "attest", "verify",+ "--evidence=" + str(RESULTS / (label + "-evidence.json")),+ "--nonce=" + nonce, "--ak-name=" + anchor["ak"],+ "--expect-chain=" + anchor["chain"],+ "--expect-config-root=" + root(selected), "--expect-config-pcr=14")+ if not anchor_path.exists():+ save("anchor", anchor)+ effects.update(status=status, config=view, pcr=pcrs[14],+ chain=evidence["register"]["value"])+ # JSON round-trip makes tuples comparable with stored snapshots.effects = json.loads(json.dumps(effects))save(label, effects)return effectsdiff --git a/testing/tamperproof/t1154-verity-config.sh b/testing/tamperproof/t1154-verity-config.shindex 4de289f9..d69dd463 100755--- a/testing/tamperproof/t1154-verity-config.sh+++ b/testing/tamperproof/t1154-verity-config.sh@@ -30,7 +30,7 @@ elsefiexport SHIRUDO_BIN-test_expect_success 'current CONFIG and direct PCR replay agree' '+test_expect_success 'current CONFIG and PCR evidence verify' 'python3 tamperproof/t1154-verity-config.py initial "$work"'diff --git a/testing/tamperproof/t1155-verity-boot-signers.py b/testing/tamperproof/t1155-verity-boot-signers.pyindex 13cbeae3..6afa36da 100644--- a/testing/tamperproof/t1155-verity-boot-signers.py+++ b/testing/tamperproof/t1155-verity-boot-signers.py@@ -100,11 +100,55 @@ def check_members(ring):def snapshot(label):- effects = config.snapshot(label)- effects["keyring"] = keyring()- require(effects["status"]["root_hash"] == ROOT, "wrong boot root")+ effects = {+ "keyring": keyring(),+ "mount": config.mount(config.CONFIG),+ "runtime_mount": config.mount(config.RUNTIME),+ "settings": (config.CONFIG / "etc/shirudo/shirudo.conf").read_text(),+ "journal": {p.name: p.read_bytes().hex()+ for p in sorted(config.JOURNAL.iterdir()) if p.is_file()},+ "mappings": config.mapping_inventory(),+ }+ status = json.loads(config.run(label + "-status", "image", "status"))+ require(status["consistent"] and not status["pending"] and+ status["root_hash"] == ROOT and status["pcr"] == 14, status)require("map_export.tenant_id = config-boot-keys\n" in effects["settings"],- "wrong boot configuration")+ "selected CONFIG does not contain the boot-key fixture settings")+ nonce = secrets.token_hex(32)+ evidence = json.loads(config.run(label + "-evidence", "attest",+ "--pcrs=0,9", "--nonce=" + nonce))+ config.save(label + "-evidence", evidence)+ view = evidence["config"]+ require(evidence["nonce"] == nonce and evidence["pcr_bank"] == "sha256",+ "incorrect nonce or PCR bank")+ require(evidence["pcr_mask"] == (1 | (1 << 9) | (1 << 14)),+ "CONFIG PCR missing from quote")+ require(view["schema"] == 1, "invalid CONFIG evidence schema")+ for field in ("pcr", "reset_count", "restart_count"):+ require(view[field] == status[field], f"status/evidence mismatch: {field}")+ require(len(view["events"]) == 1, "expected one BOOT event this boot")+ event = view["events"][0]+ require(event["sequence"] == status["sequence"], "BOOT sequence mismatch")+ require(event["kind"] == 1 and event["root_hash"] == ROOT,+ "BOOT did not select the signed boot-key fixture")+ digest = hashlib.sha256(b"shirudo-config-root-v1\0" ++ struct.pack(">I", 1) + bytes.fromhex(ROOT)).digest()+ after = hashlib.sha256(bytes.fromhex(view["initial_pcr"]) + digest).hexdigest()+ pcrs = {entry["index"]: entry["value"] for entry in evidence["pcrs"]}+ require(pcrs[14] == after, "BOOT replay disagrees with quoted PCR")+ anchor_path = config.RESULTS / "anchor.json"+ anchor = config.load("anchor") if anchor_path.exists() else {+ "ak": evidence["ak"]["name"], "chain": evidence["register"]["value"]}+ config.run(label + "-verify", "attest", "verify",+ "--evidence=" + str(config.RESULTS / (label + "-evidence.json")),+ "--nonce=" + nonce, "--ak-name=" + anchor["ak"],+ "--expect-chain=" + anchor["chain"],+ "--expect-config-root=" + ROOT, "--expect-config-pcr=14")+ if not anchor_path.exists():+ config.save("anchor", anchor)+ effects.update(status=status, config=view, pcr=pcrs[14],+ chain=evidence["register"]["value"])+ effects = json.loads(json.dumps(effects))config.save(label, effects)return effectsdiff --git a/testing/tamperproof/t1155-verity-boot-signers.sh b/testing/tamperproof/t1155-verity-boot-signers.shindex 6c6d7102..5133bf60 100755--- a/testing/tamperproof/t1155-verity-boot-signers.sh+++ b/testing/tamperproof/t1155-verity-boot-signers.sh@@ -38,7 +38,7 @@ elsefiexport SHIRUDO_BIN SHIRUDO_TEST_KEY_FIXTURES-test_expect_success 'boot enrolls the vouched signer and measures its signed CONFIG' '+test_expect_success 'boot enrolls the vouched signer and quotes its signed CONFIG' 'python3 tamperproof/t1155-verity-boot-signers.py initial "$work"'diff --git a/testing/tamperproof/t1156-verity-revocation.sh b/testing/tamperproof/t1156-verity-revocation.shindex 4b52f55b..c0b9d7a3 100644--- a/testing/tamperproof/t1156-verity-revocation.sh+++ b/testing/tamperproof/t1156-verity-revocation.sh@@ -13,7 +13,7 @@ export SHIRUDO_BIN SHIRUDO_TEST_KEY_FIXTUREStest_expect_success 'signed revocation fixture retains the primary and names the boot signer' 'python3 tamperproof/t1156-verity-revocation.py initial "$work"'-test_expect_success 'boot signer loads a pinned upatch with checked NV status' '+test_expect_success 'boot signer loads a pinned upatch with verified NV evidence' 'python3 tamperproof/t1156-verity-revocation.py load "$work"'test_expect_success 'signed CONFIG revocation unlinks its signer and purges its measured upatch' '