HMAC-based one-time password


HMAC-based one-time password is a one-time password algorithm based upon an HMAC. When a client attempts to access a server, a challenge is sent by the destination server to the client. The client then computes a response which represents a one time password. This often forms part of multi-factor authentication protocols such as the Open Authentication initiative challenge-response algorithm.
HOTP was published as an informational IETF in December 2005, documenting the algorithm along with a Java implementation. Since then, the algorithm has been adopted by many companies worldwide. The HOTP algorithm is a freely available open standard.

Algorithm

The HOTP algorithm provides a method of authentication by symmetric generation of human-readable passwords, or values, each used for only one authentication attempt. The one-time property leads directly from the single use of each counter value.
Parties intending to use HOTP must establish some ; typically these are specified by the authenticator, and either accepted or not by the authenticated entity:
Both parties compute the HOTP value derived from the secret key K and the counter C. Then the authenticator checks its locally generated value against the value supplied by the authenticated.
The authenticator and the authenticated entity increment the counter C independently. Since the authenticated entity may increment the counter more than the authenticator, recommends a resynchronization protocol. It proposes that the authenticator repeatedly try verification ahead of their counter through a window of size s. The authenticator's counter continues forward of the value at which verification succeeds, and requires no actions by the authenticated entity.
To protect against brute-force attacks targeting the small size of HOTP values, the RFC also recommends implementing persistent throttling of HOTP verification. This can be achieved by either locking out verification after a small number of failed attempts, or by linearly increasing the delay after each failed attempt.
6-digit codes are commonly provided by proprietary hardware tokens from a number of vendors informing the default value of d. Truncation extracts 31 bits or decimal digits, meaning that d can be at most 10, with the 10th digit adding less variation, taking values of 0, 1, and 2.
After verification, the authenticator can authenticate itself simply by generating the next HOTP value, returning it, and then the authenticated can generate their own HOTP value to verify it. Note that counters are guaranteed to be synchronised at this point in the process.
The HOTP value is the human-readable design output, a d-digit decimal number :
That is, the value is the d least significant base-10 digits of HOTP.
HOTP is a truncation of the HMAC of the counter C :
where the counter C must be used big-endian.
Truncation first takes the 4 least significant bits of the MAC and uses them as a byte offset i:
where ":" is used to extract bits from a starting bit number up to and including an ending bit number, where these bit numbers are 0-origin. The use of "19" in the above formula relates to the size of the output from the hash function. With the default of SHA-1, the output is, and so the last byte is byte 19.
That index i is used to select 31 bits from MAC, starting at bit i × 8 + 1:
31 bits are a single bit short of a 4-byte word. Thus the value can be placed inside such a word without using the sign bit. This is done to definitely avoid doing modular arithmetic on negative numbers, as this has many differing definitions and implementations.

Tokens

Both hardware and software tokens are available from various vendors, for some of them see references below.
Software tokens are available for all major mobile/smartphone platforms.

Reception

Although the early reception from some of the computer press was negative during 2004 and 2005, after IETF adopted HOTP as in December 2005, various vendors started to produce HOTP-compatible tokens and/or whole authentication solutions.
According to the article "Road Map: Replacing Passwords with OTP Authentication" on strong authentication, published by Burton Group in 2010, "Gartner's expectation is that the hardware OTP form factor will continue to enjoy modest growth while smartphone OTPs will grow and become the default hardware platform over time."