oath\_totp\_validate(3) liboath oath\_totp\_validate(3)

# [NAME](#NAME)

oath\_totp\_validate - API function

# [SYNOPSIS](#SYNOPSIS)

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

**int oath\_totp\_validate(const char * secret, size\_t secret\_length, time\_t now, unsigned time\_step\_size, time\_t start\_offset, size\_t window, const char * otp);**

# [ARGUMENTS](#ARGUMENTS)

[const char * secret](#const)

the shared secret string

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

length of *secret*

[time\_t now](#time_t)

Unix time value to validate TOTP for

[unsigned time\_step\_size](#unsigned)

time step system parameter (typically 30)

[time\_t start\_offset](#time_t~2)

Unix time of when to start counting time steps (typically 0)

[size\_t window](#size_t~2)

how many OTPs after/before start OTP to test

[const char * otp](#const~2)

the OTP to validate.

# [DESCRIPTION](#DESCRIPTION)

Validate an OTP according to OATH TOTP algorithm per RFC 6238.

Currently only OTP lengths of 6, 7 or 8 digits are supported. This restrictions may be lifted in future versions, although some limitations are inherent in the protocol.

# [RETURNS](#RETURNS)

Returns absolute value of position in OTP window (zero is first position), or **OATH\_INVALID\_OTP** if no OTP was found in OTP window, or an error code.

# [SINCE](#SINCE)

1.6.0

# [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_totp_validate(3) from oath-toolkit 2.6.12-r12 (Chainguard OS)
Source: https://gitlab.com/oath-toolkit/oath-toolkit.git
