9#include <botan/internal/ffi_util.h>
11#if defined(BOTAN_HAS_HOTP)
12 #include <botan/otp.h>
19#if defined(BOTAN_HAS_HOTP)
26 if(hotp ==
nullptr || key ==
nullptr || hash_algo ==
nullptr) {
32#if defined(BOTAN_HAS_HOTP)
34 auto otp = std::make_unique<Botan::HOTP>(key, key_len, hash_algo, digits);
35 *hotp =
new botan_hotp_struct(std::move(otp));
46#if defined(BOTAN_HAS_HOTP)
55#if defined(BOTAN_HAS_HOTP)
56 if(hotp ==
nullptr || hotp_code ==
nullptr) {
60 return BOTAN_FFI_VISIT(hotp, [=](
auto& h) { *hotp_code = h.generate_hotp(hotp_counter); });
69 botan_hotp_t hotp, uint64_t* next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter,
size_t resync_range) {
70#if defined(BOTAN_HAS_HOTP)
72 auto resp = h.verify_hotp(hotp_code, hotp_counter, resync_range);
75 *next_hotp_counter = resp.second;
81 BOTAN_UNUSED(hotp, next_hotp_counter, hotp_code, hotp_counter, resync_range);
struct botan_hotp_struct * botan_hotp_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_INVALID_VERIFIER
@ BOTAN_FFI_ERROR_NULL_POINTER
int botan_hotp_generate(botan_hotp_t hotp, uint32_t *hotp_code, uint64_t hotp_counter)
int botan_hotp_destroy(botan_hotp_t hotp)
int botan_hotp_check(botan_hotp_t hotp, uint64_t *next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter, size_t resync_range)
int botan_hotp_init(botan_hotp_t *hotp, const uint8_t key[], size_t key_len, const char *hash_algo, size_t digits)
#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)