8#include <botan/internal/ffi_util.h>
20 if(!mac || !mac_name || flags != 0)
23 std::unique_ptr<Botan::MessageAuthenticationCode> m =
29 *mac =
new botan_mac_struct(std::move(m));
46 return BOTAN_FFI_VISIT(mac, [=](
auto& m) { m.start(nonce, nonce_len); });
51 return BOTAN_FFI_VISIT(mac, [=](
const auto& m) { *out = m.output_length(); });
76 size_t* out_minimum_keylength,
77 size_t* out_maximum_keylength,
78 size_t* out_keylength_modulo)
81 if(out_minimum_keylength)
82 *out_minimum_keylength = m.minimum_keylength();
83 if(out_maximum_keylength)
84 *out_maximum_keylength = m.maximum_keylength();
85 if(out_keylength_modulo)
86 *out_keylength_modulo = m.key_spec().keylength_multiple();
static std::unique_ptr< MessageAuthenticationCode > create(std::string_view algo_spec, std::string_view provider="")
struct botan_mac_struct * botan_mac_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_NULL_POINTER
int botan_mac_init(botan_mac_t *mac, const char *mac_name, uint32_t flags)
int botan_mac_destroy(botan_mac_t mac)
int botan_mac_set_nonce(botan_mac_t mac, const uint8_t *nonce, size_t nonce_len)
int botan_mac_final(botan_mac_t mac, uint8_t out[])
int botan_mac_update(botan_mac_t mac, const uint8_t *buf, size_t len)
int botan_mac_output_length(botan_mac_t mac, size_t *out)
int botan_mac_name(botan_mac_t mac, char *name, size_t *name_len)
int botan_mac_get_keyspec(botan_mac_t mac, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
int botan_mac_set_key(botan_mac_t mac, const uint8_t *key, size_t key_len)
int botan_mac_clear(botan_mac_t mac)
#define BOTAN_FFI_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_DECLARE_STRUCT(NAME, TYPE, MAGIC)
int write_str_output(uint8_t out[], size_t *out_len, std::string_view str)
int ffi_guard_thunk(const char *func_name, const std::function< int()> &thunk)