code wiki / (root) / session_id.nx

session_id.nx

buildroot/runtime/session_id.nx

2922 B105 linesdepth 4pulls 4 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

syscalls.nx rand.nx session_id.nx

imports: syscalls.nxrand.nx

imported by: nobody (leaf or entry point)

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

main session_id_new session_id_with_len rand_bytes rand_open_urandom sys_read si_map session_id_valid si_is_valid_char

structs

none

consts

25const SESSION_ID_LEN: i64 = 32

functions

28func si_map(v: i64) -> i64 {
called by 1: session_id_with_len
37func si_is_valid_char(b: i64) -> i64 {
called by 1: session_id_valid
53func session_id_with_len(out: *u8, n: i64) -> i64 {
called by 1: session_id_new calls 2: rand_bytessi_map
64func session_id_new(out: *u8) -> i64 {
called by 1: main calls 1: session_id_with_len
70func session_id_valid(id: *u8, n: i64) -> i64 {
called by 1: main calls 1: si_is_valid_char
81func main() -> i64 {