interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#215 (code only)

closed derived 9964e395513be830 #215

Imported from GitHub aien-dev/aienux#215 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 9daa5e196a227edec0a33dd8c30a8e16480e36e9 · Head 2f957d08340bc8dbd8feb71820ff6c420a4f3ef4

Apply it

git checkout -b patch-9964e395513be830 9daa5e196a227edec0a33dd8c30a8e16480e36e9
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/9964e395513be830.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
215
2f957d08340bc8dbd8feb71820ff6c420a4f3ef4
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":215,"url":"https://github.com/aien-dev/aienux/pull/215","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:58Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/ck-kernel.yml b/.github/workflows/ck-kernel.yml
index 7069d9f7..3276e7ca 100644
--- a/.github/workflows/ck-kernel.yml
+++ b/.github/workflows/ck-kernel.yml
@@ -73,6 +73,11 @@ jobs:
       - name: Gate runner self-test
         run: bash scripts/ck_gates.sh --self-test
 
+      - name: Hardware staging image refuses TEST keys (build only)
+        env:
+          AIENOS_QUIET_FLAG: ${{ runner.temp }}/spark-quiet
+        run: bash scripts/ck_owner_keys_check.sh
+
       - name: Check the host tests left the tree clean (the gate runner refuses a dirty tree)
         run: |
           git status --porcelain --untracked-files=normal
diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index a2a5a7c8..b2ce22b6 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -31,6 +31,15 @@ image, QEMU `iommu=smmuv3`). The unconfined bypass build
 (`make full CK_QEMU_UNSAFE_DMA=1`) is TEST-ONLY: one boot per geometry checks
 that it announces itself; it never counts toward a PASS. QEMU only.
 
+Store keys: every gate image (default and QEMU builds) uses the labelled TEST
+Store keys, TEST store uuid and TEST machine id. The hardware staging image
+(`make full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS=... CK_MACHINE_ID=...`)
+embeds none of them and its Store stage refuses (production Store key source
+BLOCKED_OPERATOR on the TRUST-1 key ceremony; native/kernel/README.md "Owner
+provisioning"). That is a build-only property checked by
+`scripts/ck_owner_keys_check.sh` (`CK_OWNER_KEYS_CHECK`), not a gate in this
+table or the receipt; no hardware staging image is booted anywhere.
+
 ## M1 boot: scripts/qemu_boot_test.sh -> CK `M1` (scripts/qemu_ck_boot_test.sh)
 
 Same QEMU command line (virt, EL2, GICv3, single-thread TCG, -smp 4, 2 GiB,
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index 2f880bb9..f0cf3eb1 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -11,6 +11,13 @@
 #                        $(OUT)/full-qemu-unsafe-dma/BOOTAA64.EFI (only
 #                        scripts/qemu_ck_store_test.sh sets this; refused
 #                        together with CK_HARDWARE_STAGING=1)
+#   make full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS=<file> CK_MACHINE_ID=<file>
+#                        hardware staging image $(OUT)/full-hardware-staging/:
+#                        no TEST Store keys/uuid/machine id (refused without
+#                        both files; tools/ck_owner_gen.c checks them); its
+#                        Store stage refuses (production key source is
+#                        BLOCKED_OPERATOR). scripts/ck_owner_keys_check.sh
+#   make owner-gen       host tool $(OUT)/host/ck_owner_gen
 #   make [full] CK_TEST_FWCFG_ARTIFACTS=1
 #                        TEST-ONLY: loader takes candidates from the QEMU fw_cfg
 #                        side channel instead of the boot disk Store; own OUT
@@ -86,6 +93,39 @@ $(error CK_QEMU_UNSAFE_DMA must be empty or 1)
 endif
 endif
 
+# Owner provisioning. The hardware staging image never embeds the TEST Store
+# keys, the TEST store uuid or the TEST machine id: it needs owner PUBLIC
+# material and the machine identity as files (format: tools/ck_owner_gen.c;
+# relative paths are relative to native/kernel), checked and turned into a
+# generated header that refuses every known TEST value. Nothing secret is
+# read: the production Store key source stays BLOCKED_OPERATOR
+# (svc/store_boot.c ck_store_production_keys, TRUST-1 key ceremony).
+CK_OWNER_PUBKEYS ?=
+CK_MACHINE_ID ?=
+ifneq ($(strip $(CK_HARDWARE_STAGING)),)
+ifneq ($(strip $(CK_HARDWARE_STAGING)),1)
+$(error CK_HARDWARE_STAGING must be empty or 1)
+endif
+ifeq ($(strip $(CK_OWNER_PUBKEYS)),)
+$(error CK_HARDWARE_STAGING refuses the TEST Store keys and TEST machine id: give CK_OWNER_PUBKEYS=<owner public keys file> and CK_MACHINE_ID=<machine id file> (native/kernel/README.md, Owner provisioning))
+endif
+ifeq ($(strip $(CK_MACHINE_ID)),)
+$(error CK_HARDWARE_STAGING refuses the TEST Store keys and TEST machine id: give CK_OWNER_PUBKEYS=<owner public keys file> and CK_MACHINE_ID=<machine id file> (native/kernel/README.md, Owner provisioning))
+endif
+OWNER_PUBKEYS_FILE := $(abspath $(CK_OWNER_PUBKEYS))
+OWNER_MACHINE_FILE := $(abspath $(CK_MACHINE_ID))
+ifeq ($(wildcard $(OWNER_PUBKEYS_FILE)),)
+$(error CK_OWNER_PUBKEYS file not found: $(OWNER_PUBKEYS_FILE))
+endif
+ifeq ($(wildcard $(OWNER_MACHINE_FILE)),)
+$(error CK_MACHINE_ID file not found: $(OWNER_MACHINE_FILE))
+endif
+else
+ifneq ($(strip $(CK_OWNER_PUBKEYS)$(CK_MACHINE_ID)),)
+$(error CK_OWNER_PUBKEYS and CK_MACHINE_ID are only used with CK_HARDWARE_STAGING=1 (the default QEMU build keeps the labelled TEST keys))
+endif
+endif
+
 # SEED-0B qualification build: trusts the RFC 8032 TEST 1 public key only.
 # TEST ONLY; never combined with hardware staging. Use its own OUT.
 CK_SEED0B_TEST_ANCHOR ?=
@@ -148,7 +188,13 @@ FULL_NAME := full
 STAGE_DMA_FLAGS :=
 endif
 ifneq ($(strip $(CK_HARDWARE_STAGING)),)
-STAGE_DMA_FLAGS += -DCK_HARDWARE_STAGING=1
+# Own OUT subdirectory: stage objects built with these flags never mix with
+# the default full image's objects.
+FULL_NAME := full-hardware-staging
+OWNER_HDR := $(OUT)/gen-$(FULL_NAME)/ck_owner_prov.h
+STAGE_DMA_FLAGS += -DCK_HARDWARE_STAGING=1 -I$(dir $(OWNER_HDR))
+else
+OWNER_HDR :=
 endif
 FULL_OUT := $(OUT)/$(FULL_NAME)
 STAGE_KOBJ := $(OUT)/obj/stage-$(FULL_NAME)
@@ -202,7 +248,7 @@ $(KOBJ)/%.o: $(NATIVE)/%.S
 	$(KCC) $(KCFLAGS) -c -o $@ $<
 
 define stage_rule
-$(STAGE_KOBJ)/$(subst /,_,$(patsubst $(REPO)/%,%,$(abspath $(1)))).o: $(1) $(STAGE_HDRS)
+$(STAGE_KOBJ)/$(subst /,_,$(patsubst $(REPO)/%,%,$(abspath $(1)))).o: $(1) $(STAGE_HDRS) $(OWNER_HDR)
 	@mkdir -p $$(dir $$@)
 	$(KCC) $(STAGE_KCFLAGS) -c -o $$@ $(1)
 endef
@@ -221,6 +267,17 @@ define fwcfg_check
 	fi
 endef
 
+# owner_check(elf): a hardware staging image must carry no TEST Store label,
+# TEST store uuid, TEST Store print lines or TEST key symbols.
+define owner_check
+	@if [ "$(strip $(CK_HARDWARE_STAGING))" = 1 ]; then \
+	  s=$$(grep -aoE "AIENOS-LANE18-TEST-KVOL-NOT-SECRET|AIEN-TEST-BOOT01|TEST identity, TEST keys|formatted TEST store" $(1) | sort -u | tr "\n" " "); \
+	  y=$$($(KNM) $(1) | grep -E " (ck_store_test_keys|ck_store_test_uuid)$$" | tr "\n" " "); \
+	  if [ -n "$$s$$y" ]; then echo "hardware staging image carries the TEST Store identity: $$s$$y"; rm -f $(1); exit 1; fi; \
+	  echo "no TEST Store label, uuid or key code in $(1)"; \
+	fi
+endef
+
 # link_image(output elf, objects): refuses undefined symbols (weak stage
 # references excepted) and any relocation other than R_AARCH64_RELATIVE.
 define link_image
@@ -250,6 +307,7 @@ $(FULL_ELF): $(CORE_OBJS) $(STAGE_BUILT) $(BOOT)/image.ld
 	@for s in ck_stage_devices ck_stage_security ck_stage_store ck_stage_quiesce ck_stage_disk_artifacts; do \
 	  $(KNM) $@ | grep -qE " [TW] $$s$$" || { echo "full image lacks $$s"; rm -f $@; exit 1; }; done
 	$(call fwcfg_check,$@)
+	$(call owner_check,$@)
 
 $(EFI): $(ELF)
 	$(call pe_image,$<,$@)
@@ -318,8 +376,21 @@ $(STORE_IMG_TOOL): $(STORE_IMG_SRCS) $(STAGE_HDRS)
 	$(HOSTCC) $(STAGE_HOST_FLAGS) $(STAGE_INC) -o $@ $(STORE_IMG_SRCS)
 store-image: $(STORE_IMG_TOOL)
 
+# Owner provisioning generator (hosted; never part of an image) and the
+# generated header for the hardware staging image.
+OWNER_GEN := $(OUT)/host/ck_owner_gen
+$(OWNER_GEN): $(KDIR)/tools/ck_owner_gen.c
+	@mkdir -p $(dir $@)
+	$(HOSTCC) -std=gnu11 -O2 -Wall -Wextra -Werror -o $@ $<
+owner-gen: $(OWNER_GEN)
+ifneq ($(OWNER_HDR),)
+$(OWNER_HDR): $(OWNER_GEN) $(OWNER_PUBKEYS_FILE) $(OWNER_MACHINE_FILE)
+	@mkdir -p $(dir $@)
+	$(OWNER_GEN) $(OWNER_PUBKEYS_FILE) $(OWNER_MACHINE_FILE) $@
+endif
+
 clean:
 	rm -rf $(OUT)
 
 FORCE:
-.PHONY: all full test sanitize clean print-kcflags udp-echo tool store-image FORCE
+.PHONY: all full test sanitize clean print-kcflags udp-echo tool store-image owner-gen FORCE
diff --git a/native/kernel/README.md b/native/kernel/README.md
index c6690391..59637321 100644
--- a/native/kernel/README.md
+++ b/native/kernel/README.md
@@ -31,6 +31,56 @@ Toolchain: gcc, binutils (ld, objcopy, nm, readelf), make, shell. On a
 non-aarch64 host the Makefile uses the `aarch64-linux-gnu-` prefix.
 Output lands in `<repo>/target/native-kernel` (ignored by git).
 
+## Owner provisioning (hardware staging image)
+
+The default and QEMU images use the labelled TEST Store keys
+(`ck_store_test_keys`, public label, `M5_ID_TEST`), the TEST store uuid and
+the TEST ARGUS machine id (0xA1). The hardware staging image never embeds any
+of them:
+
+    make -C native/kernel full CK_HARDWARE_STAGING=1 \
+        CK_OWNER_PUBKEYS=<owner public keys file> CK_MACHINE_ID=<machine id file>
+    # -> target/native-kernel/full-hardware-staging/BOOTAA64.EFI
+
+- Without both files the Makefile stops with `CK_HARDWARE_STAGING refuses the
+  TEST Store keys and TEST machine id`. `svc/store_boot.c` and
+  `svc/security.c` also `#error` in a `CK_HARDWARE_STAGING` build without the
+  generated header, and the linked image is checked (Makefile `owner_check`)
+  to carry no TEST Store label, uuid, TEST print line or TEST key symbol.
+- The files hold PUBLIC material only, as text lines `<name> <hex>` (`#`
+  comments; each name exactly once). Owner file:
+  `owner_root_ed25519 <64 hex>` (the Gate 3 Owner Root public key). Machine
+  file: `machine_id <64 hex>` (ARGUS machine id, 32 bytes) and
+  `store_uuid <32 hex>` (boot Store uuid). `tools/ck_owner_gen.c` checks them
+  and writes `ck_owner_prov.h` into the OUT directory (never committed). It
+  refuses the RFC 8032 TEST 1/2/3 public keys, the TEST machine id, the TEST
+  store uuid, all-equal bytes, wrong lengths, non-hex, duplicates and unknown
+  names. Real owner files are never committed.
+- What the image uses: the machine id becomes the ARGUS machine id, the store
+  uuid the boot Store uuid, and the boot log prints a SHA-256 fingerprint of
+  the owner root key. Nothing in the kernel verifies with the owner root key
+  yet.
+- **Production Store keys are BLOCKED_OPERATOR.** Store keys derive from
+  K_vol (ADR 0017), which is secret and cannot come from public material.
+  `ck_store_production_keys` always refuses (`CK_SB_E_BLOCKED_OPERATOR`), so
+  the hardware staging Store stage prints `store: REFUSED proof=keyed
+  step="production Store key source"` and neither reads nor formats the disk.
+  To unblock it the operator must provide, through the TRUST-1 key ceremony:
+  the Gate 3 Owner Root (offline), and a K_vol source the kernel can unwrap
+  at boot: the Gate 5/6 TPM PolicyAuthorize key with the sealed Slot 0 KEK,
+  or the Slot 1 recovery KEK. The in-kernel keyslot unwrap is also not
+  written yet. `store_boot_run` refuses TEST-identity keys in a hardware
+  staging build before any disk access (host test `stage_test`).
+- Proof: `scripts/ck_owner_keys_check.sh` (build only, takes the quiet flag)
+  checks the refusals, the generator refusals, and builds the hardware staging
+  image from the labelled TEST-fixture files in `tests/fixtures/owner/`
+  (public bytes only, distinct from every old TEST constant), then greps the
+  ELF and EFI. Ends `CK_OWNER_KEYS_CHECK: PASS`. CI runs it.
+- Not covered: the untrusted RFC 8032 TEST 1/2 public key constants
+  (`artifact/format.c`, used only by the `CK_SEED0B_TEST_ANCHOR` build and the
+  host tools) are still present as data in every image, including hardware
+  staging; the ordinary loader trusts no anchor.
+
 ## Boot sequence
 
 1. UEFI stub: pre-exit report on ConOut, memory map, `ExitBootServices`.
diff --git a/native/kernel/svc/security.c b/native/kernel/svc/security.c
index e8ab34de..e9837bee 100644
--- a/native/kernel/svc/security.c
+++ b/native/kernel/svc/security.c
@@ -10,6 +10,13 @@
 #include "aienos_contain.h"
 #include "ck.h"
 #include "ck_compat.h"
+#ifdef CK_HARDWARE_STAGING
+#include "ck_owner_prov.h" /* generated: owner public material + machine id */
+#if !defined(CK_OWNER_PROVISIONED) || CK_OWNER_PROVISIONED != 1
+#error "CK_HARDWARE_STAGING needs the generated owner provisioning header (CK_OWNER_PUBKEYS=, CK_MACHINE_ID=)"
+#endif
+_Static_assert(sizeof ck_owner_machine_id == ARGUS_MACHINE_ID_LEN, "machine id length");
+#endif
 
 /* Rust ipc demo resource ids are irrelevant here; these are local labels. */
 #define SUBJ_A 1u
@@ -88,7 +95,12 @@ static int bring_up(ck_sec_report *r)
     if (argus_core_init(&S.core, S.core_mem, argus_core_footprint()) != ARGUS_OK) return r->fail = "argus_core_init", -1;
     if (argus_contain_init(&S.contain, S.contain_mem, argus_contain_footprint()) != ARGUS_OK)
         return r->fail = "argus_contain_init", -1;
+#ifdef CK_HARDWARE_STAGING
+    /* this machine's ARGUS id: provisioned at build time (CK_MACHINE_ID) */
+    for (uint32_t i = 0; i < ARGUS_MACHINE_ID_LEN; i++) S.machine[i] = ck_owner_machine_id[i];
+#else
     S.machine[0] = 0xA1; /* this machine's ARGUS id: fixed label, TEST */
+#endif
     if (argus_aegis_bridge_init(&S.bridge, S.bridge_mem, argus_aegis_bridge_footprint(), S.core, S.contain, &S.gate,
                                 S.view, S.machine) != ARGUS_OK)
         return r->fail = "bridge_init", -1;
diff --git a/native/kernel/svc/store_boot.c b/native/kernel/svc/store_boot.c
index 7441dd61..495e85fb 100644
--- a/native/kernel/svc/store_boot.c
+++ b/native/kernel/svc/store_boot.c
@@ -7,10 +7,29 @@
 #include "m5.h"
 #include "sha256.h"
 
+#ifdef CK_HARDWARE_STAGING
+/* Hardware staging image: owner provisioning generated at build time by
+ * tools/ck_owner_gen.c from CK_OWNER_PUBKEYS= and CK_MACHINE_ID= (public
+ * material only). No TEST label, TEST uuid or TEST key code is compiled. */
+#include "ck_owner_prov.h"
+#if !defined(CK_OWNER_PROVISIONED) || CK_OWNER_PROVISIONED != 1
+#error "CK_HARDWARE_STAGING needs the generated owner provisioning header (make full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS=<file> CK_MACHINE_ID=<file>)"
+#endif
+#if defined(CK_STORE_TEST_KEYS)
+#error "CK_STORE_TEST_KEYS (TEST Store keys, TEST uuid) cannot be combined with CK_HARDWARE_STAGING"
+#endif
+#define CK_SB_HW 1
+#else
+#define CK_STORE_TEST_KEYS 1
+#define CK_SB_HW 0
+#endif
+
+#ifdef CK_STORE_TEST_KEYS
 #define LABEL_KVOL "AIENOS-LANE18-TEST-KVOL-NOT-SECRET"
 
 const uint8_t ck_store_test_uuid[16] = {'A', 'I', 'E', 'N', '-', 'T', 'E', 'S',
                                         'T', '-', 'B', 'O', 'O', 'T', '0', '1'};
+#endif
 
 static void bz(void *p, size_t n)
 {
@@ -42,6 +61,7 @@ static uint32_t get32(const uint8_t *p)
     return (uint32_t)p[0] | (uint32_t)p[1] << 8 | (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24;
 }
 
+#ifdef CK_STORE_TEST_KEYS
 void ck_store_test_keys(ss_keys *k)
 {
     uint8_t kvol[32];
@@ -56,6 +76,27 @@ void ck_store_test_keys(ss_keys *k)
     m5_subkeys_wipe(&sk);
     bz(kvol, sizeof kvol);
 }
+#endif
+
+/* BLOCKED_OPERATOR seam. Production Store keys derive from K_vol (ADR 0017),
+ * which is secret: it cannot come from the public owner material injected at
+ * build time, and no in-kernel unwrap of a K_vol keyslot exists yet. The
+ * operator must provide, through the TRUST-1 key ceremony: Gate 3 Owner Root
+ * (offline), Gate 5/6 TPM PolicyAuthorize key + sealed Slot 0 KEK (K_vol
+ * unwrapped at boot), or the Slot 1 recovery KEK. Until then this refuses and
+ * there is no TEST fallback. */
+int ck_store_production_keys(ss_keys *k)
+{
+    if (k) bz(k, sizeof *k);
+    return CK_SB_E_BLOCKED_OPERATOR;
+}
+
+int ck_store_keys_admissible(const ss_keys *k, int hardware_staging)
+{
+    if (!k) return 0;
+    if (k->identity_class == M5_ID_PRODUCTION) return 1;
+    return k->identity_class == M5_ID_TEST && !hardware_staging;
+}
 
 static int fail(ck_store_report *r, const char *proof, const char *step, int rc)
 {
@@ -103,10 +144,22 @@ static ss_store *g_ss;
 
 int store_boot_run(const disk_dev *d, const ss_keys *keys, const uint8_t uuid[16], const char *commit,
                    ck_store_report *r)
+{
+    return store_boot_run_policy(d, keys, uuid, commit, CK_SB_HW, r);
+}
+
+int store_boot_run_policy(const disk_dev *d, const ss_keys *keys, const uint8_t uuid[16], const char *commit,
+                          int hardware_staging, ck_store_report *r)
 {
     bz(r, sizeof *r);
     bcp(r->prev_commit, "none", 5);
     if (!d || !keys || !uuid || !commit) return fail(r, "geometry", "arguments", -1);
+    r->identity_class = keys->identity_class;
+    /* Before any disk access: a hardware staging build never opens, and
+     * never formats a blank disk, under TEST-identity keys. */
+    if (!ck_store_keys_admissible(keys, hardware_staging))
+        return fail(r, "keyed", "identity class not admissible in this build (TEST keys refused on hardware)",
+                    CK_SB_E_TEST_KEYS);
     if (d->block_size != 512 && d->block_size != 4096) return fail(r, "geometry", "block size", -1);
     uint32_t bpu = CK_LAYOUT_UNIT / d->block_size;
     uint64_t units = d->block_count / bpu;
@@ -202,16 +255,31 @@ static const char *err_name(int rc)
 {
     if (rc <= -301 && rc >= -313) return ss_strerror(rc);
     if (rc <= -101 && rc >= -212) return st_strerror(rc);
+    if (rc == CK_SB_E_TEST_KEYS) return "TestKeysRefused";
+    if (rc == CK_SB_E_BLOCKED_OPERATOR) return "BlockedOperator";
     return "error";
 }
 
 void store_boot_print(const ck_store_report *r)
 {
-    ck_printf("store: TEST identity, TEST keys (public label, not secret, not production); "
-              "anchor lba=%llu store lba=%llu units=%llu\n",
-              (unsigned long long)r->anchor_lba, (unsigned long long)r->store_base_lba,
-              (unsigned long long)r->store_units);
-    if (r->formatted) ck_printf("store: blank disk (all-zero anchor + Store head): formatted TEST store\n");
+    const char *fmt_line;
+#ifdef CK_STORE_TEST_KEYS
+    if (r->identity_class == M5_ID_TEST) {
+        ck_printf("store: TEST identity, TEST keys (public label, not secret, not production); "
+                  "anchor lba=%llu store lba=%llu units=%llu\n",
+                  (unsigned long long)r->anchor_lba, (unsigned long long)r->store_base_lba,
+                  (unsigned long long)r->store_units);
+        fmt_line = "store: blank disk (all-zero anchor + Store head): formatted TEST store\n";
+    } else
+#endif
+    {
+        ck_printf("store: identity class=%u (%s); anchor lba=%llu store lba=%llu units=%llu\n",
+                  (unsigned)r->identity_class, r->identity_class == M5_ID_PRODUCTION ? "production" : "refused",
+                  (unsigned long long)r->anchor_lba, (unsigned long long)r->store_base_lba,
+                  (unsigned long long)r->store_units);
+        fmt_line = "store: blank disk (all-zero anchor + Store head): formatted production store\n";
+    }
+    if (r->formatted) ck_puts(fmt_line);
     if (r->verdict != CK_SB_COMMITTED) {
         ck_printf("store: REFUSED proof=%s step=\"%s\" rc=%d (%s); disk left as found, not reformatted\n",
                   r->proof, r->step, r->rc, err_name(r->rc));
@@ -240,9 +308,33 @@ int ck_stage_store(void)
     }
     ss_keys keys;
     ck_store_report r;
-    ck_store_test_keys(&keys);
     const char *commit = ck_commit();
-    int rc = store_boot_run(d, &keys, ck_store_test_uuid, commit ? commit : "unknown", &r);
+    int rc;
+#ifdef CK_HARDWARE_STAGING
+    {
+        uint8_t fp[32];
+        sha256_hash(ck_owner_root_pk, sizeof ck_owner_root_pk, fp);
+        ck_printf("owner: provisioned at build time (public only): owner_root_ed25519 sha256=%02x%02x%02x%02x%02x%02x%02x%02x "
+                  "store_uuid=%02x%02x%02x%02x...\n",
+                  fp[0], fp[1], fp[2], fp[3], fp[4], fp[5], fp[6], fp[7], ck_owner_store_uuid[0],
+                  ck_owner_store_uuid[1], ck_owner_store_uuid[2], ck_owner_store_uuid[3]);
+    }
+    rc = ck_store_production_keys(&keys);
+    if (rc) {
+        bz(&keys, sizeof keys);
+        ck_printf("store: REFUSED proof=keyed step=\"production Store key source\" rc=%d (BlockedOperator: "
+                  "K_vol needs the TRUST-1 key ceremony, Gate 6 TPM keyslot or the operator recovery keyslot); "
+                  "disk not read, not formatted\n",
+                  rc);
+        ck_art_stage_load(0, "production Store key source BLOCKED_OPERATOR");
+        ck_dev_nvme_release();
+        return rc;
+    }
+    rc = store_boot_run(d, &keys, ck_owner_store_uuid, commit ? commit : "unknown", &r);
+#else
+    ck_store_test_keys(&keys);
+    rc = store_boot_run(d, &keys, ck_store_test_uuid, commit ? commit : "unknown", &r);
+#endif
     bz(&keys, sizeof keys);
     store_boot_print(&r);
     /* Signed artifact candidates live in this Store: read them while the disk
diff --git a/native/kernel/svc/store_boot.h b/native/kernel/svc/store_boot.h
index 0c181335..b7fceb7d 100644
--- a/native/kernel/svc/store_boot.h
+++ b/native/kernel/svc/store_boot.h
@@ -10,9 +10,17 @@
  *   io          the disk failed
  * Only an all-zero anchor + Store head counts as blank and is formatted.
  *
- * KEYS: the kernel has no production key path yet. ck_store_test_keys gives
- * TEST identity (M5_ID_TEST) keys derived from a public label. They protect
- * nothing and every line printed with them says TEST. */
+ * KEYS. Default (QEMU) build: ck_store_test_keys gives TEST identity
+ * (M5_ID_TEST) keys derived from a public label. They protect nothing and
+ * every line printed with them says TEST.
+ * Hardware staging build (CK_HARDWARE_STAGING; built with CK_OWNER_PUBKEYS=
+ * and CK_MACHINE_ID= files, see README "Owner provisioning"): the TEST keys
+ * and TEST uuid are not compiled; the store uuid comes from the generated
+ * owner provisioning header; keys come from ck_store_production_keys, the
+ * BLOCKED_OPERATOR seam (K_vol is secret and needs the TRUST-1 key
+ * ceremony), so the stage refuses before reading the disk. store_boot_run
+ * refuses TEST-identity keys in that build before any disk access, so it
+ * never formats a blank disk with them. */
 #ifndef AIENOS_CK_STORE_BOOT_H
 #define AIENOS_CK_STORE_BOOT_H
 #include <stdint.h>
@@ -37,17 +45,35 @@ typedef struct {
     uint64_t boot_count_prev, boot_count_new;
     char prev_commit[CK_BOOT_COMMIT_MAX + 1];
     uint64_t store_base_lba, store_units, anchor_lba;
+    uint8_t identity_class;   /* identity class of the keys given (M5_ID_*) */
 } ck_store_report;
 
-/* TEST keys and store uuid. Public, not secret, never production. */
+#define CK_SB_E_TEST_KEYS (-2001)        /* TEST identity keys refused (hardware staging) */
+#define CK_SB_E_BLOCKED_OPERATOR (-2002) /* production key source needs the operator */
+
+/* TEST keys and store uuid. Public, not secret, never production. Not
+ * compiled in a CK_HARDWARE_STAGING build. */
 void ck_store_test_keys(ss_keys *k);
 extern const uint8_t ck_store_test_uuid[16];
 
+/* Production Store keys. BLOCKED_OPERATOR: always zeroes k and returns
+ * CK_SB_E_BLOCKED_OPERATOR until the TRUST-1 ceremony provides a K_vol source
+ * (Gate 6 TPM Slot 0 unwrap or Slot 1 recovery KEK). Never falls back. */
+int ck_store_production_keys(ss_keys *k);
+
+/* 1 if keys of this identity class may open/format a Store in this build:
+ * PRODUCTION always; TEST only when hardware_staging is 0. */
+int ck_store_keys_admissible(const ss_keys *k, int hardware_staging);
+
 /* One boot against disk d (whole namespace, layout of dev/disk_layout.h).
  * commit is the image commit string recorded in the new boot record.
  * Prints nothing; ck_stage_store prints. */
 int store_boot_run(const disk_dev *d, const ss_keys *keys, const uint8_t uuid[16], const char *commit,
                    ck_store_report *r);
+/* Same with the build policy explicit (store_boot_run passes 1 in a
+ * CK_HARDWARE_STAGING build, else 0); the host test drives both. */
+int store_boot_run_policy(const disk_dev *d, const ss_keys *keys, const uint8_t uuid[16], const char *commit,
+                          int hardware_staging, ck_store_report *r);
 /* Print the report lines (also used by the host test). */
 void store_boot_print(const ck_store_report *r);
 /* The open Store of the last store_boot_run (valid only after it returned 0;
diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c
index d628ddc0..7a857b56 100644
--- a/native/kernel/svc/tests/stage_test.c
+++ b/native/kernel/svc/tests/stage_test.c
@@ -228,6 +228,33 @@ static void test_store(void)
         CHECK(nz == 0);
     }
 
+    printf("  [hardware staging policy: TEST keys refused, blank disk not formatted]\n");
+    {
+        ss_keys pk;
+        memset(&pk, 0xEE, sizeof pk);
+        CHECK(ck_store_production_keys(&pk) == CK_SB_E_BLOCKED_OPERATOR);
+        size_t nz = 0;
+        for (size_t i = 0; i < sizeof pk; i++) nz += ((const uint8_t *)&pk)[i] != 0;
+        CHECK(nz == 0); /* BLOCKED_OPERATOR: no key bytes handed out */
+        CHECK(ck_store_keys_admissible(&k, 0) == 1 && ck_store_keys_admissible(&k, 1) == 0);
+        ss_keys prod = k;
+        prod.identity_class = M5_ID_PRODUCTION;
+        CHECK(ck_store_keys_admissible(&prod, 1) == 1 && ck_store_keys_admissible(&prod, 0) == 1);
+        ss_keys odd = k;
+        odd.identity_class = 0;
+        CHECK(ck_store_keys_admissible(&odd, 0) == 0 && ck_store_keys_admissible(0, 0) == 0);
+        CHECK(dopen(0) == 0);
+        int rc = store_boot_run_policy(&g_d, &k, ck_store_test_uuid, "hw-test", 1, &r);
+        store_boot_print(&r);
+        dclose();
+        CHECK(rc == CK_SB_E_TEST_KEYS && r.verdict == CK_SB_REFUSED && r.formatted == 0);
+        CHECK(r.proof && strcmp(r.proof, "keyed") == 0 && r.identity_class == M5_ID_TEST);
+        CHECK(load(now) == 0);
+        nz = 0;
+        for (size_t i = 0; i < T_BYTES; i++) nz += now[i] != 0;
+        CHECK(nz == 0); /* the disk was not touched */
+    }
+
     printf("  [store boot 1: blank disk]\n");
     CHECK(boot(&k, "commit-one", &r) == 0);
     CHECK(r.formatted == 1 && r.verdict == CK_SB_COMMITTED && r.boot_count_prev == 0 && r.boot_count_new == 1);
diff --git a/native/kernel/tests/fixtures/owner/TEST-FIXTURE-machine-id.txt b/native/kernel/tests/fixtures/owner/TEST-FIXTURE-machine-id.txt
new file mode 100644
index 00000000..de127f3a
--- /dev/null
+++ b/native/kernel/tests/fixtures/owner/TEST-FIXTURE-machine-id.txt
@@ -0,0 +1,7 @@
+# TEST FIXTURE. NOT A MACHINE IDENTITY. Never use for a real build.
+# Random bytes generated once for this fixture (2026-10-01). Used only by
+# scripts/ck_owner_keys_check.sh. Distinct from the TEST machine id (0xA1)
+# and the TEST store uuid. A real file names Machine 1's ARGUS machine id and
+# its boot Store uuid and is kept with the owner's provisioning records.
+machine_id 9c72f350f7edfc007c9157a0e74a6367adabff1022dc609c9e0bfbd34f996f67
+store_uuid dd0e837ace4005d3ec804685a3630592
diff --git a/native/kernel/tests/fixtures/owner/TEST-FIXTURE-owner-pubkeys.txt b/native/kernel/tests/fixtures/owner/TEST-FIXTURE-owner-pubkeys.txt
new file mode 100644
index 00000000..911c962e
--- /dev/null
+++ b/native/kernel/tests/fixtures/owner/TEST-FIXTURE-owner-pubkeys.txt
@@ -0,0 +1,8 @@
+# TEST FIXTURE. NOT AN OWNER KEY. Never use for a real build.
+# Public Ed25519 key of a throwaway key pair generated once for this fixture
+# (2026-10-01); the private half was never stored, so nothing can sign under
+# it. Used only by scripts/ck_owner_keys_check.sh to prove the hardware
+# staging build path. Deliberately distinct from every old TEST constant
+# (Store label, RFC 8032 vectors). A real owner file holds the Gate 3 Owner
+# Root PUBLIC key from the TRUST-1 key ceremony and is never committed.
+owner_root_ed25519 a980e270f6778c14e7a526ad997aa370b8001d24901042235215277ea7233125
diff --git a/native/kernel/tools/ck_owner_gen.c b/native/kernel/tools/ck_owner_gen.c
new file mode 100644
index 00000000..9997f964
--- /dev/null
+++ b/native/kernel/tools/ck_owner_gen.c
@@ -0,0 +1,163 @@
+/* ck_owner_gen.c -- build-time owner provisioning for the C kernel
+ * hardware staging image (make full CK_HARDWARE_STAGING=1).
+ *
+ *   ck_owner_gen <owner pubkeys file> <machine id file> <out header>
+ *
+ * Reads owner PUBLIC material and the machine identity, checks format and
+ * length, refuses every known TEST value, and writes a C header with the
+ * bytes (no labels, no file names, no comments copied from the inputs).
+ * Nothing secret is ever read here: the Store volume key K_vol is not public
+ * material and has no build-time source (store_boot.c
+ * ck_store_production_keys, BLOCKED_OPERATOR on the TRUST-1 key ceremony).
+ *
+ * Input format (both files): text lines "<name> <hex>"; '#' starts a comment
+ * line; blank lines are ignored; every name must appear exactly once; any
+ * other name is refused.
+ *   owner pubkeys file:  owner_root_ed25519 <64 hex>   Owner Root public key
+ *   machine id file:     machine_id <64 hex>           ARGUS machine id (32 B)
+ *                        store_uuid <32 hex>           boot Store uuid (16 B)
+ *
+ * Refused values: all bytes equal (all zero included); the RFC 8032 section
+ * 7.1 TEST 1/2/3 public keys; the TEST machine id (0xA1 then 31 zero bytes);
+ * the TEST store uuid "AIEN-TEST-BOOT01". Exit 0 and "CK_OWNER_GEN: OK" on
+ * success, else exit 1, "CK_OWNER_GEN: REFUSED <reason>" and no header.
+ * Hosted tool; never part of an image. No outside libraries. */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Known TEST values. RFC 8032 section 7.1 TEST 1 and TEST 2 equal
+ * native/kernel/artifact/format.c cka_test1_pk / cka_test2_pk. */
+static const uint8_t RFC8032_T1[32] = {
+    0xd7, 0x5a, 0x98, 0x01, 0x82, 0xb1, 0x0a, 0xb7, 0xd5, 0x4b, 0xfe, 0xd3, 0xc9, 0x64, 0x07, 0x3a,
+    0x0e, 0xe1, 0x72, 0xf3, 0xda, 0xa6, 0x23, 0x25, 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07, 0x51, 0x1a};
+static const uint8_t RFC8032_T2[32] = {
+    0x3d, 0x40, 0x17, 0xc3, 0xe8, 0x43, 0x89, 0x5a, 0x92, 0xb7, 0x0a, 0xa7, 0x4d, 0x1b, 0x7e, 0xbc,
+    0x9c, 0x98, 0x2c, 0xcf, 0x2e, 0xc4, 0x96, 0x8c, 0xc0, 0xcd, 0x55, 0xf1, 0x2a, 0xf4, 0x66, 0x0c};
+static const uint8_t RFC8032_T3[32] = {
+    0xfc, 0x51, 0xcd, 0x8e, 0x62, 0x18, 0xa1, 0xa3, 0x8d, 0xa4, 0x7e, 0xd0, 0x02, 0x30, 0xf0, 0x58,
+    0x08, 0x16, 0xed, 0x13, 0xba, 0x33, 0x03, 0xac, 0x5d, 0xeb, 0x91, 0x15, 0x48, 0x90, 0x80, 0x25};
+static const uint8_t TEST_MACHINE[32] = {0xA1};
+static const uint8_t TEST_UUID[16] = {'A', 'I', 'E', 'N', '-', 'T', 'E', 'S',
+                                      'T', '-', 'B', 'O', 'O', 'T', '0', '1'};
+
+typedef struct {
+    const char *name;
+    size_t len;
+    uint8_t v[32];
+    int seen;
+} field;
+
+static void refuse(const char *what, const char *why)
+{
+    printf("CK_OWNER_GEN: REFUSED %s: %s\n", what, why);
+    exit(1);
+}
+
+static int hexval(int c)
+{
+    if (c >= '0' && c <= '9') return c - '0';
+    if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+    if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+    return -1;
+}
+
+static void parse(const char *path, field *f, size_t nf)
+{
+    FILE *fp = fopen(path, "r");
+    if (!fp) refuse(path, "cannot open");
+    char line[512];
+    unsigned ln = 0;
+    while (fgets(line, sizeof line, fp)) {
+        ln++;
+        size_t n = strlen(line);
+        if (n == sizeof line - 1 && line[n - 1] != '\n') refuse(path, "line too long");
+        while (n && (line[n - 1] == '\n' || line[n - 1] == '\r' || line[n - 1] == ' ' || line[n - 1] == '\t'))
+            line[--n] = 0;
+        char *p = line;
+        while (*p == ' ' || *p == '\t') p++;
+        if (!*p || *p == '#') continue;
+        char *name = p;
+        while (*p && *p != ' ' && *p != '\t') p++;
+        if (!*p) refuse(path, "line without a value");
+        *p++ = 0;
+        while (*p == ' ' || *p == '\t') p++;
+        char *hex = p;
+        field *t = 0;
+        for (size_t i = 0; i < nf; i++)
+            if (!strcmp(f[i].name, name)) t = &f[i];
+        if (!t) {
+            printf("CK_OWNER_GEN: REFUSED %s line %u: unknown name \"%.64s\"\n", path, ln, name);
+            exit(1);
+        }
+        if (t->seen) refuse(t->name, "given twice");
+        if (strlen(hex) != 2 * t->len) {
+            printf("CK_OWNER_GEN: REFUSED %s: need exactly %zu hex digits, got %zu\n", t->name, 2 * t->len,
+                   strlen(hex));
+            exit(1);
+        }
+        for (size_t i = 0; i < t->len; i++) {
+            int hi = hexval(hex[2 * i]), lo = hexval(hex[2 * i + 1]);
+            if (hi < 0 || lo < 0) refuse(t->name, "not hex");
+            t->v[i] = (uint8_t)(hi << 4 | lo);
+        }
+        t->seen = 1;
+    }
+    if (ferror(fp)) refuse(path, "read error");
+    fclose(fp);
+    for (size_t i = 0; i < nf; i++)
+        if (!f[i].seen) refuse(f[i].name, "missing");
+}
+
+static void check_value(const field *t)
+{
+    size_t same = 1;
+    while (same < t->len && t->v[same] == t->v[0]) same++;
+    if (same == t->len) refuse(t->name, "all bytes equal (placeholder, not an identity)");
+}
+
+static void emit(FILE *o, const char *sym, const field *t)
+{
+    fprintf(o, "static const uint8_t %s[%zu] __attribute__((unused)) = {", sym, t->len);
+    for (size_t i = 0; i < t->len; i++) fprintf(o, "%s0x%02x", i ? ", " : "", t->v[i]);
+    fprintf(o, "};\n");
+}
+
+int main(int argc, char **argv)
+{
+    if (argc != 4) {
+        fprintf(stderr, "usage: ck_owner_gen <owner pubkeys file> <machine id file> <out header>\n");
+        return 2;
+    }
+    field own[1] = {{"owner_root_ed25519", 32, {0}, 0}};
+    field mach[2] = {{"machine_id", 32, {0}, 0}, {"store_uuid", 16, {0}, 0}};
+    parse(argv[1], own, 1);
+    parse(argv[2], mach, 2);
+    check_value(&own[0]);
+    check_value(&mach[0]);
+    check_value(&mach[1]);
+    if (!memcmp(own[0].v, RFC8032_T1, 32) || !memcmp(own[0].v, RFC8032_T2, 32) || !memcmp(own[0].v, RFC8032_T3, 32))
+        refuse("owner_root_ed25519", "is an RFC 8032 TEST public key");
+    if (!memcmp(mach[0].v, TEST_MACHINE, 32)) refuse("machine_id", "is the TEST machine id (0xA1)");
+    if (!memcmp(mach[1].v, TEST_UUID, 16)) refuse("store_uuid", "is the TEST store uuid");
+    if (!memcmp(own[0].v, mach[0].v, 32)) refuse("machine_id", "equals the owner root public key");
+
+    char tmp[4096];
+    if (snprintf(tmp, sizeof tmp, "%s.tmp", argv[3]) >= (int)sizeof tmp) refuse(argv[3], "path too long");
+    FILE *o = fopen(tmp, "w");
+    if (!o) refuse(argv[3], "cannot write");
+    fprintf(o, "/* Generated by native/kernel/tools/ck_owner_gen.c. Do not edit or commit. */\n"
+               "#ifndef AIENOS_CK_OWNER_PROV_H\n#define AIENOS_CK_OWNER_PROV_H\n#include <stdint.h>\n"
+               "#define CK_OWNER_PROVISIONED 1\n");
+    emit(o, "ck_owner_root_pk", &own[0]);
+    emit(o, "ck_owner_machine_id", &mach[0]);
+    emit(o, "ck_owner_store_uuid", &mach[1]);
+    fprintf(o, "#endif\n");
+    if (fclose(o) || rename(tmp, argv[3])) {
+        remove(tmp);
+        refuse(argv[3], "cannot write");
+    }
+    printf("CK_OWNER_GEN: OK %s\n", argv[3]);
+    return 0;
+}
diff --git a/scripts/ck_owner_keys_check.sh b/scripts/ck_owner_keys_check.sh
new file mode 100755
index 00000000..ebc6696e
--- /dev/null
+++ b/scripts/ck_owner_keys_check.sh
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+# ck_owner_keys_check.sh -- build-side proof that the C kernel hardware
+# staging image never embeds the TEST Store keys, the TEST store uuid or the
+# TEST machine id (native/kernel/README.md, "Owner provisioning").
+#
+#   bash scripts/ck_owner_keys_check.sh
+#
+# Checks, each PASS or FAIL:
+#   1. make full CK_HARDWARE_STAGING=1 with no owner files is refused with the
+#      expected message (also with only one of the two files); owner files
+#      without CK_HARDWARE_STAGING are refused.
+#   2. tools/ck_owner_gen.c refuses every known TEST value and every malformed
+#      input (wrong length, not hex, duplicate, unknown name, missing name,
+#      all-equal bytes) and writes no header.
+#   3. With the labelled TEST-fixture owner files
+#      (native/kernel/tests/fixtures/owner/, public bytes only, distinct from
+#      every old TEST constant) the hardware staging image builds; its ELF and
+#      EFI carry no TEST Store label, TEST uuid, TEST Store print line, fixture
+#      label, or TEST key symbol; they do carry the fixture machine id bytes
+#      and the BLOCKED_OPERATOR Store refusal line.
+#   4. Control: the default full image still carries the labelled TEST Store
+#      label (the grep is not vacuous).
+# Build-only: nothing is booted. Takes the Spark quiet flag like the qemu_ck_*
+# scripts (NOT_RUN, exit 3, if another run holds it). No Python.
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+kdir="${repo_root}/native/kernel"
+fix="${kdir}/tests/fixtures/owner"
+out="${CK_OWNER_CHECK_OUT:-${repo_root}/target/ck-owner-keys-check}"
+cross=""
+if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi
+
+quiet_flag="${AIENOS_QUIET_FLAG:-${HOME}/workspace/.spark-quiet}"
+quiet_tag="${AIENOS_QUIET_TAG:-ck_owner_keys_check $$}"
+if ! ( set -C; echo "${quiet_tag}" > "${quiet_flag}" ) 2>/dev/null; then
+    echo "NOT_RUN  quiet flag ${quiet_flag} is held: $(head -c 200 "${quiet_flag}" 2>/dev/null || true)"
+    echo "CK_OWNER_KEYS_CHECK: NOT_RUN"
+    exit 3
+fi
+tmp="$(mktemp -d)"
+cleanup() {
+    rm -rf "${tmp}"
+    if [[ -f "${quiet_flag}" ]] && grep -qxF -- "${quiet_tag}" "${quiet_flag}"; then rm -f "${quiet_flag}"; fi
+}
+trap cleanup EXIT
+
+fails=0
+ok() { echo "PASS  $*"; }
+bad() { echo "FAIL  $*"; fails=$((fails + 1)); }
+mk() { make -s -C "${kdir}" CROSS="${cross}" OUT="${out}" "$@"; }
+
+own="${fix}/TEST-FIXTURE-owner-pubkeys.txt"
+mach="${fix}/TEST-FIXTURE-machine-id.txt"
+refusal="CK_HARDWARE_STAGING refuses the TEST Store keys and TEST machine id"
+
+# ---- 1. build-time refusals ----------------------------------------------
+expect_make_refused() { # label, expected text, make args...
+    local label="$1" want="$2"; shift 2
+    local log="${tmp}/make.log"
+    if mk "$@" >"${log}" 2>&1; then
+        bad "${label}: build was not refused"
+    elif grep -qF -- "${want}" "${log}"; then
+        ok "${label}: refused ($(grep -oF -- "${want}" "${log}" | head -1))"
+    else
+        bad "${label}: refused without the expected message: $(tail -c 300 "${log}")"
+    fi
+}
+expect_make_refused "hardware staging, no owner files" "${refusal}" full CK_HARDWARE_STAGING=1
+expect_make_refused "hardware staging, owner keys only" "${refusal}" full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS="${own}"
+expect_make_refused "hardware staging, machine id only" "${refusal}" full CK_HARDWARE_STAGING=1 CK_MACHINE_ID="${mach}"
+expect_make_refused "owner files without hardware staging" "only used with CK_HARDWARE_STAGING=1" \
+    full CK_OWNER_PUBKEYS="${own}" CK_MACHINE_ID="${mach}"
+expect_make_refused "hardware staging + TEST artifact anchor" "cannot be combined with CK_HARDWARE_STAGING" \
+    full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS="${own}" CK_MACHINE_ID="${mach}" CK_SEED0B_TEST_ANCHOR=1
+
+# ---- 2. generator refusals -----------------------------------------------
+mk owner-gen
+gen="${out}/host/ck_owner_gen"
+good_pk="owner_root_ed25519 $(awk '$1=="owner_root_ed25519"{print $2}' "${own}")"
+good_mid="machine_id $(awk '$1=="machine_id"{print $2}' "${mach}")"
+good_uu="store_uuid $(awk '$1=="store_uuid"{print $2}' "${mach}")"
+expect_gen_refused() { # label, expected text, owner file text, machine file text
+    local label="$1" want="$2"
+    printf '%s\n' "$3" >"${tmp}/o.txt"
+    printf '%s\n' "$4" >"${tmp}/m.txt"
+    rm -f "${tmp}/h.h"
+    local res rc=0
+    res="$("${gen}" "${tmp}/o.txt" "${tmp}/m.txt" "${tmp}/h.h" 2>&1)" || rc=$?
+    if [[ "${rc}" == 1 && "${res}" == *"CK_OWNER_GEN: REFUSED"* && "${res}" == *"${want}"* && ! -e "${tmp}/h.h" ]]; then
+        ok "generator refuses ${label} (${res#CK_OWNER_GEN: REFUSED })"
+    else
+        bad "generator ${label}: rc=${rc} out=${res}"
+    fi
+}
+z64="$(printf '0%.0s' {1..64})"
+expect_gen_refused "RFC 8032 TEST 1 owner key" "RFC 8032 TEST public key" \
+    "owner_root_ed25519 d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "RFC 8032 TEST 2 owner key" "RFC 8032 TEST public key" \
+    "owner_root_ed25519 3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "RFC 8032 TEST 3 owner key" "RFC 8032 TEST public key" \
+    "owner_root_ed25519 fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "TEST machine id 0xA1" "TEST machine id" \
+    "${good_pk}" "machine_id a1${z64:2}"$'\n'"${good_uu}"
+expect_gen_refused "TEST store uuid" "TEST store uuid" \
+    "${good_pk}" "${good_mid}"$'\n'"store_uuid 4149454e2d544553542d424f4f543031"
+expect_gen_refused "all-zero owner key" "all bytes equal" "owner_root_ed25519 ${z64}" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "all-zero machine id" "all bytes equal" "${good_pk}" "machine_id ${z64}"$'\n'"${good_uu}"
+expect_gen_refused "short owner key" "need exactly 64 hex digits" "owner_root_ed25519 abcd" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "long store uuid" "need exactly 32 hex digits" \
+    "${good_pk}" "${good_mid}"$'\n'"store_uuid ${z64:0:30}0102"
+expect_gen_refused "non-hex owner key" "not hex" "owner_root_ed25519 zz${z64:2}" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "duplicate machine id" "given twice" "${good_pk}" "${good_mid}"$'\n'"${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "unknown name" "unknown name" "${good_pk}"$'\n'"k_vol ${z64}" "${good_mid}"$'\n'"${good_uu}"
+expect_gen_refused "missing store uuid" "missing" "${good_pk}" "${good_mid}"
+expect_gen_refused "machine id equal to owner key" "equals the owner root public key" \
+    "${good_pk}" "machine_id ${good_pk#owner_root_ed25519 }"$'\n'"${good_uu}"
+
+# ---- 3. hardware staging image with the TEST-fixture owner files ---------
+hw="${out}/full-hardware-staging"
+if mk full CK_HARDWARE_STAGING=1 CK_OWNER_PUBKEYS="${own}" CK_MACHINE_ID="${mach}" >"${tmp}/hw.log" 2>&1 \
+    && [[ -s "${hw}/BOOTAA64.EFI" && -s "${hw}/aienos-ck.elf" ]]; then
+    ok "hardware staging image built with the TEST-fixture owner files ($(grep -c . "${tmp}/hw.log") build lines)"
+    grep -qF "no TEST Store label, uuid or key code" "${tmp}/hw.log" \
+        && ok "Makefile owner_check ran on the hardware staging ELF" || bad "Makefile owner_check line missing"
+else
+    bad "hardware staging image with fixture owner files did not build: $(tail -c 400 "${tmp}/hw.log")"
+fi
+banned='AIENOS-LANE18-TEST-KVOL-NOT-SECRET|AIEN-TEST-BOOT01|TEST identity, TEST keys|formatted TEST store|TEST-FIXTURE|TEST FIXTURE'
+for f in "${hw}/aienos-ck.elf" "${hw}/BOOTAA64.EFI"; do
+    [[ -s "${f}" ]] || { bad "missing ${f}"; continue; }
+    s="$(grep -aoE "${banned}" "${f}" | sort -u | tr '\n' ' ' || true)"
+    [[ -z "${s}" ]] && ok "no TEST Store label/uuid/print line or fixture label in $(basename "${f}")" \
+        || bad "$(basename "${f}") carries: ${s}"
+    hex="$(od -An -tx1 -v "${f}" | tr -d ' \n')"
+    mid_hex="$(awk '$1=="machine_id"{print $2}' "${mach}")"
+    [[ "${hex}" == *"${mid_hex}"* ]] && ok "$(basename "${f}") carries the provisioned machine id bytes" \
+        || bad "$(basename "${f}") lacks the provisioned machine id bytes"
+    [[ "${hex}" == *"4149454e2d544553542d424f4f543031"* ]] && bad "$(basename "${f}") carries the TEST uuid bytes" \
+        || ok "no TEST uuid bytes in $(basename "${f}")"
+    grep -aqF 'production Store key source' "${f}" && ok "$(basename "${f}") carries the BLOCKED_OPERATOR Store refusal" \
+        || bad "$(basename "${f}") lacks the BLOCKED_OPERATOR Store refusal"
+done
+if [[ -s "${hw}/aienos-ck.elf" ]]; then
+    nmtool="${cross}nm"
+    y="$("${nmtool}" "${hw}/aienos-ck.elf" | grep -E ' (ck_store_test_keys|ck_store_test_uuid)$' || true)"
+    [[ -z "${y}" ]] && ok "no TEST Store key symbols in the hardware staging ELF" || bad "TEST symbols: ${y}"
+    "${nmtool}" "${hw}/aienos-ck.elf" | grep -qE ' ck_store_production_keys$' \
+        && ok "ck_store_production_keys (BLOCKED_OPERATOR seam) is linked" || bad "ck_store_production_keys not linked"
+fi
+
+# ---- 4. control: the default image keeps the labelled TEST keys -----------
+if mk full >"${tmp}/def.log" 2>&1 && grep -aqF 'AIENOS-LANE18-TEST-KVOL-NOT-SECRET' "${out}/full/aienos-ck.elf"; then
+    ok "control: default full image still carries the labelled TEST Store label"
+else
+    bad "control: default full image lacks the TEST Store label or did not build"
+fi
+
+if [[ "${fails}" == 0 ]]; then
+    echo "CK_OWNER_KEYS_CHECK: PASS"
+else
+    echo "CK_OWNER_KEYS_CHECK: FAIL failures=${fails}"
+    exit 1
+fi