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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Algorithm Retrieval
* (C) 1999-2007,2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include <botan/lookup.h>
#include <botan/internal/algo_registry.h>
#include <botan/cipher_mode.h>
#include <botan/block_cipher.h>
#include <botan/stream_cipher.h>
#include <botan/hash.h>
#include <botan/mac.h>
#include <botan/pbkdf.h>
namespace Botan {
Transform* get_transform(const std::string& specstr,
const std::string& provider,
const std::string& dirstr)
{
Algo_Registry<Transform>::Spec spec(specstr, dirstr);
return Algo_Registry<Transform>::global_registry().make(spec, provider);
}
BlockCipher* get_block_cipher(const std::string& algo_spec, const std::string& provider)
{
return make_a<BlockCipher>(algo_spec, provider);
}
StreamCipher* get_stream_cipher(const std::string& algo_spec, const std::string& provider)
{
return make_a<StreamCipher>(algo_spec, provider);
}
HashFunction* get_hash_function(const std::string& algo_spec, const std::string& provider)
{
return make_a<HashFunction>(algo_spec, provider);
}
MessageAuthenticationCode* get_mac(const std::string& algo_spec, const std::string& provider)
{
return make_a<MessageAuthenticationCode>(algo_spec, provider);
}
std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec,
const std::string& provider)
{
if(auto x = get_block_cipher(algo_spec, provider))
return std::unique_ptr<BlockCipher>(x);
throw Algorithm_Not_Found(algo_spec);
}
std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec,
const std::string& provider)
{
if(auto x = get_stream_cipher(algo_spec, provider))
return std::unique_ptr<StreamCipher>(x);
throw Algorithm_Not_Found(algo_spec);
}
std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec,
const std::string& provider)
{
if(auto x = get_hash_function(algo_spec, provider))
return std::unique_ptr<HashFunction>(x);
throw Algorithm_Not_Found(algo_spec);
}
std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec,
const std::string& provider)
{
if(auto x = get_mac(algo_spec, provider))
return std::unique_ptr<MessageAuthenticationCode>(x);
throw Algorithm_Not_Found(algo_spec);
}
std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
{
return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec));
}
std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
{
return providers_of<StreamCipher>(StreamCipher::Spec(algo_spec));
}
std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
{
return providers_of<HashFunction>(HashFunction::Spec(algo_spec));
}
std::vector<std::string> get_mac_providers(const std::string& algo_spec)
{
return providers_of<MessageAuthenticationCode>(MessageAuthenticationCode::Spec(algo_spec));
}
/*
* Get a PBKDF algorithm by name
*/
PBKDF* get_pbkdf(const std::string& algo_spec, const std::string& provider)
{
if(PBKDF* pbkdf = make_a<PBKDF>(algo_spec, provider))
return pbkdf;
throw Algorithm_Not_Found(algo_spec);
}
}
|