Botan  2.6.0
Crypto and TLS for C++11
lookup.h
Go to the documentation of this file.
1 /*
2 * Algorithm Lookup
3 * (C) 1999-2007,2015 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_LOOKUP_H_
9 #define BOTAN_LOOKUP_H_
10 
11 #include <botan/build.h>
12 #include <botan/exceptn.h>
13 #include <string>
14 #include <vector>
15 #include <memory>
16 
17 #if defined(BOTAN_HAS_BLOCK_CIPHER)
18  #include <botan/block_cipher.h>
19 #endif
20 
21 #if defined(BOTAN_HAS_STREAM_CIPHER)
22  #include <botan/stream_cipher.h>
23 #endif
24 
25 #if defined(BOTAN_HAS_HASH)
26  #include <botan/hash.h>
27 #endif
28 
29 #if defined(BOTAN_HAS_MAC)
30  #include <botan/mac.h>
31 #endif
32 
33 namespace Botan {
34 
35 /*
36 * As of 1.11.26 this header is deprecated. Instead use the calls T::create and
37 * T::providers (as demonstrated in the implementation below).
38 */
39 
40 /*
41 * Get an algorithm object
42 * NOTE: these functions create and return new objects, letting the
43 * caller assume ownership of them
44 */
45 
46 #if defined(BOTAN_HAS_BLOCK_CIPHER)
47 
48 /**
49 * Block cipher factory method.
50 *
51 * @param algo_spec the name of the desired block cipher
52 * @param provider the provider to use
53 * @return pointer to the block cipher object
54 */
55 BOTAN_DEPRECATED("Use BlockCipher::create")
56 inline BlockCipher* get_block_cipher(const std::string& algo_spec,
57  const std::string& provider = "")
58  {
59  return BlockCipher::create(algo_spec, provider).release();
60  }
61 
62 BOTAN_DEPRECATED("Use BlockCipher::create_or_throw")
63 inline std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec,
64  const std::string& provider = "")
65  {
66  return BlockCipher::create_or_throw(algo_spec, provider);
67  }
68 
69 BOTAN_DEPRECATED("Use BlockCipher::providers")
70 inline std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
71  {
72  return BlockCipher::providers(algo_spec);
73  }
74 
75 #endif
76 
77 #if defined(BOTAN_HAS_STREAM_CIPHER)
78 
79 /**
80 * Stream cipher factory method.
81 *
82 * @param algo_spec the name of the desired stream cipher
83 * @param provider the provider to use
84 * @return pointer to the stream cipher object
85 */
86 BOTAN_DEPRECATED("Use StreamCipher::create")
87 inline StreamCipher* get_stream_cipher(const std::string& algo_spec,
88  const std::string& provider = "")
89  {
90  return StreamCipher::create(algo_spec, provider).release();
91  }
92 
93 BOTAN_DEPRECATED("Use StreamCipher::create_or_throw")
94 inline std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec,
95  const std::string& provider = "")
96  {
97  return StreamCipher::create_or_throw(algo_spec, provider);
98  }
99 
100 BOTAN_DEPRECATED("Use StreamCipher::providers")
101 inline std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
102  {
103  return StreamCipher::providers(algo_spec);
104  }
105 
106 #endif
107 
108 #if defined(BOTAN_HAS_HASH)
109 
110 /**
111 * Hash function factory method.
112 *
113 * @param algo_spec the name of the desired hash function
114 * @param provider the provider to use
115 * @return pointer to the hash function object
116 */
117 BOTAN_DEPRECATED("Use HashFunction::create")
118 inline HashFunction* get_hash_function(const std::string& algo_spec,
119  const std::string& provider = "")
120  {
121  return HashFunction::create(algo_spec, provider).release();
122  }
123 
124 BOTAN_DEPRECATED("Use HashFunction::create_or_throw")
125 inline std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec,
126  const std::string& provider = "")
127  {
128  return HashFunction::create_or_throw(algo_spec, provider);
129  }
130 
131 BOTAN_DEPRECATED("Use HashFunction::create")
132 inline HashFunction* get_hash(const std::string& algo_spec,
133  const std::string& provider = "")
134  {
135  return HashFunction::create(algo_spec, provider).release();
136  }
137 
138 BOTAN_DEPRECATED("Use HashFunction::providers")
139 inline std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
140  {
141  return HashFunction::providers(algo_spec);
142  }
143 
144 #endif
145 
146 #if defined(BOTAN_HAS_MAC)
147 /**
148 * MAC factory method.
149 *
150 * @param algo_spec the name of the desired MAC
151 * @param provider the provider to use
152 * @return pointer to the MAC object
153 */
154 BOTAN_DEPRECATED("MessageAuthenticationCode::create")
155 inline MessageAuthenticationCode* get_mac(const std::string& algo_spec,
156  const std::string& provider = "")
157  {
158  return MessageAuthenticationCode::create(algo_spec, provider).release();
159  }
160 
161 BOTAN_DEPRECATED("MessageAuthenticationCode::create_or_throw")
162 inline std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec,
163  const std::string& provider = "")
164  {
165  return MessageAuthenticationCode::create(algo_spec, provider);
166  }
167 
168 BOTAN_DEPRECATED("MessageAuthenticationCode::providers")
169 inline std::vector<std::string> get_mac_providers(const std::string& algo_spec)
170  {
171  return MessageAuthenticationCode::providers(algo_spec);
172  }
173 #endif
174 
175 }
176 
177 #endif
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:45
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:345
static std::unique_ptr< StreamCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: bigint.h:719
static std::vector< std::string > providers(const std::string &algo_spec)
Definition: mac.cpp:133
static std::vector< std::string > providers(const std::string &algo_spec)
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:106
static std::vector< std::string > providers(const std::string &algo_spec)
Definition: hash.cpp:355
Definition: alg_id.cpp:13
static std::vector< std::string > providers(const std::string &algo_spec)
static std::unique_ptr< BlockCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< BlockCipher > create(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< StreamCipher > create(const std::string &algo_spec, const std::string &provider="")