code wiki / (root) / hotp_sha1.nx

hotp_sha1.nx

buildroot/runtime/hotp_sha1.nx

2771 B86 linesdepth 4pulls 5 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

syscalls.nx hmac_sha1.nx hotp_sha1.nx

imports: syscalls.nxhmac_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 hmac_sha1 sha1 sys_mmap sha1_process_block if_ge hotp_sha1_render

structs

none

consts

none

functions

28func hotp_sha1_code(key: *u8, key_len: i64,
called by 1: main calls 1: hmac_sha1
56func hotp_sha1_render(value: i64, digits: i64, out: *u8) -> i64 {
called by 1: main
72func main() -> i64 {