otplib-hotp/HOTP

HMAC-based One-time Password Algorithm

References

  • http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm
  • http://tools.ietf.org/html/rfc4226

Algorithm

K be a secret secret
C be a counter
HMAC(K,C) = SHA1(K & 0x5c5c... | SHA1(K & 0x3636... | C))
be an HMAC calculated with the SHA-1 cryptographic hash algorithm
Truncate be a function that selects 4 bytes from the result of the
HMAC in a defined manner
HOTP(K,C) = Truncate(HMAC(K,C)) & 0x7FFFFFFF
HOTP-Value = HOTP(K,C) mod 10d, where d is the desired number of digits
Since:
  • 3.0.0
Source: