Botan 1.10.17
lookup_mac.cpp
Go to the documentation of this file.
1/*
2* MAC Lookup
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#include <botan/internal/core_engine.h>
9#include <botan/scan_name.h>
10#include <botan/algo_factory.h>
11
12#if defined(BOTAN_HAS_CBC_MAC)
13 #include <botan/cbc_mac.h>
14#endif
15
16#if defined(BOTAN_HAS_CMAC)
17 #include <botan/cmac.h>
18#endif
19
20#if defined(BOTAN_HAS_HMAC)
21 #include <botan/hmac.h>
22#endif
23
24#if defined(BOTAN_HAS_SSL3_MAC)
25 #include <botan/ssl3_mac.h>
26#endif
27
28#if defined(BOTAN_HAS_ANSI_X919_MAC)
29 #include <botan/x919_mac.h>
30#endif
31
32namespace Botan {
33
34/*
35* Look for an algorithm with this name
36*/
39 Algorithm_Factory& af) const
40 {
41
42#if defined(BOTAN_HAS_CBC_MAC)
43 if(request.algo_name() == "CBC-MAC" && request.arg_count() == 1)
44 return new CBC_MAC(af.make_block_cipher(request.arg(0)));
45#endif
46
47#if defined(BOTAN_HAS_CMAC)
48 if(request.algo_name() == "CMAC" && request.arg_count() == 1)
49 return new CMAC(af.make_block_cipher(request.arg(0)));
50#endif
51
52#if defined(BOTAN_HAS_HMAC)
53 if(request.algo_name() == "HMAC" && request.arg_count() == 1)
54 return new HMAC(af.make_hash_function(request.arg(0)));
55#endif
56
57#if defined(BOTAN_HAS_SSL3_MAC)
58 if(request.algo_name() == "SSL3-MAC" && request.arg_count() == 1)
59 return new SSL3_MAC(af.make_hash_function(request.arg(0)));
60#endif
61
62#if defined(BOTAN_HAS_ANSI_X919_MAC)
63 if(request.algo_name() == "X9.19-MAC" && request.arg_count() == 0)
64 return new ANSI_X919_MAC(af.make_block_cipher("DES"));
65#endif
66
67 return 0;
68 }
69
70}
ANSI_X919_MAC(BlockCipher *cipher)
Definition x919_mac.cpp:87
HashFunction * make_hash_function(const std::string &algo_spec, const std::string &provider="")
BlockCipher * make_block_cipher(const std::string &algo_spec, const std::string &provider="")
CBC_MAC(BlockCipher *cipher)
Definition cbc_mac.cpp:91
CMAC(BlockCipher *cipher)
Definition cmac.cpp:132
MessageAuthenticationCode * find_mac(const SCAN_Name &request, Algorithm_Factory &) const
HMAC(HashFunction *hash)
Definition hmac.cpp:87
std::string arg(size_t i) const
size_t arg_count() const
Definition scan_name.h:47
std::string algo_name() const
Definition scan_name.h:37
SSL3_MAC(HashFunction *hash)
Definition ssl3_mac.cpp:75