blob: baaea15ddd65851a81725cb7a70896a4583ed148 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*************************************************
* MAC Lookup *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
#include <botan/eng_def.h>
#include <botan/lookup.h>
#include <botan/libstate.h>
#include <botan/parsing.h>
#if defined(BOTAN_HAS_CBC_MAC)
#include <botan/cbc_mac.h>
#endif
#if defined(BOTAN_HAS_CMAC)
#include <botan/cmac.h>
#endif
#if defined(BOTAN_HAS_HMAC)
#include <botan/hmac.h>
#endif
#if defined(BOTAN_HAS_SSL3_MAC)
#include <botan/ssl3_mac.h>
#endif
#if defined(BOTAN_HAS_ANSI_X919_MAC)
#include <botan/x919_mac.h>
#endif
namespace Botan {
/*************************************************
* Look for an algorithm with this name *
*************************************************/
MessageAuthenticationCode*
Default_Engine::find_mac(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
if(name.empty())
return 0;
const std::string algo_name = global_state().deref_alias(name[0]);
#if defined(BOTAN_HAS_CBC_MAC)
if(algo_name == "CBC-MAC")
{
if(name.size() == 2)
return new CBC_MAC(get_block_cipher(name[1]));
throw Invalid_Algorithm_Name(algo_spec);
}
#endif
#if defined(BOTAN_HAS_CMAC)
if(algo_name == "CMAC")
{
if(name.size() == 2)
return new CMAC(get_block_cipher(name[1]));
throw Invalid_Algorithm_Name(algo_spec);
}
#endif
#if defined(BOTAN_HAS_HMAC)
if(algo_name == "HMAC")
{
if(name.size() == 2)
return new HMAC(get_hash(name[1]));
throw Invalid_Algorithm_Name(algo_spec);
}
#endif
#if defined(BOTAN_HAS_SSL3_MAC)
if(algo_name == "SSL3-MAC")
{
if(name.size() == 2)
return new SSL3_MAC(get_hash(name[1]));
throw Invalid_Algorithm_Name(algo_spec);
}
#endif
#if defined(BOTAN_HAS_ANSI_X919_MAC)
if(algo_name == "X9.19-MAC")
{
if(name.size() == 1)
return new ANSI_X919_MAC(get_block_cipher("DES"));
throw Invalid_Algorithm_Name(algo_spec);
}
#endif
return 0;
}
}
|