nx_hotp_sha1.nx
buildroot/runtime/nx_hotp_sha1.nx
about
hotp_sha1.nx -- RFC 4226 HOTP with SHA-1.
Counter-based OTP. Used by:
- Yubico OTP hardware tokens (YubiKey in HOTP mode)
- Microsoft ActiveSync + Exchange legacy provisioning
- Some corporate 2FA where server tracks a per-user counter
TOTP (totp_sha1.nx) is the time-based variant that builds on
HOTP by setting counter = floor(unix_time / step). HOTP is
the lower-level primitive.
Algorithm:
HOTP(K, C) = DT(HMAC-SHA-1(K, C_be64)) mod 10^digits
DT(mac) = big-endian u32 at offset (mac[19] & 0x0F)
with high bit of first byte masked off
Invariants:
H1 Counter is serialised as 8-byte big-endian u64.
H2 Dynamic truncation: offset = low 4 bits of mac[19]
(valid 0..15; always 4 bytes left in 20-byte MAC).
H3 Output value in range [0, 10^digits).
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_hmac_sha1.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
| 31 | const K_MAGIC_755224: i64 = 755224 |
| 32 | const K_MAGIC_287082: i64 = 287082 |
| 33 | const K_MAGIC_359152: i64 = 359152 |
functions
| 37 | func hotp_sha1_code(key: *u8, key_len: i64, |
| 65 | func hotp_sha1_render(value: i64, digits: i64, out: *u8) -> i64 called by 1: main |
| 81 | func main() -> i64 |