code wiki / (root) / hmac_sha1.nx

hmac_sha1.nx

buildroot/runtime/hmac_sha1.nx

3132 B100 linesdepth 3pulls 4 transitivereach 5 importersview sourcekind tooltopic hmac
docsdependenciesstructsconstsfunctions

about

hmac_sha1.nx -- HMAC with SHA-1 (RFC 2104 + FIPS 198-1). Interop-only primitive, like sha1.nx itself. HMAC does not rely on its inner hash's collision resistance (only pseudo- randomness of the keyed mix), so HMAC-SHA1 remains safe for authentication even though plain SHA-1 is broken for signatures. Still widely used: - TOTP / HOTP (RFC 4226 / 6238 default) - OAuth 1.0 HMAC-SHA1 signatures - AWS SigV2 / legacy API auth - PBKDF2-HMAC-SHA1 (WPA2, older WebCrypto key derivation) - Older JWT HS1 tokens Algorithm (RFC 2104): block_size = 64 bytes for SHA-1 if len(key) > block_size: key = SHA1(key) key = key || zeros to block_size ipad = key XOR 0x36 repeated opad = key XOR 0x5C repeated tag = SHA1(opad || SHA1(ipad || msg)) Composes sha1.nx. Output is 20 bytes. Invariants: HS1 Output = 20 bytes always (HMAC-SHA1 tag length). HS2 Matches RFC 2202 test vectors (not checked in smoke, but the algorithm is textbook).

dependencies 2 imports · 4 importers

syscalls.nx nx_sha1.nx hmac_sha1.nx hkdf_sha1.nx hotp_sha1.nx pbkdf2_sha1.nx totp_sha1.nx

imports: syscalls.nxnx_sha1.nx

imported by: hkdf_sha1.nxhotp_sha1.nxpbkdf2_sha1.nxtotp_sha1.nx

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

main hmac_sha1 sha1 sys_mmap sha1_process_block if_ge

structs

none

consts

33const HMAC_SHA1_BLOCK: i64 = 64
34const HMAC_SHA1_OUT: i64 = 20

functions

36func hmac_sha1(key: *u8, key_len: i64,
88func main() -> i64 {
calls 1: hmac_sha1