Botan 1.10.17
lookup.h
Go to the documentation of this file.
1/*
2* Algorithm Lookup
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_LOOKUP_H__
9#define BOTAN_LOOKUP_H__
10
11#include <botan/libstate.h>
12#include <botan/engine.h>
13#include <botan/filters.h>
14#include <botan/mode_pad.h>
15#include <botan/kdf.h>
16#include <botan/eme.h>
17#include <botan/emsa.h>
18#include <botan/pbkdf.h>
19
20namespace Botan {
21
22/**
23* Retrieve an object prototype from the global factory
24* @param algo_spec an algorithm name
25* @return constant prototype object (use clone to create usable object),
26 library retains ownership
27*/
28inline const BlockCipher*
29retrieve_block_cipher(const std::string& algo_spec)
30 {
32 return af.prototype_block_cipher(algo_spec);
33 }
34
35/**
36* Retrieve an object prototype from the global factory
37* @param algo_spec an algorithm name
38* @return constant prototype object (use clone to create usable object),
39 library retains ownership
40*/
41inline const StreamCipher*
42retrieve_stream_cipher(const std::string& algo_spec)
43 {
45 return af.prototype_stream_cipher(algo_spec);
46 }
47
48/**
49* Retrieve an object prototype from the global factory
50* @param algo_spec an algorithm name
51* @return constant prototype object (use clone to create usable object),
52 library retains ownership
53*/
54inline const HashFunction*
55retrieve_hash(const std::string& algo_spec)
56 {
58 return af.prototype_hash_function(algo_spec);
59 }
60
61/**
62* Retrieve an object prototype from the global factory
63* @param algo_spec an algorithm name
64* @return constant prototype object (use clone to create usable object),
65 library retains ownership
66*/
67inline const MessageAuthenticationCode*
68retrieve_mac(const std::string& algo_spec)
69 {
71 return af.prototype_mac(algo_spec);
72 }
73
74/*
75* Get an algorithm object
76* NOTE: these functions create and return new objects, letting the
77* caller assume ownership of them
78*/
79
80/**
81* Block cipher factory method.
82* @deprecated Call algorithm_factory() directly
83*
84* @param algo_spec the name of the desired block cipher
85* @return pointer to the block cipher object
86*/
87inline BlockCipher* get_block_cipher(const std::string& algo_spec)
88 {
90 return af.make_block_cipher(algo_spec);
91 }
92
93/**
94* Stream cipher factory method.
95* @deprecated Call algorithm_factory() directly
96*
97* @param algo_spec the name of the desired stream cipher
98* @return pointer to the stream cipher object
99*/
100inline StreamCipher* get_stream_cipher(const std::string& algo_spec)
101 {
103 return af.make_stream_cipher(algo_spec);
104 }
105
106/**
107* Hash function factory method.
108* @deprecated Call algorithm_factory() directly
109*
110* @param algo_spec the name of the desired hash function
111* @return pointer to the hash function object
112*/
113inline HashFunction* get_hash(const std::string& algo_spec)
114 {
116 return af.make_hash_function(algo_spec);
117 }
118
119/**
120* MAC factory method.
121* @deprecated Call algorithm_factory() directly
122*
123* @param algo_spec the name of the desired MAC
124* @return pointer to the MAC object
125*/
126inline MessageAuthenticationCode* get_mac(const std::string& algo_spec)
127 {
129 return af.make_mac(algo_spec);
130 }
131
132/**
133* Password based key derivation function factory method
134* @param algo_spec the name of the desired PBKDF algorithm
135* @return pointer to newly allocated object of that type
136*/
137BOTAN_DLL PBKDF* get_pbkdf(const std::string& algo_spec);
138
139/**
140* @deprecated Use get_pbkdf
141* @param algo_spec the name of the desired algorithm
142* @return pointer to newly allocated object of that type
143*/
144inline PBKDF* get_s2k(const std::string& algo_spec)
145 {
146 return get_pbkdf(algo_spec);
147 }
148
149/*
150* Get an EMSA/EME/KDF/MGF function
151*/
152// NOTE: these functions create and return new objects, letting the
153// caller assume ownership of them
154
155/**
156* Factory method for EME (message-encoding methods for encryption) objects
157* @param algo_spec the name of the EME to create
158* @return pointer to newly allocated object of that type
159*/
160BOTAN_DLL EME* get_eme(const std::string& algo_spec);
161
162/**
163* Factory method for EMSA (message-encoding methods for signatures
164* with appendix) objects
165* @param algo_spec the name of the EME to create
166* @return pointer to newly allocated object of that type
167*/
168BOTAN_DLL EMSA* get_emsa(const std::string& algo_spec);
169
170/**
171* Factory method for KDF (key derivation function)
172* @param algo_spec the name of the KDF to create
173* @return pointer to newly allocated object of that type
174*/
175BOTAN_DLL KDF* get_kdf(const std::string& algo_spec);
176
177/*
178* Get a cipher object
179*/
180
181/**
182* Factory method for general symmetric cipher filters.
183* @param algo_spec the name of the desired cipher
184* @param key the key to be used for encryption/decryption performed by
185* the filter
186* @param iv the initialization vector to be used
187* @param direction determines whether the filter will be an encrypting
188* or decrypting filter
189* @return pointer to newly allocated encryption or decryption filter
190*/
191BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec,
192 const SymmetricKey& key,
193 const InitializationVector& iv,
194 Cipher_Dir direction);
195
196/**
197* Factory method for general symmetric cipher filters.
198* @param algo_spec the name of the desired cipher
199* @param key the key to be used for encryption/decryption performed by
200* the filter
201* @param direction determines whether the filter will be an encrypting
202* or decrypting filter
203* @return pointer to the encryption or decryption filter
204*/
205BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec,
206 const SymmetricKey& key,
207 Cipher_Dir direction);
208
209/**
210* Factory method for general symmetric cipher filters. No key will be
211* set in the filter.
212*
213* @param algo_spec the name of the desired cipher
214* @param direction determines whether the filter will be an encrypting or
215* decrypting filter
216* @return pointer to the encryption or decryption filter
217*/
218BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec,
219 Cipher_Dir direction);
220
221/**
222* Check if an algorithm exists.
223* @param algo_spec the name of the algorithm to check for
224* @return true if the algorithm exists, false otherwise
225*/
226BOTAN_DLL bool have_algorithm(const std::string& algo_spec);
227
228/**
229* Check if a block cipher algorithm exists.
230* @deprecated Call algorithm_factory() directly
231*
232* @param algo_spec the name of the algorithm to check for
233* @return true if the algorithm exists, false otherwise
234*/
235inline bool have_block_cipher(const std::string& algo_spec)
236 {
238 return (af.prototype_block_cipher(algo_spec) != 0);
239 }
240
241/**
242* Check if a stream cipher algorithm exists.
243* @deprecated Call algorithm_factory() directly
244*
245* @param algo_spec the name of the algorithm to check for
246* @return true if the algorithm exists, false otherwise
247*/
248inline bool have_stream_cipher(const std::string& algo_spec)
249 {
251 return (af.prototype_stream_cipher(algo_spec) != 0);
252 }
253
254/**
255* Check if a hash algorithm exists.
256* @deprecated Call algorithm_factory() directly
257*
258* @param algo_spec the name of the algorithm to check for
259* @return true if the algorithm exists, false otherwise
260*/
261inline bool have_hash(const std::string& algo_spec)
262 {
264 return (af.prototype_hash_function(algo_spec) != 0);
265 }
266
267/**
268* Check if a MAC algorithm exists.
269* @deprecated Call algorithm_factory() directly
270*
271* @param algo_spec the name of the algorithm to check for
272* @return true if the algorithm exists, false otherwise
273*/
274inline bool have_mac(const std::string& algo_spec)
275 {
277 return (af.prototype_mac(algo_spec) != 0);
278 }
279
280/*
281* Query information about an algorithm
282*/
283
284/**
285* Find out the block size of a certain symmetric algorithm.
286* @deprecated Call algorithm_factory() directly
287*
288* @param algo_spec the name of the algorithm
289* @return block size of the specified algorithm
290*/
291BOTAN_DLL size_t block_size_of(const std::string& algo_spec);
292
293/**
294* Find out the output length of a certain symmetric algorithm.
295* @deprecated Call algorithm_factory() directly
296*
297* @param algo_spec the name of the algorithm
298* @return output length of the specified algorithm
299*/
300BOTAN_DLL size_t output_length_of(const std::string& algo_spec);
301
302/**
303* Find out the minimum key size of a certain symmetric algorithm.
304* @deprecated Call algorithm_factory() directly
305*
306* @param algo_spec the name of the algorithm
307* @return minimum key length of the specified algorithm
308*/
309BOTAN_DEPRECATED("Retrieve object you want and then call key_spec")
310BOTAN_DLL size_t min_keylength_of(const std::string& algo_spec);
311
312/**
313* Find out the maximum key size of a certain symmetric algorithm.
314* @deprecated Call algorithm_factory() directly
315*
316* @param algo_spec the name of the algorithm
317* @return maximum key length of the specified algorithm
318*/
319BOTAN_DEPRECATED("Retrieve object you want and then call key_spec")
320BOTAN_DLL size_t max_keylength_of(const std::string& algo_spec);
321
322/**
323* Find out the size any valid key is a multiple of for a certain algorithm.
324* @deprecated Call algorithm_factory() directly
325*
326* @param algo_spec the name of the algorithm
327* @return size any valid key is a multiple of
328*/
329BOTAN_DEPRECATED("Retrieve object you want and then call key_spec")
330BOTAN_DLL size_t keylength_multiple_of(const std::string& algo_spec);
331
332}
333
334#endif
StreamCipher * make_stream_cipher(const std::string &algo_spec, const std::string &provider="")
const HashFunction * prototype_hash_function(const std::string &algo_spec, const std::string &provider="")
HashFunction * make_hash_function(const std::string &algo_spec, const std::string &provider="")
MessageAuthenticationCode * make_mac(const std::string &algo_spec, const std::string &provider="")
const BlockCipher * prototype_block_cipher(const std::string &algo_spec, const std::string &provider="")
const MessageAuthenticationCode * prototype_mac(const std::string &algo_spec, const std::string &provider="")
const StreamCipher * prototype_stream_cipher(const std::string &algo_spec, const std::string &provider="")
BlockCipher * make_block_cipher(const std::string &algo_spec, const std::string &provider="")
Algorithm_Factory & algorithm_factory() const
Definition libstate.cpp:173
OctetString SymmetricKey
Definition symkey.h:147
MessageAuthenticationCode * get_mac(const std::string &algo_spec)
Definition lookup.h:126
bool have_stream_cipher(const std::string &algo_spec)
Definition lookup.h:248
const BlockCipher * retrieve_block_cipher(const std::string &algo_spec)
Definition lookup.h:29
BlockCipher * get_block_cipher(const std::string &algo_spec)
Definition lookup.h:87
const MessageAuthenticationCode * retrieve_mac(const std::string &algo_spec)
Definition lookup.h:68
bool have_mac(const std::string &algo_spec)
Definition lookup.h:274
bool have_hash(const std::string &algo_spec)
Definition lookup.h:261
KDF * get_kdf(const std::string &algo_spec)
Definition get_enc.cpp:174
EMSA * get_emsa(const std::string &algo_spec)
Definition get_enc.cpp:86
StreamCipher * get_stream_cipher(const std::string &algo_spec)
Definition lookup.h:100
const HashFunction * retrieve_hash(const std::string &algo_spec)
Definition lookup.h:55
size_t max_keylength_of(const std::string &name)
Definition lookup.cpp:86
size_t min_keylength_of(const std::string &name)
Definition lookup.cpp:67
HashFunction * get_hash(const std::string &algo_spec)
Definition lookup.h:113
Keyed_Filter * get_cipher(const std::string &algo_spec, Cipher_Dir direction)
Definition lookup.cpp:124
Library_State & global_state()
OctetString InitializationVector
Definition symkey.h:152
bool have_algorithm(const std::string &name)
Definition lookup.cpp:17
Cipher_Dir
Definition sym_algo.h:87
const StreamCipher * retrieve_stream_cipher(const std::string &algo_spec)
Definition lookup.h:42
PBKDF * get_s2k(const std::string &algo_spec)
Definition lookup.h:144
EME * get_eme(const std::string &algo_spec)
Definition get_enc.cpp:143
size_t output_length_of(const std::string &name)
Definition lookup.cpp:51
size_t keylength_multiple_of(const std::string &name)
Definition lookup.cpp:105
size_t block_size_of(const std::string &name)
Definition lookup.cpp:35
bool have_block_cipher(const std::string &algo_spec)
Definition lookup.h:235
PBKDF * get_pbkdf(const std::string &algo_spec)
Definition get_enc.cpp:73
Definition secmem.h:435