oath_totp_validate3(3)

πŸ’– oath_totp_validate3 β€” NAME πŸ’–

okay so bestie, this is oath_totp_validate3, an API function straight out of liboath (that's the manual we're in, liboath(3) vibes, hi), and it's literally the girl whose whole job is checking whether your TOTP code is valid. no cap. πŸŽ€


✨ SYNOPSIS ✨

#include <oath.h>

int oath_totp_validate3(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, const char * otp);

she takes nine arguments. nine. main character energy fr fr. πŸ’…


🫢 ARGUMENTS 🫢

  • const char * secret β€” the shared secret string. the little secret. the tea. 🀫
  • size_t secret_length β€” how long secret is, in bytes.
  • time_t now β€” the Unix time value you want to validate the TOTP for. like, right now? or whenever. your call. ⏰
  • unsigned time_step_size β€” the time step system parameter. typically 30. that's the default-ish vibe everyone uses.
  • time_t start_offset β€” the Unix time of when to start counting time steps. typically 0.
  • size_t window β€” how many OTPs after/before the start OTP to test. so like, the search radius. πŸ”
  • int * otp_pos β€” output search position in the search window (zero is first position, jsyk). may be NULL.
  • uint64_t * otp_counter β€” the counter value used to calculate the OTP value. may be NULL. πŸ™ˆ
  • const char * otp β€” the OTP to validate. the code itself. the moment of truth. 😭

🌸 DESCRIPTION 🌸

Validate an OTP according to the OATH TOTP algorithm per RFC 6238. that's it. that's the whole gig. validation queen. πŸ‘‘

currently only OTP lengths of 6, 7 or 8 digits are supported. yes, only those three. this restriction may be lifted in future versions, although some limitations are inherent in the protocol β€” so like, don't come for her, the protocol is the messy one here. πŸ’€


πŸ”₯ RETURNS πŸ”₯

returns the absolute value of the position in the 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 number, or a sad little sentinel, or a bad-vibes error. that's the range. 🌈


⭐ SINCE ⭐

2.4.0 β€” she's been iconic since 2.4.0, respect her longevity. 🫢


πŸ¦‹ REPORTING BUGS πŸ¦‹

found a bug? report it to <oath-toolkit-help@nongnu.org>. πŸ“§


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. (yes that includes your group chat. slay.) πŸ’œ


ngl bestie, that's the whole page β€” every flag, every param, every caveat, nothing skipped, periodt. πŸ’…

and that's the sign-off from liboath, version 2.6.15, dated oath_totp_validate3(3) β€” mwah, go validate something. πŸ§šπŸ’–

πŸ“¦ where this page comes from