code wiki / (root) / nx_session_id.nx

nx_session_id.nx

buildroot/runtime/nx_session_id.nx

3074 B111 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic session
docsdependenciesstructsconstsfunctions

about

session_id.nx -- cryptographically strong session identifiers. Session IDs are the primary auth artefact after login. They must be: - Unpredictable (>= 128 bits entropy) - URL + cookie-safe characters - Fixed length (makes brute-force scans inherently bounded) - Cheap to validate format before DB lookup This module generates 32-char session IDs = 192 bits entropy over the URL-safe alphabet (A-Z a-z 0-9 - _). Matches the security profile of Django / Rails / Express session IDs. Composes rand.nx. Invariants: SI1 Every char from the 64-char URL-safe alphabet. SI2 Length fixed at 32 (customisable via session_id_with_len). SI3 Format-validation helper so callers can reject malformed IDs before DB lookup.

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_rand.nx nx_session_id.nx

imports: nx_syscalls.nxnx_rand.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 session_id_new session_id_with_len rand_bytes rand_open_urandom sys_openat_rd sys_read sys_close si_map session_id_valid si_is_valid_char

structs

none

consts

31const SESSION_ID_LEN: i64 = 32

functions

34func si_map(v: i64) -> i64
called by 1: session_id_with_len
43func si_is_valid_char(b: i64) -> i64
called by 1: session_id_valid
59func session_id_with_len(out: *u8, n: i64) -> i64
called by 1: session_id_new calls 2: rand_bytessi_map
70func session_id_new(out: *u8) -> i64
called by 1: main calls 1: session_id_with_len
76func session_id_valid(id: *u8, n: i64) -> i64
called by 1: main calls 1: si_is_valid_char
87func main() -> i64