# `./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`

-----------------------------------------------------
