digest_auth.nx
buildroot/runtime/digest_auth.nx
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
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
structs
| none |
consts
| 42 | const DA_ERR_SHORT: i64 = -1 |
functions
| 45 | func da_md5_two(a: *u8, a_len: i64, |
| 68 | func digest_auth_ha1(user: *u8, user_len: i64, |
| 90 | func digest_auth_ha2(method: *u8, method_len: i64, |
| 98 | func digest_auth_response(ha1: *u8, |
| 143 | func main() -> i64 { |