code wiki / _hdl_build / nx_fw_capsule.nx

nx_fw_capsule.nx

buildroot/runtime/_hdl_build/nx_fw_capsule.nx

7502 B159 linesdepth 9pulls 13 transitivereach 8 importersview sourcekind tooltopic fw
docsdependenciesstructsconstsfunctions

about

nx_fw_capsule.nx -- Secure-Boot-grade signed firmware capsule (sovereign ed25519). module: nishi-core.genealogy.fw_capsule capability: CORE_COMPUTE (authenticity + integrity for firmware images and golden snapshots) sha256 (rungs 4-6) detects CORRUPTION but not FORGERY -- an attacker can recompute the hash over a malicious image. A real capsule is SIGNED: only an image signed by the trusted PLATFORM key is bootable. This is the Secure-Boot model, sovereign (our own ed25519, no vendor blob): capsule "NXC1" = magic(4) + payload_len(4) + payload + ed25519_signature(64) over magic||len||payload. cap_verify(path) = 1 ONLY IF the magic/len are intact AND the signature verifies against the baked TRUSTED platform public key. A corrupted OR forged (wrong-key) capsule -> 0 (rejected). In production the verifier holds ONLY the public key (the private seed is offline with the signer); here a fixed test seed lets the gate both sign and anchor -- ed25519 is deterministic (RFC 8032), so signatures + this gate are reproducible. Sovereign: nx_ed25519 + nx_syscalls. license_tier: ORIGINAL

dependencies 3 imports · 4 importers

nx_ed25519_signature.nx nx_itoa_lib.nx nx_syscalls.nx nx_fw_capsule.nx nx_cmos_signed.nx nx_fw_capsule_gate.nx nx_fw_signed_robust.nx nx_fw_uefi_capsule.nx

imports: nx_ed25519_signature.nxnx_itoa_lib.nxnx_syscalls.nx

imported by: nx_cmos_signed.nxnx_fw_capsule_gate.nxnx_fw_signed_robust.nxnx_fw_uefi_capsule.nx

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

main cp_puts sys_write sys_now_realtime_sec sys_mmap sys_clock_gettime_real sys_mmap ↻ cap_trusted_pub sys_mmap ↻ cap_plat_seed ed25519_pub_from_priv sys_mmap ↻ ed25519_sha512 sys_mmap ↻ sha512_init sha512_update sha512_blk_set_byte blk_get_i64 blk_set_i64 sha512_compress sys_mmap ↻ blk_get_i64 ↻ sha512_gamma0 sha512_gamma1 sha512_sigma1 sha512_ch sha512_k sha512_sigma0 sha512_maj sha512_final sha512_blk_set_byte ↻ sha512_compress ↻ ge_p3_alloc sys_mmap ↻ fe_alloc nx_scratch nx_scratch_init nx_scratch_oom sys_mmap ↻ fe_zero

structs

none

consts

18const CAP_MAGIC_65536: i64 = 65536
19const CAP_MAGIC_16777216: i64 = 16777216
21const CAP_HDR: i64 = 8 // magic(4) + payload_len(4)
22const CAP_SIG: i64 = 64 // ed25519 signature
23const CAP_MAXIMG: i64 = 16777216

functions

25func cp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 }
called by 5: maincgc_rowmainmainmain calls 1: sys_write
30func cp_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 3: mainmainmain calls 1: nxi_out
31func cp_read(path: *u8, lb: *i64) -> *u8
44func cp_write(path: *u8, buf: *u8, n: i64) -> i64
49func cp_wr_u32(buf: *u8, off: i64, v: i64) -> i64
called by 2: cap_makeuc_make
54func cp_rd_u32(buf: *u8, off: i64) -> i64
63func cap_plat_seed(out: *u8) -> i64 { var i: i64 = 0; while i < 32 { out[i] = ((i * 7 + 13) & 0xff) as u8; i = i + 1 } return 0 }
64func cap_trusted_pub(out: *u8) -> i64
71func cap_make(path: *u8, payload: *u8, plen: i64, seed32: *u8) -> i64
87func cap_verify(path: *u8) -> i64
107func cp_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != 0 as u8 { dst[off + i] = s[i]; i = i + 1 } return off + i }
108func cp_catn(dst: *u8, off: i64, v: i64) -> i64
called by 2: cap_pathmain calls 1: sys_mmap
118func cap_path(out: *u8, stem: *u8, epoch: i64, pid: i64) -> i64
called by 5: mainmainmainmainmain calls 2: cp_catcp_catn
124func cap_corrupt(path: *u8) -> i64
134func main() -> i64