basic_auth.nx
buildroot/runtime/basic_auth.nx
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
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
structs
| none |
consts
| 28 | const BA_ERR_FORMAT: i64 = -1 |
| 29 | const BA_ERR_SHORT: i64 = -2 |
functions
| 34 | func basic_auth_encode(username: *u8, u_len: i64, |
| 73 | func basic_auth_decode(hdr: *u8, n: i64, |
| 137 | func basic_auth_verify(user_got: *u8, u_got_len: i64, |
| 161 | func main() -> i64 { |