code wiki / _hdl_build / nx_efivarstore.nx
nx_efivarstore.nx
buildroot/runtime/_hdl_build/nx_efivarstore.nx
about
nx_efivarstore.nx -- F103e RUNG 11a: READ a UEFI authenticated variable store.
The enrolment rung needs PK / KEK / db entries, which means knowing the varstore layout and the
EFI GUIDs. ★★★★★★I AM NOT WRITING THOSE GUIDs FROM MEMORY. `OVMF_VARS_4M.ms.fd` ships with
Microsoft's keys already enrolled -- it is a WORKED EXAMPLE OF THE EXACT FORMAT, on disk, free.
So: parse it, print what is really there, and take every constant from the artifact.
**THE FORMAT COMES FROM THE FILE, NOT FROM RECALL** -- the same rule that has caught me three
times today when I trusted a filename over a symbol table.
Layout (EDK2 VariableFormat.h), all little-endian:
EFI_FIRMWARE_VOLUME_HEADER : ZeroVector[16], FileSystemGuid[16], FvLength[8], Signature "_FVH",
Attributes[4], HeaderLength[2], Checksum[2], ExtHeaderOffset[2],
Reserved[1], Revision[1], BlockMap...
VARIABLE_STORE_HEADER : Signature GUID[16], Size[4], Format[1], State[1], Reserved[6]
AUTHENTICATED_VARIABLE_HEADER (60 B) : StartId[2]=0x55AA, State[1], Reserved[1], Attributes[4],
MonotonicCount[8], TimeStamp[16], PubKeyIndex[4], NameSize[4],
DataSize[4], VendorGuid[16] then Name(UCS-2) then Data,
each entry 4-byte aligned.
Usage: nx_efivarstore dump <vars.fd> -- enumerate every variable
nx_efivarstore selftest <vars.fd> -- teeth against a REAL MS-key varstore
Exit: 0 GREEN | 1 RED | 3 UNPROVEN (cannot read input).
license_tier: ORIGINAL
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_efivars_enrol.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 26 | const EV_HDR: i64 = 60 // AUTHENTICATED_VARIABLE_HEADER |
| 27 | const EV_STARTID: i64 = 0x55AA |
| 28 | const EV_ADDED: i64 = 0x3F // VAR_ADDED |
| 29 | const EV_MAXVARS: i64 = 512 |
functions
| 31 | func ev_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 32 | func ev_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 } |
| 33 | func ev_fn(fd: i64, v: i64) -> i64 |
| 43 | func ev_hexb(b: *u8, off: i64, n: i64) -> i64 |
| 54 | func ev_eq_str(a: *u8, b: *u8) -> i64 called by 1: main |
| 60 | func ev_r16(b: *u8, o: i64) -> i64 { return (b[o] as i64) | ((b[o+1] as i64) << 8) } |
| 61 | func ev_r32(b: *u8, o: i64) -> i64 |
| 67 | func ev_first_var(b: *u8, len: i64, store_off_p: *i64) -> i64 called by 8: en_x509guid_from_msen_vendor_guiden_sha256guid_from_msen_build_hashdben_builden_selftest+2 calls 2: ev_r16ev_r32 |
| 86 | func ev_walk(b: *u8, len: i64, first: i64, store_off: i64, verbose: i64, |
| 157 | func ev_selftest(path: *u8) -> i64 |
| 227 | func main(argc: i64, argv: *i64) -> i64 |