Phase 8 C (5/n): Zuse's cert wired to the fence -- first-boot mint works
Replaces the crashed NVRAM approach entirely. New include/starkernel/zuse_cert_devblock.h: a standalone on-disk record (magic + version + 32-byte seed + 32-byte pubkey + a real CRC-64/ISO from day one, same discipline homeblocks_sig_t established) occupying devblock_from_top=0 of the fence. Its own header, not inlined at the boot call site, since the still-open MINT word will be a second consumer of this exact format. kernel_main.c's mint-or-load logic now reads the fence, installs an existing valid cert, or mints fresh via virtio_rng+ed25519_keygen and writes it. Runs right after virtio_rng_init(), before capsule_birth_mama() -- unlike the crashed NVRAM attempt, raw block I/O against Artemis's already-proven device has no boot-timing risk, so the earlier "re-invoke ACL-ZUSE-BOOT after Mama birth" workaround is gone; ACL.4th's self-activating ACL-ZUSE-BOOT sees a correct cert on its one ordinary pass. Verified independently across every real scenario, never trusting the kernel's own report: fresh mint decodes correctly on disk with a CRC confirmed by a from-scratch Python re-implementation of the algorithm; a reboot without reformatting loads back byte-for-byte identical seed/pubkey (genuinely "mint once, ever"); a pre-fence volume refuses cleanly (no crash, no silent data loss, honest "not persistent" reporting); the real, untouched disk/artemis.img exercises the same graceful-refusal path identically on all three architectures. Phase 8's core arc is now functionally complete: real entropy -> real signing -> real anti-file block-native persistence -> a first-boot mint that survives reboots. Still open: the ongoing MINT word for minting additional regular users. Documented in FABRIC-3.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U14ET9CWAtbQMbYqomKgXd
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
6e9c1d3bc2
commit
a8692681a8
@@ -67,6 +67,7 @@ EFI_RUNTIME_SERVICES *g_sk_runtime_services = NULL;
|
||||
#include "starkernel/virtio_blk.h"
|
||||
#include "starkernel/virtio_rng.h"
|
||||
#include "starkernel/ed25519.h"
|
||||
#include "starkernel/zuse_cert_devblock.h"
|
||||
#include "starkernel/virtio_input.h"
|
||||
#include "starkernel/xhci_driver.h"
|
||||
#include "block_subsystem.h"
|
||||
@@ -630,6 +631,63 @@ static void kernel_main_deep(BootInfo *boot_info) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Phase 8: Zuse first-boot mint-then-load, via the top-of-device
|
||||
* system-metadata fence (block_subsystem.h's blk_meta_zone_read()/
|
||||
* write(), FABRIC-3.md Phase 8 §C) -- NOT UEFI NVRAM. An earlier
|
||||
* NVRAM-based attempt page-faulted inside OVMF's variable service on
|
||||
* a real flash write (root-caused, documented, reverted); raw block
|
||||
* I/O against Artemis's already-proven virtio-blk device has none of
|
||||
* that risk and needs no runtime-services timing care at all. Runs
|
||||
* here, before capsule_birth_mama() below, so ACL.4th/zuse.4th's
|
||||
* self-activating ACL-ZUSE-BOOT sees a populated cert on its one,
|
||||
* ordinary first pass -- no re-invocation workaround needed this
|
||||
* time. "Mint once, ever": a valid ZUSE_CERT_DEVBLOCK_MAGIC record
|
||||
* in the fence means a prior boot already minted -- load it back
|
||||
* rather than generating a new one. Graceful no-op if there's no
|
||||
* disk-backed device or no entropy source; Zuse simply won't
|
||||
* authenticate this boot. */
|
||||
{
|
||||
zuse_cert_devblock_t rec;
|
||||
int found = 0;
|
||||
if (blk_meta_zone_read(0, (uint8_t *)&rec) == 0 &&
|
||||
rec.magic == ZUSE_CERT_DEVBLOCK_MAGIC &&
|
||||
rec.version == ZUSE_CERT_DEVBLOCK_VERSION) {
|
||||
uint64_t want_crc = compute_crc64((const uint8_t *)&rec, offsetof(zuse_cert_devblock_t, crc));
|
||||
if (want_crc == rec.crc) found = 1;
|
||||
}
|
||||
|
||||
VM *zuse_vm = (VM *)mama_vm;
|
||||
if (found) {
|
||||
if (vm_zuse_cert_install(zuse_vm, rec.seed, rec.pubkey) == 0) {
|
||||
console_println("Zuse: cert loaded from block fence");
|
||||
}
|
||||
} else if (virtio_rng_ready()) {
|
||||
uint8_t seed[32];
|
||||
if (virtio_rng_get_bytes(seed, sizeof(seed)) == 0) {
|
||||
uint8_t pubkey[32];
|
||||
ed25519_keygen(seed, pubkey);
|
||||
if (vm_zuse_cert_install(zuse_vm, seed, pubkey) == 0) {
|
||||
zuse_cert_devblock_t wrec;
|
||||
memset(&wrec, 0, sizeof(wrec));
|
||||
wrec.magic = ZUSE_CERT_DEVBLOCK_MAGIC;
|
||||
wrec.version = ZUSE_CERT_DEVBLOCK_VERSION;
|
||||
memcpy(wrec.seed, seed, 32);
|
||||
memcpy(wrec.pubkey, pubkey, 32);
|
||||
wrec.crc = compute_crc64((const uint8_t *)&wrec, offsetof(zuse_cert_devblock_t, crc));
|
||||
if (blk_meta_zone_write(0, (const uint8_t *)&wrec) == 0) {
|
||||
console_println("Zuse: minted, fuse blown");
|
||||
} else {
|
||||
console_println("Zuse: minted but fence write FAILED (not persistent)");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console_println("Zuse: entropy read failed, not minted this boot");
|
||||
}
|
||||
} else {
|
||||
console_println("Zuse: no cert and no entropy source, not minted this boot");
|
||||
}
|
||||
}
|
||||
|
||||
/* item 4.3.5c: virtio-keyboard-pci, riscv64 only today. Unconditional
|
||||
* call site, same as virtio_blk_find_artemis() above -- the function
|
||||
* itself no-ops with a console message on architectures/boards where
|
||||
|
||||
Reference in New Issue
Block a user