code wiki / (root) / nx_hmac_sha1.nx

nx_hmac_sha1.nx

buildroot/runtime/nx_hmac_sha1.nx

8824 B203 linesdepth 3pulls 3 transitivereach 28 importersview sourcekind tooltopic hmac
docsdependenciesstructsconstsfunctions

about

hmac_sha1.nx -- HMAC with SHA-1 (RFC 2104 + FIPS 198-1). license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/nist/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 · 8 importers

nx_syscalls.nx nx_sha1.nx nx_hmac_sha1.nx nx_hkdf_sha1.nx nx_hmac_alloc_ab.nx nx_hmaccounter_extvec_gate.nx nx_hotp_sha1.nx nx_pbkdf2_sha1.nx nx_stun.nx nx_totp_sha1.nx nx_turn_msgintegrity.nx

imports: nx_syscalls.nxnx_sha1.nx

imported by: nx_hkdf_sha1.nxnx_hmac_alloc_ab.nxnx_hmaccounter_extvec_gate.nxnx_hotp_sha1.nxnx_pbkdf2_sha1.nxnx_stun.nxnx_totp_sha1.nxnx_turn_msgintegrity.nx

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

main sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ hmac_sha1 sys_mmap ↻ sha1 sys_mmap ↻ sha1_process_block if_ge

structs

none

consts

42const HMAC_SHA1_BLOCK: i64 = 64
43const HMAC_SHA1_OUT: i64 = 20
88const HS1_OFF_K: i64 = 0
89const HS1_OFF_IH: i64 = 80
90const HS1_OFF_OUT: i64 = 112
91const HS1_OFF_S1: i64 = 212
92const HS1_OFF_IN: i64 = 1236

functions

94func hmac_sha1_scratch_bytes(msg_cap: i64) -> i64
called by 2: mainhmac_sha1_into
101func hmac_sha1_into(scratch: *u8, scratch_cap: i64,
139func hmac_sha1(key: *u8, key_len: i64,
191func main() -> i64