Botan  1.11.15
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::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
48  {
49  return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec));
50  }
51 
52 std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
53  {
54  return providers_of<StreamCipher>(StreamCipher::Spec(algo_spec));
55  }
56 
57 std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
58  {
59  return providers_of<HashFunction>(HashFunction::Spec(algo_spec));
60  }
61 
62 std::vector<std::string> get_mac_providers(const std::string& algo_spec)
63  {
64  return providers_of<MessageAuthenticationCode>(MessageAuthenticationCode::Spec(algo_spec));
65  }
66 
67 /*
68 * Get a PBKDF algorithm by name
69 */
70 PBKDF* get_pbkdf(const std::string& algo_spec, const std::string& provider)
71  {
72  if(PBKDF* pbkdf = make_a<PBKDF>(algo_spec, provider))
73  return pbkdf;
74  throw Algorithm_Not_Found(algo_spec);
75  }
76 
77 }
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
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
std::vector< std::string > get_block_cipher_providers(const std::string &algo_spec)
Definition: lookup.cpp:47
std::vector< std::string > get_hash_function_providers(const std::string &algo_spec)
Definition: lookup.cpp:57
std::vector< std::string > get_stream_cipher_providers(const std::string &algo_spec)
Definition: lookup.cpp:52
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:62
PBKDF * get_pbkdf(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:70
static Algo_Registry< T > & global_registry()
Definition: algo_registry.h:28