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,
26 const char* hash_algo,
30 if(totp ==
nullptr || key ==
nullptr || hash_algo ==
nullptr)
35#if defined(BOTAN_HAS_TOTP)
37 auto otp = std::make_unique<Botan::TOTP>(key, key_len, hash_algo, digits, time_step);
38 *totp =
new botan_totp_struct(std::move(otp));
43 BOTAN_UNUSED(totp, key, key_len, hash_algo, digits, time_step);
50#if defined(BOTAN_HAS_TOTP)
62#if defined(BOTAN_HAS_TOTP)
63 if(totp ==
nullptr || totp_code ==
nullptr)
67 *totp_code = t.generate_totp(timestamp);
79 size_t acceptable_clock_drift)
81#if defined(BOTAN_HAS_TOTP)
83 const bool ok = t.verify_totp(totp_code, timestamp, acceptable_clock_drift);
88 BOTAN_UNUSED(totp, totp_code, timestamp, acceptable_clock_drift);
#define BOTAN_UNUSED(...)
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_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_DECLARE_STRUCT(NAME, TYPE, MAGIC)
int ffi_guard_thunk(const char *func_name, const std::function< int()> &thunk)