oath_totp_generate(3)
π oath_totp_generate(3) β the liboath era π
okay bestie, gather round, because this is the function that makes your authenticator app actually work π it lives in liboath, and the manual page header says oath_totp_generate(3) β yes, section 3, we love a library call β¨
πΈ NAME πΈ
oath_totp_generate β the API function that mints you a fresh time-based one-time password, no cap π₯
π¦ SYNOPSIS π¦
#include <oath.h>
int oath_totp_generate(const char * secret, size_t secret_length, time_t
now, unsigned time_step_size, time_t start_offset, unsigned digits, char
* output_otp);
π ARGUMENTS π
const char * secretβ the shared secret string, the whole vibe behind your OTP πsize_t secret_lengthβ how long that secret is, obviouslytime_t nowβ the Unix time value you're computing the TOTP for β°unsigned time_step_sizeβ the time step system parameter (typically30)time_t start_offsetβ the Unix time of when to start counting time steps (typically0)unsigned digitsβ how many digits you want in the OTP, excluding the checksumchar * output_otpβ your output buffer, and it must have room for the output OTP plus the zero terminator π«Ά
β¨ DESCRIPTION β¨
So what this does is generate a one-time-password using the time-variant TOTP algorithm described in RFC 6238 β iconic spec behaviour honestly π The input parameters are taken as time values.
The system parameter time_step_size describes how long the time window for each OTP is. The recommended value is 30 seconds, and you can use the value 0 or the symbol OATH_TOTP_DEFAULT_TIME_STEP_SIZE to indicate this π
The system parameter start_offset denotes the Unix time when time steps are started to be counted. The recommended value is 0, to fall back on the Unix epoch, and you can use the symbol OATH_TOTP_DEFAULT_START_TIME to indicate this. (Yes, the original manpage literally has a stray ) there β we stan a typo that survived into the docs ππ)
The output_otp buffer must have room for at least digits characters, plus one for the terminating NUL.
β οΈ Currently only values6,7and8fordigitsare supported. This restriction may be lifted in future versions β so don't come for me if you asked for9π
π RETURNS π
On success, OATH_OK (zero) is returned β slay π
otherwise an error code is returned. Periodt.
β SINCE β
1.4.0 β she's been serving since day one, fr fr π§
π REPORTING BUGS π
Report bugs to <oath-toolkit-help@nongnu.org>. liboath home page: https://oath-toolkit.codeberg.page/ General help using GNU software: http://www.gnu.org/gethelp/ π«Ά
π 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. π
and that's the whole page bestie, iykyk πΈ β this little beauty comes to you from liboath, version 2.6.15, dated oath_totp_generate(3) (that's the header/footer energy, we kept it cute) π go forth and generate those OTPs, main character energy only β¨π¦
π¦ 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