code wiki / _hdl_build / nx_reg_sign.nx

nx_reg_sign.nx

buildroot/runtime/_hdl_build/nx_reg_sign.nx

6139 B133 linesdepth 6pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_reg_sign.nx -- SOVEREIGN registry integrity tool (operator directive 2026-07-16, the security debt the maturity census SURFACED: "daemons.reg is owner-writable plain file -> local write grants revive-exec"). Signs / verifies a registry file with HMAC-SHA256 keyed by the machine-bound secret, so the daemon supervisor can REFUSE to apply a registry that was changed without going through the signer. HONEST SCOPE (stated, not oversold -- this session's whole ethic): this is TAMPER-EVIDENCE + FAIL-SAFE integrity, NOT prevention against a same-uid attacker who can read the 0600 key. What it genuinely gives: - a corrupt/truncated/partial-written registry FAILS verify -> supervisor holds last-good (never-brick) - a different-uid or remote-dropped registry can't be validly signed (they can't read the 0600 key) - ANY change to daemons.reg without re-signing is CAUGHT + surfaced (SECURITY event on /status) within one supervisor cycle -> silent revive-exec injection becomes impossible; it is seen + held. The L3 rung (root-held ed25519 asymmetric key so even the same uid as the supervisor can't forge) is the stated next step; signing is a DELIBERATE act (not auto-run), so an un-re-signed change genuinely means "changed outside the signer" = the threat. usage: nx_reg_sign sign <reg-path> <key-path> -> writes <reg-path>.sig (64 hex chars), exit 0 nx_reg_sign verify <reg-path> <key-path> -> exit 0 match · 3 mismatch · 4 sig-absent · 5 reg-unreadable · 2 usage license_tier: ORIGINAL module: nishi-core.ops.reg_sign

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_hmac.nx nx_reg_sign.nx

imports: nx_syscalls.nxnx_hmac.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main rs_p sys_write rs_slen sys_mmap rs_compute sys_mmap ↻ rs_read sys_openat_rd sys_read sys_close hmac_sha256 sys_mmap ↻ sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word sha256_final blk_set_byte ↻ sha256_compress ↻ sha256_init ↻ sha256_update ↻ sha256_final ↻ rs_hex rs_streq rs_write_atomic sys_mmap ↻ sys_openat_wr sys_write ↻ sys_close ↻ sys_renameat rs_read ↻

structs

none

consts

24const RS_CAP: i64 = 262144
25const RS_KEYCAP: i64 = 4096

functions

27func rs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: rs_p
28func rs_p(s: *u8) -> i64 { sys_write(1, s, rs_slen(s)); return 0 }
called by 1: main calls 2: sys_writers_slen
29func rs_streq(a: *u8, b: *u8) -> i64
called by 1: main
35func rs_read(path: *u8, buf: *u8, cap: i64) -> i64
45func rs_hex(src: *u8, n: i64, dst: *u8) -> i64
called by 1: rs_compute
56func rs_write_atomic(path: *u8, buf: *u8, n: i64) -> i64
76func rs_compute(reg: *u8, key: *u8, out: *u8) -> i64
89func main(argc: i64, argv: *i64) -> i64