HOTP is an HMAC-based one-time password (OTP) algorithm. It is a cornerstone of Initiative For Open Authentication (OATH).

HOTP was published as an informational IETF RFC 4226 in December 2005, documenting the algorithm along with a Java implementation. Since then, the algorithm has been adopted by many companies worldwide (see below). The HOTP algorithm is a freely available open standard.



  • K be a secret key
  • C be a counter
  • HMAC(K,C) = SHA1(K ⊕ 0x5c5c… ∥ SHA1(K ⊕ 0x3636… ∥ C)) with ⊕ as XOR, ∥ as concatenation, for more details see HMAC (C is the message)
  • Truncate be a function that selects 4 bytes from the result of the HMAC in a defined manner

Then HOTP(K,C) is mathematically defined by :HOTP(K,C) = Truncate(HMAC(K,C)) & 0x7FFFFFFF

The mask 0x7FFFFFFF sets the result's most significant bit to zero. This avoids problems if the result is interpreted as a signed number as some processors do.<ref></ref>

For HOTP to be useful for an individual to input to a system, the result must be converted into a HOTP value, a 6–8 digits number that is implementation dependent.

:HOTP-Value = HOTP(K,C) mod 10d, where d is the desired number of digits —


HOTP can be used to authenticate a user in a system via an authentication server. Also, if some more steps are carried out (the server calculates subsequent OTP value and sends/displays it to the user who checks it against subsequent OTP value calculated by his token), the user can also authenticate the validation server.


Both hardware and software tokens are available from various vendors, for some of them see references below. Hardware tokens implementing OATH HOTP tend to be significantly cheaper than their competitors based on proprietary algorithms.<ref name=“gartnerotprm”>

</ref> As of 2010, OATH HOTP hardware tokens can be purchased for a marginal price.<ref>

</ref> Some products can be used for strong passwords as well as OATH HOTP.<ref>


Software tokens are available for (nearly) all major mobile/smartphone platforms (J2ME,<ref>

</ref> Android,<ref>


</ref> iPhone,<ref>

</ref> BlackBerry,<ref name=“actividentityst”>

</ref> Maemo,<ref>

</ref> Mac OS X,<ref>

</ref> Windows Mobile<ref name=“actividentityst”/>).


Although the reception from some of the computer press has been negative during 2004 and 2005,<ref>



</ref> after IETF adopted HOTP as RFC 4226 in December 2005, various vendors started to produce HOTP compatible tokens and/or whole authentication solutions (see above/below).

According to a paper on strong authentication (entitled “Road Map: Replacing Passwords with OTP Authentication”) published by Burton Group (a division of Gartner, Inc.) 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.”<ref name=“gartnerotprm”/>

See also


hmac-based_one-time_password_algorithm.txt · Last modified: 2017/01/09 17:51 by Mike J. Kreuzer PhD MCSE MCT Microsoft Cloud Ecosystem