hmac_sha1.nx
buildroot/runtime/hmac_sha1.nx
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
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
structs
| none |
consts
| 33 | const HMAC_SHA1_BLOCK: i64 = 64 |
| 34 | const HMAC_SHA1_OUT: i64 = 20 |
functions
| 36 | func hmac_sha1(key: *u8, key_len: i64,
called by 6: hkdf_sha1_extracthkdf_sha1_expandmainhotp_sha1_codepb_f_sha1hotp_sha1_value calls 1: sha1 |
| 88 | func main() -> i64 {
calls 1: hmac_sha1 |