code wiki / (root) / nx_digest_auth.nx

nx_digest_auth.nx

buildroot/runtime/nx_digest_auth.nx

6674 B179 linesdepth 3pulls 4 transitivereach 2 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 · 2 importers

nx_syscalls.nx nx_md5_canonical.nx nx_hex_codec.nx nx_digest_auth.nx nx_roku_install.nx nx_roku_install_gate.nx

imports: nx_syscalls.nxnx_md5_canonical.nxnx_hex_codec.nx

imported by: nx_roku_install.nxnx_roku_install_gate.nx

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

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

structs

none

consts

48const DA_ERR_SHORT: i64 = -1

functions

51func da_md5_two(a: *u8, a_len: i64,
74func digest_auth_ha1(user: *u8, user_len: i64,
96func digest_auth_ha2(method: *u8, method_len: i64,
called by 3: mainmaingvalidate calls 1: da_md5_two
104func digest_auth_response(ha1: *u8,
149func main() -> i64