code wiki / _hdl_build / nx_pattern_emit13_demo.nx
nx_pattern_emit13_demo.nx source
↩ module page · 53 lines · 2286 B
1// nx_pattern_emit13_demo.nx -- the TEAM authoring the STATE_MACHINE shape's first real machine
2// (no Claude core logic): _pe_tlshs = the TLS 1.3 server-flight ORDER VALIDATOR. States:
3// 0=START 1=WAIT_EE 2=WAIT_CERT 3=WAIT_CV 4=WAIT_FIN 5=CONNECTED; events = handshake msg kinds
4// 0=server_hello 1=encrypted_extensions 2=certificate 3=cert_verify 4=finished. Exactly the
5// canonical chain is defined; EVERYTHING else (reorder, replay-after-connect, skip) refuses --
6// the browser arc's out-of-order-handshake security property as an authored, gateable core.
7// ALSO proves the refusal rails: a table value past nstates and an out-of-range s0 are REFUSED.
8// license_tier: ORIGINAL
9import "nx_pattern_emit13.nx"
10import "nx_syscalls.nx"
11
12func d13_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
13
14// fill the 6x5 table: all undefined except the canonical chain
15func d13_table(spec: *i64) -> i64 {
16 spec[0] = 6
17 spec[1] = 5
18 spec[2] = 0
19 var i: i64 = 0
20 while i < 30 { spec[3 + i] = 0 - 1; i = i + 1 }
21 spec[3 + 0 * 5 + 0] = 1
22 spec[3 + 1 * 5 + 1] = 2
23 spec[3 + 2 * 5 + 2] = 3
24 spec[3 + 3 * 5 + 3] = 4
25 spec[3 + 4 * 5 + 4] = 5
26 return 0
27}
28
29func main() -> i64 {
30 let spec: *i64 = sys_mmap(8 * 40) as *i64
31 d13_table(spec)
32 let a: i64 = pe13_author_state_machine("_pe_tlshs" as *u8,
33 "runtime/_hdl_build/_pe_tlshs.nx" as *u8,
34 "runtime/_hdl_build/_pe_tlshs_test.nx" as *u8,
35 spec)
36 // rail 1: a transition target past nstates is REFUSED
37 d13_table(spec)
38 spec[3 + 7] = 17
39 let r1: i64 = pe13_author_state_machine("_pe_badsm" as *u8,
40 "/tmp/_pe_badsm.nx" as *u8, "/tmp/_pe_badsm_test.nx" as *u8, spec)
41 // rail 2: s0 out of range is REFUSED
42 d13_table(spec)
43 spec[2] = 6
44 let r2: i64 = pe13_author_state_machine("_pe_bads0" as *u8,
45 "/tmp/_pe_bads0.nx" as *u8, "/tmp/_pe_bads0_test.nx" as *u8, spec)
46 if a == 1 { if r1 == 0 { if r2 == 0 {
47 d13_w("TEAM AUTHORED MACHINE: _pe_tlshs (STATE_MACHINE shape 18 = TLS 1.3 flight-order validator) + bad-target and bad-s0 specs REFUSED -- verify with Engineer\n" as *u8)
48 sys_exit(0)
49 } } }
50 d13_w("author failed (or refusal rail broken)\n" as *u8)
51 sys_exit(1)
52 return 1
53}