code wiki / _hdl_build / _ar2_minrepro.nx
_ar2_minrepro.nx source
↩ module page · 47 lines · 2637 B
1// _ar2_minrepro.nx -- REGRESSION REPRO for the argon2id runtime defect (issue filed 2026-06-10).
2// Isolated: nx_argon2id_hash segfaults (sig11) with the test's EXACT params + identical ctx alloc;
3// the crash is in STEP 1 `_ar2_h0` (blake2b H0), BEFORE any memory fill. blake2b compiles to valid
4// .s, so this is a RUNTIME codegen/exec defect (miscompile-class), not a source/integration bug.
5// When the crypto/toolchain workers fix it, THIS module must print "_ar2_h0 returned rc=0" and
6// "hash returned rc=0" -> it becomes the argon2id regression gate. NOT my machine_key integration.
7import "nx_syscalls.nx"
8import "nx_argon2id.nx"
9func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
10func _pn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
11func mk_ctx(m_kib: i64) -> *NxArgon2idCtx {
12 let raw: *u8 = sys_mmap(NX_ARGON2ID_CTX_BYTES)
13 let ctx: *NxArgon2idCtx = raw as *NxArgon2idCtx
14 ctx.memory_blocks = sys_mmap(m_kib * 1024)
15 ctx.h0_buf = sys_mmap(64)
16 ctx.prepend_buf = sys_mmap(2048)
17 ctx.prev_buf = sys_mmap(64)
18 ctx.curr_buf = sys_mmap(64)
19 ctx.zero_block = sys_mmap(1024)
20 ctx.z_buf = sys_mmap(1024)
21 ctx.tmp_block = sys_mmap(1024)
22 ctx.addr_block = sys_mmap(1024)
23 ctx.final_block = sys_mmap(1024)
24 ctx.h0_input = sys_mmap(2048)
25 ctx.b2b_ctx = sys_mmap(NX_BLAKE2B_CTX_BYTES) as *NxBlake2b
26 ctx.b2b_buf = sys_mmap(128)
27 ctx.b2b_sv = sys_mmap(128) as *i64
28 ctx.b2b_sm = sys_mmap(128) as *i64
29 ctx.g_r = sys_mmap(1024) as *i64
30 ctx.g_rs = sys_mmap(1024) as *i64
31 ctx.g_col = sys_mmap(128) as *i64
32 return ctx
33}
34func main() -> i64 {
35 _p("minrepro: make_ctx(16)\n" as *u8)
36 let ctx: *NxArgon2idCtx = mk_ctx(16)
37 _p("minrepro: ctx built; step 1 = _ar2_h0 (blake2b) alone\n" as *u8)
38 let h0rc: i64 = _ar2_h0(ctx, "password" as *u8, 8, "somesalt" as *u8, 8, 1, 32, 16, 2)
39 _p("minrepro: _ar2_h0 returned rc=" as *u8); _pn(h0rc); _p(" (survived step 1)\n" as *u8)
40 _p("minrepro: step 2 = full nx_argon2id_hash(m=16,t=2,p=1,tag=32)\n" as *u8)
41 let tag: *u8 = sys_mmap(64)
42 let rc: i64 = nx_argon2id_hash(ctx, "password" as *u8, 8, "somesalt" as *u8, 8, 1, 32, 16, 2, tag)
43 _p("minrepro: hash returned rc=" as *u8); _pn(rc); _p("\n" as *u8)
44 if rc == 0 { _p("minrepro: OK first tag byte=" as *u8); _pn(tag[0] as i64); _p("\n" as *u8) }
45 sys_exit(0)
46 return 0
47}