code wiki / _hdl_build / nx_hmacalt_extvec_gate.nx

nx_hmacalt_extvec_gate.nx

buildroot/runtime/_hdl_build/nx_hmacalt_extvec_gate.nx

13676 B287 linesdepth 7pulls 9 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_hmacalt_extvec_gate.nx -- ADJUDICATES the hmac.nx FORK against RFC 4231 (all 7 HMAC-SHA-256 vectors). One import apart from nx_hmac_extvec_gate: nx_hmac_extvec_gate -> nx_hmac.nx -> nx_sha256.nx (7/7 GREEN) nx_hmacalt_extvec_gate -> hmac.nx -> sha256.nx (9 live importers, NEVER GRADED) Symbol parity verified: hmac.nx's functions all exist in nx_hmac.nx. NOTE sha256.nx is a SHIM re-exporting nx_sha256.nx, so the CORE beneath this fork is already the validated one -- what is under test here is the HMAC WRAPPER itself (key padding, ipad/opad, the key-longer-than-block branch that RFC 4231 cases 6 and 7 exercise with a 131-byte key). * TESTING A WRAPPER WHOSE CORE IS ALREADY EXONERATED IS STILL WORTH DOING -- HMAC's most commonly botched part is the key-shortening branch, which lives in the wrapper, not the hash. // nx_hmacalt_extvec_gate.nx -- HMAC-SHA-256 vs RFC 4231, ALL SEVEN published test cases. SUPERSEDES the single-case version. Going from 1 vector to 7 matters because the cases are deliberately chosen by the authority to hit DIFFERENT code paths, and the ones I was NOT running are the interesting ones: case 3 uses a 50-byte repeated data block, cases 6 and 7 use a 131-BYTE KEY (longer than the 64-byte SHA-256 block, so the key must be HASHED first), and case 5 publishes a TRUNCATED 128-bit MAC. ★A gate that ran only case 1 would never touch the key-longer-than-block branch -- the single most commonly botched part of HMAC. Running one vector from a seven-vector suite is not "validated against RFC 4231"; it is validated against one line of it. ⚠VARIABLE-LENGTH FIELDS, HANDLED BY TERMINATOR NOT BY LENGTH. Key/Data lengths differ per case and their annotations are inconsistent -- "(20 bytes)" for keys but ("Hi There") for data -- so a length cannot be read uniformly. Instead the hex run is read until the first `(`, which terminates both forms. ⚠THE MAC HAS NO `(` TERMINATOR and case 5's is TRUNCATED to 16 bytes, so it is read as hex pairs until a pair is not both-hex, capped at 32. That correctly stops at the section heading that follows -- note "4.3." begins with '4', a HEX DIGIT, and is only rejected because '.' is not: the PAIR rule saves this, a single-nibble rule would have swallowed it. Construction unchanged: no expected value in this source, document pinned to a socket-time digest, every key/data/MAC read from that pinned document, and a completeness check that refuses GREEN below 7. license_tier: ORIGINAL expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_sha256_wasm.nx hmac.nx nx_gate_verdict.nx nx_hmacalt_extvec_gate.nx

imports: nx_syscalls.nxnx_sha256_wasm.nxhmac.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main w sys_write sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close nx_sha256_one_shot _h_set _sha256_compress _blk_word_be _rotr32 _h_get _sha256_k _h_set ↻ _h_get ↻ hexnib wb sys_write ↻ findfrom starts find_key_label

structs

none

consts

none

functions

38func w(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 2: nnmain calls 1: sys_write
39func wb(b: *u8, n: i64) -> i64 { sys_write(1, b, n); return 0 }
called by 1: main calls 1: sys_write
41func nn(v: i64) -> i64
called by 1: main calls 3: wsys_mmapsys_write
55func hexnib(v: i64) -> i64 { if v < 10 { return 48 + v } return 87 + v }
called by 1: main
57func hexval(c: i64) -> i64
called by 1: parserun
64func isws(c: i64) -> i64
called by 1: parserun
72func starts(b: *u8, n: i64, at: i64, s: *u8) -> i64
called by 1: findfrom
82func findfrom(b: *u8, n: i64, s: *u8, from: i64) -> i64
called by 2: find_key_labelmain calls 1: starts
93func parserun(b: *u8, n: i64, from: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 2: iswshexval
171func find_key_label(b: *u8, n: i64, from: i64) -> i64
called by 1: main calls 1: findfrom
184func main() -> i64