oath_hotp_generate(3)
β¨ oath_hotp_generate β like, the HOTP generator β¨
okay bestie, so this one lives in the liboath manual, section 3 (the library functions girlies), and it's genuinely iconic β it's the function that makes one-time passwords out of thin air. let's get into it π
πΈ SYNOPSIS πΈ
#include <oath.h>
int oath_hotp_generate(const char * secret, size_t secret_length,
uint64_t moving_factor, unsigned digits, bool add_checksum, size_t
truncation_offset, char * output_otp);
like yes she's got a lot of arguments but she's worth it, trust π«Ά
π ARGUMENTS π
const char * secretβ the shared secret string, the lil bestie everything's built on πsize_t secret_lengthβ how long that secret is, obviouslyuint64_t moving_factorβ a counter showing which OTP you're on rn (this is the whole "moving" part of moving factor, iykyk)unsigned digitsβ how many digits you want in your OTP, and this does not count the checksumbool add_checksumβ do you want a checksum digit tacked on or notsize_t truncation_offsetβ use a specific truncation offset, fancychar * output_otpβ the output buffer π and it must have room for the output OTP plus zero
π DESCRIPTION π
so the whole vibe: she generates a one-time-password using the HOTP algorithm, exactly like RFC 4226 describes. no cap, that's the entire job and she does it flawlessly β¨
now, listen β use the value OATH_HOTP_DYNAMIC_TRUNCATION for truncation_offset unless you really need a specific truncation offset. like, genuinely really. main character energy is trusting the dynamic truncation π
to find out how big your OTP is gonna be, hit up the OATH_HOTP_LENGTH() macro. and remember: your output_otp buffer has to have room for that length plus one for the terminating NUL. that NUL is not optional, she's the plus-one of this whole operation π
π heads up fr fr: right now only the values6,7and8are supported fordigits, and theadd_checksumvalue just gets ignored. yes, ignored. she's not even looking at it. these restrictions may get lifted in future versions, although ngl some limitations are baked into the protocol itself and are here to stay.
β RETURNS β
on success you get OATH_OK (which is zero, cute right?) and otherwise you get an error code. no in-between, periodt π«Ά
π¦ REPORTING BUGS π¦
found a bug? spill it to <oath-toolkit-help@nongnu.org> π
liboathhome page: https://oath-toolkit.codeberg.page/- general help with 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. slay, genuinely πΈ
okay that's the whole page bestie, you're officially an HOTP expert now π§
signing off with love from the liboath manual, version 2.6.15 β oath_hotp_generate(3), written and dated with the manual π
π¦ 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