feat(kernel): the real Zuse's stick recognised, attached at the chain's tail; her session (#92, 4.7) [skip ci]
A GPT stick with an identity partition and no Artemis, the system stick in and its marker naming a real Zuse: checked against the real key; a match attached and logged in (a running session moves to her); no match: 'not this system's Zuse stick -- not used'. Arriving first, it is remembered and checked when the marker is read. Builds on three ISAs; mint_zuse running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
@@ -106,6 +106,10 @@ static sk_v4_drive_t *g_offered;
|
||||
/* the last stick turned away as not this system's (or handed back by a mint
|
||||
* that was refused): still plugged in, so a mint offers it first */
|
||||
static sk_v4_drive_t *g_spare;
|
||||
/* a stick that looks like the real Zuse's (an identity partition, no
|
||||
* Artemis) and arrived before the system stick: checked once it is in
|
||||
* (plan 2026-10-29-stick-5, Review Focus 1) */
|
||||
static sk_v4_drive_t *g_pending_real;
|
||||
static const BootDisk *g_boot_disk; /* the loader's: the disk it booted from */
|
||||
static int g_stick_in; /* a stick's Artemis partition is attached */
|
||||
|
||||
@@ -216,11 +220,12 @@ static void sk_v4_login(blkio_dev_t *dev, const uint8_t seed[32], const uint8_t
|
||||
console_fb_mirror(1);
|
||||
console_fb_enable_ttf();
|
||||
console_println(line);
|
||||
if (!g_zuse_cert_installed) {
|
||||
memcpy(g_zuse_seed, seed, 32);
|
||||
memcpy(g_zuse_pubkey, pubkey, 32);
|
||||
g_zuse_cert_installed = 1;
|
||||
}
|
||||
/* on v4 the installed key is the logged-in Zuse's, set at each login --
|
||||
* the proxy's or the real Zuse's (plan 2026-10-29-stick-5, my calls);
|
||||
* v3's one-way vm_zuse_cert_install() is v3's VM's and is not touched */
|
||||
memcpy(g_zuse_seed, seed, 32);
|
||||
memcpy(g_zuse_pubkey, pubkey, 32);
|
||||
g_zuse_cert_installed = 1;
|
||||
memcpy(g_zuse_root_pubkey, pubkey, 32); /* as v3's install_and_activate() */
|
||||
g_zuse_root_known = 1;
|
||||
g_zuse_dev = dev;
|
||||
@@ -268,6 +273,39 @@ static int sk_v4_genesis(blkio_dev_t *dev, blkio_dev_t *art)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* A stick that looks like the real Zuse's -- a GPT disk (just read into
|
||||
* g_gpt_parts) with a StarshipOS identity partition and no Artemis -- and the
|
||||
* system stick in, its marker naming a real Zuse: her identity checked
|
||||
* against the marker's real key. A match is attached (the block chain's tail:
|
||||
* after the system stick's two partitions) and her session begins, or goes
|
||||
* on as hers if the proxy's was running (after MINT-ZUSE). Returns 1 when the
|
||||
* stick was hers to judge (a match, or "not this system's Zuse stick"), 0
|
||||
* when it is no Zuse stick of this system's at all. */
|
||||
static int sk_v4_real_zuse_arrived(sk_v4_drive_t *d, unsigned nparts)
|
||||
{
|
||||
homeblocks_sig_t sig;
|
||||
homeblocks_sig_result_t sig_rc;
|
||||
uint8_t seed[32], pubkey[32];
|
||||
int ii = gpt_find(g_gpt_parts, nparts, gpt_type_starship_identity);
|
||||
|
||||
if (!g_marker.present || !g_marker.has_real || ii < 0) return 0;
|
||||
if (gpt_part_open(&d->part, &d->part_state, &d->raw, &g_gpt_parts[ii]) != BLKIO_OK) return 0;
|
||||
sig_rc = homeblocks_sig_check(&d->part, HOMEBLOCKS_SIG_START_FBLOCK, &sig);
|
||||
if (capsule_zuse_boot_check_key(&d->part, sig_rc, &sig, g_marker.real, seed, pubkey) != ZUSE_DRIVE_HERS) {
|
||||
console_println("Zuse: not this system's Zuse stick -- not used");
|
||||
return 1;
|
||||
}
|
||||
if (blk_subsys_attach_device(&d->part) != BLK_OK) {
|
||||
console_println("xhci: USB MSC block-subsystem attach failed");
|
||||
return 1;
|
||||
}
|
||||
d->used = &d->part;
|
||||
g_proxy_fallback = 0;
|
||||
sk_v4_login(&d->part, seed, pubkey, "Zuse: identity confirmed from attached thumbdrive");
|
||||
memset(seed, 0, sizeof seed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* A drive that has arrived. This system's stick: its Artemis partition is
|
||||
* attached (the first disk slot, the block subsystem's), Zuse's public key is
|
||||
* read from its genesis marker, then its identity partition is attached and,
|
||||
@@ -302,6 +340,12 @@ static int sk_v4_drive_arrived(sk_v4_drive_t *d)
|
||||
return 1;
|
||||
}
|
||||
if (gpt_rc != GPT_OK || !sk_v4_is_this_stick(nparts)) {
|
||||
/* the real Zuse's stick: an identity partition and no Artemis */
|
||||
if (gpt_rc == GPT_OK && gpt_find(g_gpt_parts, nparts, gpt_type_starship_identity) >= 0 &&
|
||||
gpt_find(g_gpt_parts, nparts, gpt_type_starship_artemis) < 0) {
|
||||
if (!g_stick_in) { g_pending_real = d; return 1; } /* checked when the system stick is in */
|
||||
if (sk_v4_real_zuse_arrived(d, nparts)) return 1;
|
||||
}
|
||||
console_println("USB: a drive that is not this system's stick -- not used");
|
||||
if (gpt_rc != GPT_EIO) g_spare = d;
|
||||
return 1;
|
||||
@@ -363,6 +407,16 @@ static int sk_v4_drive_arrived(sk_v4_drive_t *d)
|
||||
if (which != ZUSE_DRIVE_HERS) return 1;
|
||||
if (g_marker.has_real) {
|
||||
g_proxy_fallback = 1; /* a real Zuse exists: the proxy gets no session */
|
||||
/* her stick came first: checked now that the marker is read */
|
||||
if (g_pending_real) {
|
||||
sk_v4_drive_t *r = g_pending_real;
|
||||
g_pending_real = (sk_v4_drive_t *)0;
|
||||
if (gpt_read(&r->raw, g_gpt_parts, SK_V4_GPT_PARTS, &nparts) != GPT_OK ||
|
||||
!sk_v4_real_zuse_arrived(r, nparts)) {
|
||||
console_println("USB: a drive that is not this system's stick -- not used");
|
||||
g_spare = r;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
sk_v4_login(dev, seed, pubkey, "Zuse: identity confirmed from attached thumbdrive");
|
||||
@@ -378,6 +432,7 @@ static void sk_v4_drive_left(sk_v4_drive_t *d)
|
||||
|
||||
if (d == g_offered) g_offered = (sk_v4_drive_t *)0; /* the offered stick, pulled */
|
||||
if (d == g_spare) g_spare = (sk_v4_drive_t *)0;
|
||||
if (d == g_pending_real) g_pending_real = (sk_v4_drive_t *)0;
|
||||
|
||||
if (dev) {
|
||||
d->used = (blkio_dev_t *)0;
|
||||
|
||||
Reference in New Issue
Block a user