code wiki / _hdl_build / nx_efivars_enrol.nx
nx_efivars_enrol.nx
buildroot/runtime/_hdl_build/nx_efivars_enrol.nx
about
nx_efivars_enrol.nx -- F103e RUNG 11b: enrol OUR key into a UEFI variable store.
The last software rung. Builds an EFI_SIGNATURE_LIST around our self-signed cert and writes PK,
KEK and db into a varstore derived from the EMPTY (setup-mode) OVMF varstore. Booting secboot
firmware against it should put the machine in USER MODE with OUR key as the authority -- so the
decisive test is a PAIR: our SIGNED image accepted, an UNSIGNED image refused. Either alone proves
nothing (a varstore that failed to load would accept both; a broken one would refuse both).
★★★★★★EVERY CONSTANT IS TAKEN FROM THE ARTIFACT, NOT FROM MEMORY. `OVMF_VARS_4M.ms.fd` has PK/KEK/db
already enrolled, so the vendor GUIDs, the attribute word, and even EFI_CERT_X509_GUID (which is
literally the first 16 bytes of the real `db` data) are READ OUT OF IT. Writing a UEFI GUID from
recall is a fabricated constant, and a wrong one here fails in a way that looks like "Secure Boot
just doesn't like us".
EFI_SIGNATURE_LIST: SignatureType[16] | SignatureListSize[4] | SignatureHeaderSize[4] |
SignatureSize[4] | (header) | { SignatureOwner[16] | SignatureData[] }...
Usage: nx_efivars_enrol build <empty_vars.fd> <ms_vars.fd> <out_vars.fd>
nx_efivars_enrol selftest <empty_vars.fd> <ms_vars.fd>
Exit: 0 GREEN | 1 RED | 3 UNPROVEN.
license_tier: ORIGINAL
dependencies 18 imports · 0 importers
diagram shows first 10 each side; +8 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_sha256.nxnx_u2048.nxnx_u2048_mul.nxnx_rsa2048_mod.nxnx_rsa2048_mod_exp.nxnx_rsa2048_mont.nxnx_rsa2048_mod_exp_big.nxnx_asn1.nxnx_x509.nxnx_rsa_pkcs1_v1_5_sha256.nxnx_u2048_millerrabin.nxnx_u2048_smallops.nxnx_rsa_keygen.nxnx_rsa_pkcs1_sign.nxnx_x509_emit.nxnx_efivarstore.nxnx_pe_authhash.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 40 | const EN_MAGIC_4096: i64 = 4096 |
| 41 | const EN_MAGIC_20260808: i64 = 20260808 |
| 42 | const EN_MAGIC_1024: i64 = 1024 |
| 43 | const EN_MAGIC_8192: i64 = 8192 |
| 44 | const EN_MAGIC_65537: i64 = 65537 |
| 45 | const EN_MAGIC_4097: i64 = 4097 |
| 46 | const EN_MAGIC_16384: i64 = 16384 |
| 48 | const EN_ATTRS: i64 = 39 // MEASURED from the MS varstore: NV|BS|RT|TIME_BASED_AUTH_WRITE |
functions
| 50 | func en_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 51 | func en_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 52 | func en_fn(fd: i64, v: i64) -> i64 |
| 62 | func en_eq_str(a: *u8, b: *u8) -> i64 called by 1: main |
| 68 | func en_w32(b: *u8, o: i64, v: i64) -> i64 |
| 76 | func en_siglist(out: *u8, x509guid: *u8, cert: *u8, certlen: i64) -> i64 |
| 93 | func en_put_var(b: *u8, off: i64, name: *u8, guid: *u8, data: *u8, dlen: i64) -> i64 |
| 127 | func en_x509guid_from_ms(ms: *u8, mslen: i64, out16: *u8) -> i64 |
| 143 | func en_vendor_guid(ms: *u8, mslen: i64, name: *u8, nlen: i64, out16: *u8) -> i64 |
| 165 | func en_sha256guid_from_ms(ms: *u8, mslen: i64, out16: *u8) -> i64 |
| 183 | func en_build_hashdb(emptyp: *u8, msp: *u8, imgp: *u8, outp: *u8) -> i64 |
| 256 | func en_build(emptyp: *u8, msp: *u8, outp: *u8, quiet: i64) -> i64 called by 2: en_selftestmain calls 14: sys_mmapsys_read_fileen_pen_x509guid_from_msen_vendor_guidu2048_alloc+8 |
| 314 | func en_selftest(emptyp: *u8, msp: *u8) -> i64 |
| 445 | func main(argc: i64, argv: *i64) -> i64 |