8#include <botan/internal/ffi_util.h>
10#if defined(BOTAN_HAS_TOTP)
11 #include <botan/otp.h>
18#if defined(BOTAN_HAS_TOTP)
25 const uint8_t key[],
size_t key_len,
30 if(totp ==
nullptr || key ==
nullptr ||
hash_algo ==
nullptr)
35#if defined(BOTAN_HAS_TOTP)
38 *totp =
new botan_totp_struct(
51#if defined(BOTAN_HAS_TOTP)
63#if defined(BOTAN_HAS_TOTP)
64 if(totp ==
nullptr || totp_code ==
nullptr)
80 size_t acceptable_clock_drift)
82#if defined(BOTAN_HAS_TOTP)
84 const bool ok = t.
verify_totp(totp_code, timestamp, acceptable_clock_drift);
89 BOTAN_UNUSED(totp, totp_code, timestamp, acceptable_clock_drift);
#define BOTAN_UNUSED(...)
uint32_t generate_totp(std::chrono::system_clock::time_point time_point)
bool verify_totp(uint32_t otp, std::chrono::system_clock::time_point time, size_t clock_drift_accepted=0)
struct botan_totp_struct * botan_totp_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_INVALID_VERIFIER
@ BOTAN_FFI_ERROR_NULL_POINTER
int botan_totp_generate(botan_totp_t totp, uint32_t *totp_code, uint64_t timestamp)
int botan_totp_init(botan_totp_t *totp, const uint8_t key[], size_t key_len, const char *hash_algo, size_t digits, size_t time_step)
int botan_totp_destroy(botan_totp_t totp)
int botan_totp_check(botan_totp_t totp, uint32_t totp_code, uint64_t timestamp, size_t acceptable_clock_drift)
#define BOTAN_FFI_DO(T, obj, param, block)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_RETURNING(T, obj, param, block)
#define BOTAN_FFI_DECLARE_STRUCT(NAME, TYPE, MAGIC)
int ffi_guard_thunk(const char *func_name, std::function< int()> thunk)
AlgorithmIdentifier hash_algo