code wiki / (root) / basic_auth.nx

basic_auth.nx

buildroot/runtime/basic_auth.nx

6533 B195 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

basic_auth.nx -- HTTP Basic Authentication (RFC 7617). Authorization header format: Authorization: Basic BASE64(username:password) The oldest HTTP auth scheme. Still everywhere: admin-panel login, IoT device configs, CI runner tokens, registry push, htpasswd-protected directories, internal tools. Combined with HTTPS it's adequate; on plain HTTP it's trivially sniffable. We ship encoder + decoder + Authorization-header matcher. Composes base64.nx. Invariants: BA1 Encoded output is \"Basic \" + base64(\"user:pass\"), one ASCII line. BA2 Decoder strips the leading \"Basic \" prefix case- insensitively per RFC 7617 ยง2. BA3 username + password round-trip byte-exact. BA4 Compare uses constant-time memcmp via ct.nx for the password half -- timing attacks on admin logins are real.

dependencies 3 imports · 0 importers

syscalls.nx base64.nx ct.nx basic_auth.nx

imports: syscalls.nxbase64.nxct.nx

imported by: nobody (leaf or entry point)

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

main basic_auth_encode b64_encode b64_enc_char basic_auth_decode b64_decode b64_grab b64_dec_char basic_auth_verify ct_memcmp ct_eq

structs

none

consts

28const BA_ERR_FORMAT: i64 = -1
29const BA_ERR_SHORT: i64 = -2

functions

34func basic_auth_encode(username: *u8, u_len: i64,
called by 1: main calls 1: b64_encode
73func basic_auth_decode(hdr: *u8, n: i64,
called by 1: main calls 1: b64_decode
137func basic_auth_verify(user_got: *u8, u_got_len: i64,
called by 1: main calls 1: ct_memcmp
161func main() -> i64 {