10#include <botan/exceptn.h>
11#include <botan/mem_ops.h>
12#include <botan/internal/ct_utils.h>
13#include <botan/internal/scan_name.h>
15#if defined(BOTAN_HAS_CMAC)
16 #include <botan/internal/cmac.h>
19#if defined(BOTAN_HAS_GMAC)
20 #include <botan/block_cipher.h>
21 #include <botan/internal/gmac.h>
24#if defined(BOTAN_HAS_HMAC)
25 #include <botan/hash.h>
26 #include <botan/internal/hmac.h>
29#if defined(BOTAN_HAS_POLY1305)
30 #include <botan/internal/poly1305.h>
33#if defined(BOTAN_HAS_SIPHASH)
34 #include <botan/internal/siphash.h>
37#if defined(BOTAN_HAS_ANSI_X919_MAC)
38 #include <botan/internal/x919_mac.h>
41#if defined(BOTAN_HAS_BLAKE2BMAC)
42 #include <botan/internal/blake2bmac.h>
45#if defined(BOTAN_HAS_KMAC)
46 #include <botan/internal/kmac.h>
52 std::string_view provider) {
55#if defined(BOTAN_HAS_BLAKE2BMAC)
61#if defined(BOTAN_HAS_GMAC)
65 return std::make_unique<GMAC>(std::move(bc));
71#if defined(BOTAN_HAS_HMAC)
75 return std::make_unique<HMAC>(std::move(hash));
81#if defined(BOTAN_HAS_POLY1305)
84 return std::make_unique<Poly1305>();
89#if defined(BOTAN_HAS_SIPHASH)
97#if defined(BOTAN_HAS_CMAC)
101 return std::make_unique<CMAC>(std::move(bc));
107#if defined(BOTAN_HAS_ANSI_X919_MAC)
110 return std::make_unique<ANSI_X919_MAC>();
115#if defined(BOTAN_HAS_KMAC)
120 "invalid algorithm specification for KMAC-128: need exactly one argument for output bit length");
130 "invalid algorithm specification for KMAC-256: need exactly one argument for output bit length");
149 std::string_view provider) {
169 if(our_mac.size() != mac.size()) {
173 return CT::is_equal(our_mac.data(), mac.data(), mac.size()).as_bool();
static std::unique_ptr< BlockCipher > create(std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
virtual bool verify_mac_result(std::span< const uint8_t > in)
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< MessageAuthenticationCode > create(std::string_view algo_spec, std::string_view provider="")
virtual std::string provider() const
virtual void start_msg(std::span< const uint8_t > nonce)
static std::vector< std::string > providers(std::string_view algo_spec)
std::string arg(size_t i) const
const std::string & algo_name() const
size_t arg_as_integer(size_t i, size_t def_value) const
virtual std::string name() const =0
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
std::vector< std::string > probe_providers_of(std::string_view algo_spec, const std::vector< std::string > &possible={"base"})
std::vector< T, secure_allocator< T > > secure_vector