facil.io

#./fio-stl/159 otp.h

7 public symbols.

#Types

#fio_otp_settings_s

c
typedef struct {
/** The time interval for TOTP rotation. */
size_t interval; /* 30 == Google OTP */
/** The number of digits in the OTP. */
size_t digits; /* 6 == Google OTP */
/** The time offset (in `interval` units) from the current time. */
int64_t offset; /* 0 == Google OTP */
/** Set to true if the secret / key is in Hex instead of Byte32 encoding. */
uint8_t is_hex;
/** Set to true if the secret / key is raw bit data (no encoding). */
uint8_t is_raw;
} fio_otp_settings_s

Symbol type: type

#Functions

#fio_otp_generate_key

c
inline fio_u128 fio_otp_generate_key(void)

Generates a random 128 bit key for TOTP processing.

Symbol type: function

#fio_otp_print_key

c
inline size_t fio_otp_print_key(char *dest, uint8_t *key, size_t len)

Prints out an OTP secret (big endian number) as a Byte32 encoded String.

Symbol type: function

#fio_otp

c
uint32_t fio_otp(fio_buf_info_s secret, fio_otp_settings_s settings)

Returns a TOTP based on secret and the otp settings.

Symbol type: function

#fio_otp

c
#define fio_otp(secret, ...) fio_otp(secret, (fio_otp_settings_s){__VA_ARGS__})

Note: this may be a macro only / macro wrapper for a function.

Symbol type: macro

#fio_otp_at

c
uint32_t fio_otp_at(fio_buf_info_s secret, uint64_t unix_time, fio_otp_settings_s settings)

Returns a TOTP for a specific unix timestamp (for testing/verification). This is useful for verifying OTPs at specific times or for RFC test vectors.

Symbol type: function

#fio_otp_at

c
#define fio_otp_at(secret, unix_time, ...)   \
  fio_otp_at(secret, unix_time, (fio_otp_settings_s){__VA_ARGS__})

Note: this may be a macro only / macro wrapper for a function.

Symbol type: macro