code wiki / _hdl_build / nx_token.nx

nx_token.nx

buildroot/runtime/_hdl_build/nx_token.nx

3184 B60 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic token
docsdependenciesstructsconstsfunctions

about

nx_token.nx -- CMS layered-spec task #3 (L3-crypto, lowest BUILD): a secure random token for session IDs and CSRF tokens. Grounded (deep-research wpq1btr1l, OWASP/NIST primary): session IDs need >=64 bits of CSPRNG entropy, CSRF synchronizer tokens >=128 bits, generated by a CSPRNG. We read the kernel CSPRNG (/dev/urandom) -- NOT a fast PRNG -- and hex-encode. 16 bytes = 128 bits (covers both). Bottom-up: L0 file read -> L3 token. Built by the team; Engineer gate = the property test below (length + uniqueness + non-degenerate). Hands a tested deliverable UP to L7 (cookie/session) and the CSRF binder. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_token.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sec_token sys_openat_rd sys_mmap ↻ sys_read sys_close hexc tk_puts sys_write sys_write ↻ sys_exit

structs

none

consts

none

functions

9func tk_puts(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 1: main calls 1: sys_write
11func hexc(v: i64) -> u8 { if v < 10 { return (48 + v) as u8 } return (97 + (v - 10)) as u8 }
called by 1: sec_token
14func sec_token(out: *u8, nbytes: i64) -> i64
31func main() -> i64