HMAC-Based One-Time Password (HOTP)

A one-time password algorithm, defined in RFC 4226, that computes each code from a shared secret key and a counter that advances every time a code is generated.

HOTP, published as RFC 4226 in 2005, generates one-time passwords from two inputs: a secret key shared by the token and the server, and a counter. The token applies a keyed hash (HMAC) to the counter and truncates the result to a short numeric code, commonly six digits. Each generation moves the counter on. The server holds the same key and counter and checks the code. Because a user may generate a code without logging in, the server commonly accepts codes a few steps ahead and then resynchronises.

The counter is the contrast with TOTP, which replaces it with the current time step. An unused HOTP code can stay valid until a later code is accepted, while a TOTP code expires within a short window. NIST SP 800-63B-4 requires a verifier to accept a given OTP only once, which limits replay, and to protect the symmetric keys it holds. Under the same document, OTP authentication is not phishing-resistant: a code typed into a fake site can be relayed at once.

Exam relevance: questions in this area tend to contrast HOTP and TOTP. Candidates are expected to link HOTP to a counter and TOTP to time, to recognise the longer life of an unused HOTP code, and to remember that neither resists a real-time phishing relay.