oath\_hotp\_generate(3) liboath oath\_hotp\_generate(3)

# [NAME](#NAME)

oath\_hotp\_generate - API function

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;oath.h&gt;**

**int oath\_hotp\_generate(const char * secret, size\_t secret\_length, uint64\_t moving\_factor, unsigned digits, bool add\_checksum, size\_t truncation\_offset, char * output\_otp);**

# [ARGUMENTS](#ARGUMENTS)

[const char * secret](#const)

the shared secret string

[size\_t secret\_length](#size_t)

length of *secret*

[uint64\_t moving\_factor](#uint64_t)

a counter indicating the current OTP to generate

[unsigned digits](#unsigned)

number of requested digits in the OTP, excluding checksum

[bool add\_checksum](#bool)

whether to add a checksum digit or not

[size\_t truncation\_offset](#size_t~2)

use a specific truncation offset

[char * output\_otp](#char)

output buffer, must have room for the output OTP plus zero

# [DESCRIPTION](#DESCRIPTION)

Generate a one-time-password using the HOTP algorithm as described in RFC 4226.

Use a value of **OATH\_HOTP\_DYNAMIC\_TRUNCATION** for *truncation\_offset* unless you really need a specific truncation offset.

To find out the size of the OTP you may use the **OATH\_HOTP\_LENGTH()** macro. The *output\_otp* buffer must be have room for that length plus one for the terminating NUL.

Currently only values 6, 7 and 8 for *digits* are supported, and the *add\_checksum* value is ignored. These restrictions may be lifted in future versions, although some limitations are inherent in the protocol.

# [RETURNS](#RETURNS)

On success, **OATH\_OK** (zero) is returned, otherwise an error code is returned.

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;oath-toolkit-help@nongnu.org&gt;. liboath home page: https://www.nongnu.org/oath-toolkit/ General help using GNU software: http://www.gnu.org/gethelp/

# [COPYRIGHT](#COPYRIGHT)

Copyright © 2009-2020 Simon Josefsson.  
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

2.6.12-dirty liboath

---

Document: oath_hotp_generate(3) from oath-toolkit 2.6.12-r13 (Chainguard OS)
Source: https://gitlab.com/oath-toolkit/oath-toolkit.git
