nx_hmac_sha1.nx
buildroot/runtime/nx_hmac_sha1.nx
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
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
structs
| none |
consts
| 42 | const HMAC_SHA1_BLOCK: i64 = 64 |
| 43 | const HMAC_SHA1_OUT: i64 = 20 |
| 88 | const HS1_OFF_K: i64 = 0 |
| 89 | const HS1_OFF_IH: i64 = 80 |
| 90 | const HS1_OFF_OUT: i64 = 112 |
| 91 | const HS1_OFF_S1: i64 = 212 |
| 92 | const HS1_OFF_IN: i64 = 1236 |
functions
| 94 | func hmac_sha1_scratch_bytes(msg_cap: i64) -> i64 |
| 101 | func hmac_sha1_into(scratch: *u8, scratch_cap: i64, |
| 139 | func hmac_sha1(key: *u8, key_len: i64, |
| 191 | func main() -> i64 |