Botan  1.10.10
lookup.cpp
Go to the documentation of this file.
1 /*
2 * Algorithm Retrieval
3 * (C) 1999-2007,2015 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #include <botan/lookup.h>
9 #include <botan/internal/algo_registry.h>
10 #include <botan/cipher_mode.h>
11 #include <botan/block_cipher.h>
12 #include <botan/stream_cipher.h>
13 #include <botan/hash.h>
14 #include <botan/mac.h>
15 #include <botan/pbkdf.h>
16 
17 namespace Botan {
18 
19 Transform* get_transform(const std::string& specstr,
20  const std::string& provider,
21  const std::string& dirstr)
22  {
23  Algo_Registry<Transform>::Spec spec(specstr, dirstr);
24  return Algo_Registry<Transform>::global_registry().make(spec, provider);
25  }
26 
27 BlockCipher* get_block_cipher(const std::string& algo_spec, const std::string& provider)
28  {
29  return make_a<BlockCipher>(algo_spec, provider);
30  }
31 
32 StreamCipher* get_stream_cipher(const std::string& algo_spec, const std::string& provider)
33  {
34  return make_a<StreamCipher>(algo_spec, provider);
35  }
36 
37 HashFunction* get_hash_function(const std::string& algo_spec, const std::string& provider)
38  {
39  return make_a<HashFunction>(algo_spec, provider);
40  }
41 
42 MessageAuthenticationCode* get_mac(const std::string& algo_spec, const std::string& provider)
43  {
44  return make_a<MessageAuthenticationCode>(algo_spec, provider);
45  }
46 
47 std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec,
48  const std::string& provider)
49  {
50  if(auto x = get_block_cipher(algo_spec, provider))
51  return std::unique_ptr<BlockCipher>(x);
52  throw Algorithm_Not_Found(algo_spec);
53  }
54 
55 std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec,
56  const std::string& provider)
57  {
58  if(auto x = get_stream_cipher(algo_spec, provider))
59  return std::unique_ptr<StreamCipher>(x);
60  throw Algorithm_Not_Found(algo_spec);
61  }
62 
63 std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec,
64  const std::string& provider)
65  {
66  if(auto x = get_hash_function(algo_spec, provider))
67  return std::unique_ptr<HashFunction>(x);
68  throw Algorithm_Not_Found(algo_spec);
69  }
70 
71 std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec,
72  const std::string& provider)
73  {
74  if(auto x = get_mac(algo_spec, provider))
75  return std::unique_ptr<MessageAuthenticationCode>(x);
76  throw Algorithm_Not_Found(algo_spec);
77  }
78 
79 std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
80  {
81  return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec));
82  }
83 
84 std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
85  {
86  return providers_of<StreamCipher>(StreamCipher::Spec(algo_spec));
87  }
88 
89 std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
90  {
91  return providers_of<HashFunction>(HashFunction::Spec(algo_spec));
92  }
93 
94 std::vector<std::string> get_mac_providers(const std::string& algo_spec)
95  {
96  return providers_of<MessageAuthenticationCode>(MessageAuthenticationCode::Spec(algo_spec));
97  }
98 
99 /*
100 * Get a PBKDF algorithm by name
101 */
102 PBKDF* get_pbkdf(const std::string& algo_spec, const std::string& provider)
103  {
104  if(PBKDF* pbkdf = make_a<PBKDF>(algo_spec, provider))
105  return pbkdf;
106  throw Algorithm_Not_Found(algo_spec);
107  }
108 
109 }
const BigInt & x
Definition: dsa.cpp:99
StreamCipher * get_stream_cipher(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:32
BlockCipher * get_block_cipher(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:27
std::unique_ptr< BlockCipher > make_block_cipher(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:47
MessageAuthenticationCode * get_mac(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:42
Transform * get_transform(const std::string &specstr, const std::string &provider, const std::string &dirstr)
Definition: lookup.cpp:19
def pbkdf
Definition: botan.py:255
std::vector< std::string > get_block_cipher_providers(const std::string &algo_spec)
Definition: lookup.cpp:79
std::vector< std::string > get_hash_function_providers(const std::string &algo_spec)
Definition: lookup.cpp:89
std::vector< std::string > get_stream_cipher_providers(const std::string &algo_spec)
Definition: lookup.cpp:84
HashFunction * get_hash_function(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:37
SCAN_Name Spec
Definition: hash.h:37
std::vector< std::string > get_mac_providers(const std::string &algo_spec)
Definition: lookup.cpp:94
std::unique_ptr< MessageAuthenticationCode > make_message_auth(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:71
PBKDF * get_pbkdf(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:102
std::unique_ptr< StreamCipher > make_stream_cipher(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:55
static Algo_Registry< T > & global_registry()
Definition: algo_registry.h:29
std::unique_ptr< HashFunction > make_hash_function(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:63