Botan  2.19.1
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 
36 
37 /*
38 * As of 1.11.26 this header is deprecated. Instead use the calls T::create and
39 * T::providers (as demonstrated in the implementation below).
40 */
41 
42 /*
43 * Get an algorithm object
44 * NOTE: these functions create and return new objects, letting the
45 * caller assume ownership of them
46 */
47 
48 #if defined(BOTAN_HAS_BLOCK_CIPHER)
49 
50 /**
51 * Block cipher factory method.
52 *
53 * @param algo_spec the name of the desired block cipher
54 * @param provider the provider to use
55 * @return pointer to the block cipher object
56 */
57 BOTAN_DEPRECATED("Use BlockCipher::create")
58 inline BlockCipher* get_block_cipher(const std::string& algo_spec,
59  const std::string& provider = "")
60  {
61  return BlockCipher::create(algo_spec, provider).release();
62  }
63 
64 BOTAN_DEPRECATED("Use BlockCipher::create_or_throw")
65 inline std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec,
66  const std::string& provider = "")
67  {
68  return BlockCipher::create_or_throw(algo_spec, provider);
69  }
70 
71 BOTAN_DEPRECATED("Use BlockCipher::providers")
72 inline std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
73  {
74  return BlockCipher::providers(algo_spec);
75  }
76 
77 #endif
78 
79 #if defined(BOTAN_HAS_STREAM_CIPHER)
80 
81 /**
82 * Stream cipher factory method.
83 *
84 * @param algo_spec the name of the desired stream cipher
85 * @param provider the provider to use
86 * @return pointer to the stream cipher object
87 */
88 BOTAN_DEPRECATED("Use StreamCipher::create")
89 inline StreamCipher* get_stream_cipher(const std::string& algo_spec,
90  const std::string& provider = "")
91  {
92  return StreamCipher::create(algo_spec, provider).release();
93  }
94 
95 BOTAN_DEPRECATED("Use StreamCipher::create_or_throw")
96 inline std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec,
97  const std::string& provider = "")
98  {
99  return StreamCipher::create_or_throw(algo_spec, provider);
100  }
101 
102 BOTAN_DEPRECATED("Use StreamCipher::providers")
103 inline std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
104  {
105  return StreamCipher::providers(algo_spec);
106  }
107 
108 #endif
109 
110 #if defined(BOTAN_HAS_HASH)
111 
112 /**
113 * Hash function factory method.
114 *
115 * @param algo_spec the name of the desired hash function
116 * @param provider the provider to use
117 * @return pointer to the hash function object
118 */
119 BOTAN_DEPRECATED("Use HashFunction::create")
120 inline HashFunction* get_hash_function(const std::string& algo_spec,
121  const std::string& provider = "")
122  {
123  return HashFunction::create(algo_spec, provider).release();
124  }
125 
126 BOTAN_DEPRECATED("Use HashFunction::create_or_throw")
127 inline std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec,
128  const std::string& provider = "")
129  {
130  return HashFunction::create_or_throw(algo_spec, provider);
131  }
132 
133 BOTAN_DEPRECATED("Use HashFunction::create")
134 inline HashFunction* get_hash(const std::string& algo_spec,
135  const std::string& provider = "")
136  {
137  return HashFunction::create(algo_spec, provider).release();
138  }
139 
140 BOTAN_DEPRECATED("Use HashFunction::providers")
141 inline std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
142  {
143  return HashFunction::providers(algo_spec);
144  }
145 
146 #endif
147 
148 #if defined(BOTAN_HAS_MAC)
149 /**
150 * MAC factory method.
151 *
152 * @param algo_spec the name of the desired MAC
153 * @param provider the provider to use
154 * @return pointer to the MAC object
155 */
156 BOTAN_DEPRECATED("MessageAuthenticationCode::create")
157 inline MessageAuthenticationCode* get_mac(const std::string& algo_spec,
158  const std::string& provider = "")
159  {
160  return MessageAuthenticationCode::create(algo_spec, provider).release();
161  }
162 
163 BOTAN_DEPRECATED("MessageAuthenticationCode::create_or_throw")
164 inline std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec,
165  const std::string& provider = "")
166  {
167  return MessageAuthenticationCode::create(algo_spec, provider);
168  }
169 
170 BOTAN_DEPRECATED("MessageAuthenticationCode::providers")
171 inline std::vector<std::string> get_mac_providers(const std::string& algo_spec)
172  {
173  return MessageAuthenticationCode::providers(algo_spec);
174  }
175 #endif
176 
177 }
178 
179 #endif
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:46
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:344
static std::unique_ptr< StreamCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: bigint.h:1143
static std::vector< std::string > providers(const std::string &algo_spec)
Definition: mac.cpp:134
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:354
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="")
#define BOTAN_DEPRECATED_HEADER(hdr)
Definition: compiler.h:132
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="")
std::string lookup(const OID &oid)
Definition: oids.h:71