aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/base/lookup.cpp
blob: b6a49ec6b9cfcc544d0b28ce9b287ec6766fdaae (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
/*
* 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::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);
   }

}