NaviServer Built-in Commands – 5.0.1
ns_hotp - Returns a decimal-coded one-time password (HOTP)
The function returns a one-time password based on the HMAC algorithm (HOTP) as described in RFC-4226, allowing the choice of message digest algorithm and the number of digits for the truncated output.
RFC-4226 defines HOTP as:
HOTP(K,C) = Truncate(HMAC-SHA-1(K,C)) K: key C: counter (moving factor for one time passwd)
The implemented function ns_hotp is an extension of the standard RFC by allowing you to specify the message digest algorithm and the number of characters in the truncated output.
The command is available when NaviServer is compiled with OpenSSL support and the nsf package is installed.
counter specifies the moving factor for the one-time password (referred to as "C" in the formula above). The counter is a 64-bit moving factor, encoded in big-endian order and passed as the message to the HMAC calculation.
# provide coutner in 64-bit big-endian order % ns_hotp -key "tweedie123" [binary format W 1] 601045