oath\_totp\_validate4(3) liboath oath\_totp\_validate4(3)

# [NAME](#NAME)

oath\_totp\_validate4 - API function

# [SYNOPSIS](#SYNOPSIS)

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

**int oath\_totp\_validate4(const char * secret, size\_t secret\_length, time\_t now, unsigned time\_step\_size, time\_t start\_offset, size\_t window, int * otp\_pos, uint64\_t * otp\_counter, int flags, 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

[int * otp\_pos](#int)

output search position in search window (may be NULL).

[uint64\_t * otp\_counter](#uint64_t)

counter value used to calculate OTP value (may be NULL).

[int flags](#int~2)

flags indicating mode, one of **oath\_totp\_flags**

[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.

The *flags* parameter may be used to change the MAC function, for example **OATH\_TOTP\_HMAC\_SHA256** or **OATH\_TOTP\_HMAC\_SHA512**.

# [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)

2.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_validate4(3) from oath-toolkit 2.6.12-r13 (Chainguard OS)
Source: https://gitlab.com/oath-toolkit/oath-toolkit.git
