Botan  2.4.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/block_cipher.h>
12 #include <botan/stream_cipher.h>
13 #include <botan/hash.h>
14 #include <botan/mac.h>
15 #include <botan/exceptn.h>
16 #include <string>
17 #include <vector>
18 #include <memory>
19 
20 namespace Botan {
21 
22 /*
23 * As of 1.11.26 this header is deprecated. Instead use the calls T::create and
24 * T::providers (as demonstrated in the implementation below).
25 */
26 
27 /*
28 * Get an algorithm object
29 * NOTE: these functions create and return new objects, letting the
30 * caller assume ownership of them
31 */
32 
33 /**
34 * Block cipher factory method.
35 *
36 * @param algo_spec the name of the desired block cipher
37 * @param provider the provider to use
38 * @return pointer to the block cipher object
39 */
40 BOTAN_DEPRECATED("Use BlockCipher::create")
41 inline BlockCipher* get_block_cipher(const std::string& algo_spec,
42  const std::string& provider = "")
43  {
44  return BlockCipher::create(algo_spec, provider).release();
45  }
46 
47 BOTAN_DEPRECATED("Use BlockCipher::create_or_throw")
48 inline std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec,
49  const std::string& provider = "")
50  {
51  return BlockCipher::create_or_throw(algo_spec, provider);
52  }
53 
54 BOTAN_DEPRECATED("Use BlockCipher::providers")
55 inline std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec)
56  {
57  return BlockCipher::providers(algo_spec);
58  }
59 
60 /**
61 * Stream cipher factory method.
62 *
63 * @param algo_spec the name of the desired stream cipher
64 * @param provider the provider to use
65 * @return pointer to the stream cipher object
66 */
67 BOTAN_DEPRECATED("Use StreamCipher::create")
68 inline StreamCipher* get_stream_cipher(const std::string& algo_spec,
69  const std::string& provider = "")
70  {
71  return StreamCipher::create(algo_spec, provider).release();
72  }
73 
74 BOTAN_DEPRECATED("Use StreamCipher::create_or_throw")
75 inline std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec,
76  const std::string& provider = "")
77  {
78  return StreamCipher::create_or_throw(algo_spec, provider);
79  }
80 
81 BOTAN_DEPRECATED("Use StreamCipher::providers")
82 inline std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec)
83  {
84  return StreamCipher::providers(algo_spec);
85  }
86 
87 /**
88 * Hash function factory method.
89 *
90 * @param algo_spec the name of the desired hash function
91 * @param provider the provider to use
92 * @return pointer to the hash function object
93 */
94 BOTAN_DEPRECATED("Use HashFunction::create")
95 inline HashFunction* get_hash_function(const std::string& algo_spec,
96  const std::string& provider = "")
97  {
98  return HashFunction::create(algo_spec, provider).release();
99  }
100 
101 BOTAN_DEPRECATED("Use HashFunction::create_or_throw")
102 inline std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec,
103  const std::string& provider = "")
104  {
105  return HashFunction::create_or_throw(algo_spec, provider);
106  }
107 
108 BOTAN_DEPRECATED("Use HashFunction::create")
109 inline HashFunction* get_hash(const std::string& algo_spec,
110  const std::string& provider = "")
111  {
112  return HashFunction::create(algo_spec, provider).release();
113  }
114 
115 BOTAN_DEPRECATED("Use HashFunction::providers")
116 inline std::vector<std::string> get_hash_function_providers(const std::string& algo_spec)
117  {
118  return HashFunction::providers(algo_spec);
119  }
120 
121 /**
122 * MAC factory method.
123 *
124 * @param algo_spec the name of the desired MAC
125 * @param provider the provider to use
126 * @return pointer to the MAC object
127 */
128 BOTAN_DEPRECATED("MessageAuthenticationCode::create")
129 inline MessageAuthenticationCode* get_mac(const std::string& algo_spec,
130  const std::string& provider = "")
131  {
132  return MessageAuthenticationCode::create(algo_spec, provider).release();
133  }
134 
135 BOTAN_DEPRECATED("MessageAuthenticationCode::create_or_throw")
136 inline std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec,
137  const std::string& provider = "")
138  {
139  return MessageAuthenticationCode::create(algo_spec, provider);
140  }
141 
142 BOTAN_DEPRECATED("MessageAuthenticationCode::providers")
143 inline std::vector<std::string> get_mac_providers(const std::string& algo_spec)
144  {
145  return MessageAuthenticationCode::providers(algo_spec);
146  }
147 
148 }
149 
150 #endif
std::unique_ptr< HashFunction > make_hash_function(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:102
std::unique_ptr< StreamCipher > make_stream_cipher(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:75
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
std::vector< std::string > get_hash_function_providers(const std::string &algo_spec)
Definition: lookup.h:116
static std::unique_ptr< StreamCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
HashFunction * get_hash(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:109
BlockCipher * get_block_cipher(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:41
Definition: bigint.h:635
std::vector< std::string > get_mac_providers(const std::string &algo_spec)
Definition: lookup.h:143
std::unique_ptr< MessageAuthenticationCode > make_message_auth(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:136
std::vector< std::string > get_block_cipher_providers(const std::string &algo_spec)
Definition: lookup.h:55
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)
std::vector< std::string > get_stream_cipher_providers(const std::string &algo_spec)
Definition: lookup.h:82
std::unique_ptr< BlockCipher > make_block_cipher(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:48
StreamCipher * get_stream_cipher(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:68
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="")
MessageAuthenticationCode * get_mac(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:129
static std::unique_ptr< StreamCipher > create(const std::string &algo_spec, const std::string &provider="")
HashFunction * get_hash_function(const std::string &algo_spec, const std::string &provider="")
Definition: lookup.h:95