9 #include <botan/scan_name.h>
10 #include <botan/mem_ops.h>
12 #if defined(BOTAN_HAS_CBC_MAC)
13 #include <botan/cbc_mac.h>
16 #if defined(BOTAN_HAS_CMAC)
17 #include <botan/cmac.h>
20 #if defined(BOTAN_HAS_GMAC)
21 #include <botan/gmac.h>
24 #if defined(BOTAN_HAS_HMAC)
25 #include <botan/hmac.h>
28 #if defined(BOTAN_HAS_POLY1305)
29 #include <botan/poly1305.h>
32 #if defined(BOTAN_HAS_SIPHASH)
33 #include <botan/siphash.h>
36 #if defined(BOTAN_HAS_ANSI_X919_MAC)
37 #include <botan/x919_mac.h>
42 std::unique_ptr<MessageAuthenticationCode>
44 const std::string& provider)
48 #if defined(BOTAN_HAS_GMAC)
51 if(provider.empty() || provider ==
"base")
54 return std::unique_ptr<MessageAuthenticationCode>(
new GMAC(bc.release()));
59 #if defined(BOTAN_HAS_HMAC)
63 if(provider.empty() || provider ==
"base")
66 return std::unique_ptr<MessageAuthenticationCode>(
new HMAC(h.release()));
71 #if defined(BOTAN_HAS_POLY1305)
74 if(provider.empty() || provider ==
"base")
75 return std::unique_ptr<MessageAuthenticationCode>(
new Poly1305);
79 #if defined(BOTAN_HAS_SIPHASH)
82 if(provider.empty() || provider ==
"base")
84 return std::unique_ptr<MessageAuthenticationCode>(
90 #if defined(BOTAN_HAS_CMAC)
94 if(provider.empty() || provider ==
"base")
97 return std::unique_ptr<MessageAuthenticationCode>(
new CMAC(bc.release()));
103 #if defined(BOTAN_HAS_CBC_MAC)
106 if(provider.empty() || provider ==
"base")
109 return std::unique_ptr<MessageAuthenticationCode>(
new CBC_MAC(bc.release()));
114 #if defined(BOTAN_HAS_ANSI_X919_MAC)
117 if(provider.empty() || provider ==
"base")
119 return std::unique_ptr<MessageAuthenticationCode>(
new ANSI_X919_MAC);
130 std::vector<std::string>
133 return probe_providers_of<MessageAuthenticationCode>(algo_spec, {
"base",
"openssl"});
137 std::unique_ptr<MessageAuthenticationCode>
139 const std::string& provider)
155 if(our_mac.size() != length)
158 return same_mem(our_mac.data(), mac, length);
std::string arg(size_t i) const
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
bool same_mem(const T *p1, const T *p2, size_t n)
static std::vector< std::string > providers(const std::string &algo_spec)
std::vector< T, secure_allocator< T >> secure_vector
virtual bool verify_mac(const uint8_t in[], size_t length)
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
size_t arg_as_integer(size_t i, size_t def_value) const
static std::unique_ptr< BlockCipher > create(const std::string &algo_spec, const std::string &provider="")
const std::string & algo_name() const
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(const std::string &algo_spec, const std::string &provider="")