code wiki / (root) / digest_auth.nx

digest_auth.nx

buildroot/runtime/digest_auth.nx

6488 B173 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

digest_auth.nx -- HTTP Digest authentication response builder. RFC 7616 / RFC 2617. Stronger than Basic auth (password not transmitted) but still obsolete compared to bearer tokens + TLS. Interop reality: many IP cameras, routers, printers, legacy enterprise apps, and Microsoft IIS sites use Digest. Challenge format (server -> client, 401 response): WWW-Authenticate: Digest realm=\"Protected\", nonce=\"abc123\", qop=\"auth\", algorithm=MD5 Response format (client -> server): Authorization: Digest username=\"alice\", realm=\"Protected\", nonce=\"abc123\", uri=\"/admin\", qop=auth, nc=00000001, cnonce=\"xyz789\", response=\"<hash>\", algorithm=MD5 Response hash (RFC 7616 ยง3.4.1 for qop=auth): HA1 = MD5(username : realm : password) HA2 = MD5(method : uri) response = MD5(HA1 : nonce : nc : cnonce : qop : HA2) We compute the `response` value + emit the full Authorization header value. Challenge-parsing is a separate job; this module assumes caller extracted realm/nonce/qop from the WWW- Authenticate header already. Composes md5.nx + hex.nx. Invariants: D1 HA1/HA2/response all emitted as 32 lowercase hex chars. D2 Currently supports qop=auth + algorithm=MD5 only. SHA-256 variant (RFC 7616) is a future extension composing sha256. D3 cnonce + nc counter are caller-supplied -- the module doesn't generate them (entropy + state are caller's concern).

dependencies 3 imports · 0 importers

syscalls.nx nx_md5_canonical.nx hex.nx digest_auth.nx

imports: syscalls.nxnx_md5_canonical.nxhex.nx

imported by: nobody (leaf or entry point)

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

main digest_auth_ha1 md5 sys_mmap md5_process_block sys_mmap ↻ md5_g md5_k md5_rotl md5_s hex_encode digest_auth_ha2 da_md5_two md5 ↻ hex_encode ↻ digest_auth_response md5 ↻ hex_encode ↻

structs

none

consts

42const DA_ERR_SHORT: i64 = -1

functions

45func da_md5_two(a: *u8, a_len: i64,
called by 1: digest_auth_ha2 calls 2: md5hex_encode
68func digest_auth_ha1(user: *u8, user_len: i64,
called by 1: main calls 2: md5hex_encode
90func digest_auth_ha2(method: *u8, method_len: i64,
called by 1: main calls 1: da_md5_two
98func digest_auth_response(ha1: *u8,
called by 1: main calls 2: md5hex_encode
143func main() -> i64 {