code wiki / (root) / nx_hotp_sha1.nx

nx_hotp_sha1.nx

buildroot/runtime/nx_hotp_sha1.nx

3071 B95 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hmac_sha1.nx nx_hotp_sha1.nx

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

main hotp_sha1_code sys_mmap hmac_sha1 sys_mmap ↻ sha1 sys_mmap ↻ sha1_process_block if_ge sys_mmap ↻ hotp_sha1_render

structs

none

consts

31const K_MAGIC_755224: i64 = 755224
32const K_MAGIC_287082: i64 = 287082
33const K_MAGIC_359152: i64 = 359152

functions

37func hotp_sha1_code(key: *u8, key_len: i64,
called by 1: main calls 2: sys_mmaphmac_sha1
65func hotp_sha1_render(value: i64, digits: i64, out: *u8) -> i64
called by 1: main
81func main() -> i64