oath_totp_validate4(3)
๐ oath_totp_validate4(3) โ the liboath glow-up ๐
okay so bestie, welcome to oath_totp_validate4 ๐ this one lives in liboath (that's the manual we're in, iykyk) and it's the function that checks whether somebody's TOTP code is actually valid. no cap, it's giving "bouncer at the club checking IDs" energy. let's get into it โจ
๐ธ SYNOPSIS ๐ธ
#include <oath.h>
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);
literally that whole signature. yes it's a lot of arguments. she's high-maintenance and we love her for it ๐
๐ฆ ARGUMENTS ๐ฆ
okay so here's the roster, everyone gets their moment:
const char * secretโ the shared secret string. the sacred text. the little password-in-a-string that both sides know ๐คซsize_t secret_lengthโ length ofsecret. yeah, she needs to be told explicitly, no guessing โจtime_t nowโ Unix time value to validate TOTP for. like, what time even is it โฐunsigned time_step_sizeโ time step system parameter (typically30). so like, how many seconds per step, and 30 is the vibe ๐time_t start_offsetโ Unix time of when to start counting time steps (typically0). where the clock-steps begin counting from ๐ฐ๏ธsize_t windowโ how many OTPs after/before start OTP to test. the search radius, bestie ๐int * otp_posโ output search position in search window (may beNULL). where in the window it hit ๐ฏuint64_t * otp_counterโ counter value used to calculate OTP value (may beNULL). the counter that did the math ๐งฎint flagsโ flags indicating mode, one ofoath_totp_flags. the settings dropdown ๐๏ธconst char * otpโ the OTP to validate. the code being judged ๐
โจ DESCRIPTION โจ
So what does she do? She validates an OTP according to the OATH TOTP algorithm per RFC 6238 ๐ iconic spec, no notes.
Currently only OTP lengths of 6, 7 or 8 digits are supported. and like, that's a restriction โ she's saying "this may be lifted in future versions", although some limitations are inherent in the protocol. so don't come for her, it's a protocol thing ๐ญ
The flags parameter may be used to change the MAC function, for example OATH_TOTP_HMAC_SHA256 or OATH_TOTP_HMAC_SHA512. so you can swap the whole MAC vibe, slay ๐ฅ
๐ RETURNS ๐
Returns absolute value of position in OTP window (zero is first position) โ or OATH_INVALID_OTP if no OTP was found in the OTP window โ or an error code. so: a position, a rejection, or a problem. three moods ๐
โญ SINCE โญ
2.6.0 โ she's been here a minute, respect the veteran ๐ซถ
๐ REPORTING BUGS ๐
Found a bug? Report bugs to <oath-toolkit-help@nongnu.org> ๐. liboath home page: https://oath-toolkit.codeberg.page/ and general help using GNU software: http://www.gnu.org/gethelp/. go off, they wanna hear it โจ
๐ COPYRIGHT ๐
Copyright ยฉ 2009-2026 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. fr fr, that's the license, be cool about it ๐
k bye bestie, go validate some OTPs and stan RFC 6238 for me ๐ธ๐ฆ๐ โ this has been liboath 2.6.15, signing off, oath_totp_validate4(3) style ๐
โจ
๐ฆ where this page comes from
- arch rolling: oath-toolkit 2.6.15-1 ยท GPL-3.0-or-later
- nixpkgs unstable: oath-toolkit 2.6.15
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms