#include <algo_factory.h>
Classes | |
| class | Engine_Iterator |
Public Member Functions | |
| void | add_block_cipher (BlockCipher *algo, const std::string &provider) |
| void | add_engine (class Engine *engine) |
| void | add_hash_function (HashFunction *algo, const std::string &provider) |
| void | add_mac (MessageAuthenticationCode *algo, const std::string &provider) |
| void | add_stream_cipher (StreamCipher *algo, const std::string &provider) |
| Algorithm_Factory (Mutex_Factory &mf) | |
| BlockCipher * | make_block_cipher (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="") |
| StreamCipher * | make_stream_cipher (const std::string &algo_spec, const std::string &provider="") |
| const BlockCipher * | prototype_block_cipher (const std::string &algo_spec, const std::string &provider="") |
| const HashFunction * | prototype_hash_function (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="") |
| std::vector< std::string > | providers_of (const std::string &algo_spec) |
| void | set_preferred_provider (const std::string &algo_spec, const std::string &provider) |
| ~Algorithm_Factory () | |
Friends | |
| class | Engine_Iterator |
Definition at line 33 of file algo_factory.h.
| Botan::Algorithm_Factory::Algorithm_Factory | ( | Mutex_Factory & | mf | ) |
Constructor
| mf | a mutex factory |
Definition at line 90 of file algo_factory.cpp.
References Botan::Mutex_Factory::make().
00091 { 00092 block_cipher_cache = new Algorithm_Cache<BlockCipher>(mf.make()); 00093 stream_cipher_cache = new Algorithm_Cache<StreamCipher>(mf.make()); 00094 hash_cache = new Algorithm_Cache<HashFunction>(mf.make()); 00095 mac_cache = new Algorithm_Cache<MessageAuthenticationCode>(mf.make()); 00096 }
| Botan::Algorithm_Factory::~Algorithm_Factory | ( | ) |
Destructor
Definition at line 101 of file algo_factory.cpp.
00102 { 00103 std::for_each(engines.begin(), engines.end(), del_fun<Engine>()); 00104 00105 delete block_cipher_cache; 00106 delete stream_cipher_cache; 00107 delete hash_cache; 00108 delete mac_cache; 00109 }
| void Botan::Algorithm_Factory::add_block_cipher | ( | BlockCipher * | algo, | |
| const std::string & | provider | |||
| ) |
| algo | the algorithm to add | |
| provider | the provider of this algorithm |
Definition at line 262 of file algo_factory.cpp.
References Botan::Algorithm_Cache< T >::add(), and Botan::SymmetricAlgorithm::name().
| void Botan::Algorithm_Factory::add_engine | ( | class Engine * | engine | ) |
| engine | to add (Algorithm_Factory takes ownership) |
Definition at line 111 of file algo_factory.cpp.
Referenced by Botan::Library_State::initialize().
| void Botan::Algorithm_Factory::add_hash_function | ( | HashFunction * | algo, | |
| const std::string & | provider | |||
| ) |
| algo | the algorithm to add | |
| provider | the provider of this algorithm |
Definition at line 280 of file algo_factory.cpp.
References Botan::Algorithm_Cache< T >::add(), and Botan::HashFunction::name().
| void Botan::Algorithm_Factory::add_mac | ( | MessageAuthenticationCode * | algo, | |
| const std::string & | provider | |||
| ) |
| algo | the algorithm to add | |
| provider | the provider of this algorithm |
Definition at line 289 of file algo_factory.cpp.
References Botan::Algorithm_Cache< T >::add(), and Botan::MessageAuthenticationCode::name().
| void Botan::Algorithm_Factory::add_stream_cipher | ( | StreamCipher * | algo, | |
| const std::string & | provider | |||
| ) |
| algo | the algorithm to add | |
| provider | the provider of this algorithm |
Definition at line 271 of file algo_factory.cpp.
References Botan::Algorithm_Cache< T >::add(), and Botan::SymmetricAlgorithm::name().
| BlockCipher * Botan::Algorithm_Factory::make_block_cipher | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 215 of file algo_factory.cpp.
References Botan::BlockCipher::clone(), and prototype_block_cipher().
Referenced by Botan::Default_Engine::find_mac(), and Botan::get_block_cipher().
00217 { 00218 if(const BlockCipher* proto = prototype_block_cipher(algo_spec, provider)) 00219 return proto->clone(); 00220 throw Algorithm_Not_Found(algo_spec); 00221 }
| HashFunction * Botan::Algorithm_Factory::make_hash_function | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 239 of file algo_factory.cpp.
References Botan::HashFunction::clone(), and prototype_hash_function().
Referenced by Botan::Default_Engine::find_mac(), Botan::generate_dsa_primes(), Botan::get_eme(), Botan::get_emsa(), Botan::get_hash(), Botan::get_kdf(), Botan::get_s2k(), and Botan::Hash_Filter::Hash_Filter().
00241 { 00242 if(const HashFunction* proto = prototype_hash_function(algo_spec, provider)) 00243 return proto->clone(); 00244 throw Algorithm_Not_Found(algo_spec); 00245 }
| MessageAuthenticationCode * Botan::Algorithm_Factory::make_mac | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 251 of file algo_factory.cpp.
References Botan::MessageAuthenticationCode::clone(), and prototype_mac().
Referenced by Botan::get_mac(), and Botan::MAC_Filter::MAC_Filter().
00253 { 00254 if(const MessageAuthenticationCode* proto = prototype_mac(algo_spec, provider)) 00255 return proto->clone(); 00256 throw Algorithm_Not_Found(algo_spec); 00257 }
| StreamCipher * Botan::Algorithm_Factory::make_stream_cipher | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 227 of file algo_factory.cpp.
References Botan::StreamCipher::clone(), and prototype_stream_cipher().
Referenced by Botan::get_stream_cipher(), and Botan::StreamCipher_Filter::StreamCipher_Filter().
00229 { 00230 if(const StreamCipher* proto = prototype_stream_cipher(algo_spec, provider)) 00231 return proto->clone(); 00232 throw Algorithm_Not_Found(algo_spec); 00233 }
| const BlockCipher * Botan::Algorithm_Factory::prototype_block_cipher | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 170 of file algo_factory.cpp.
Referenced by Botan::algorithm_benchmark(), Botan::algorithm_kat(), Botan::block_size_of(), Botan::Default_Engine::find_block_cipher(), Botan::Default_Engine::get_cipher(), Botan::get_pbe(), Botan::have_algorithm(), Botan::have_block_cipher(), Botan::keylength_multiple_of(), make_block_cipher(), Botan::max_keylength_of(), Botan::min_keylength_of(), providers_of(), Botan::retrieve_block_cipher(), set_preferred_provider(), and Botan::valid_keylength_for().
00172 { 00173 return factory_prototype<BlockCipher>(algo_spec, provider, engines, 00174 *this, block_cipher_cache); 00175 }
| const HashFunction * Botan::Algorithm_Factory::prototype_hash_function | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 192 of file algo_factory.cpp.
Referenced by Botan::algorithm_benchmark(), Botan::algorithm_kat(), Botan::block_size_of(), Botan::Default_Engine::find_block_cipher(), Botan::Default_Engine::find_hash(), Botan::get_pbe(), Botan::have_algorithm(), Botan::have_hash(), make_hash_function(), Botan::output_length_of(), providers_of(), Botan::retrieve_hash(), and set_preferred_provider().
00194 { 00195 return factory_prototype<HashFunction>(algo_spec, provider, engines, 00196 *this, hash_cache); 00197 }
| const MessageAuthenticationCode * Botan::Algorithm_Factory::prototype_mac | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 203 of file algo_factory.cpp.
Referenced by Botan::algorithm_benchmark(), Botan::algorithm_kat(), Botan::have_algorithm(), Botan::have_mac(), Botan::keylength_multiple_of(), make_mac(), Botan::max_keylength_of(), Botan::min_keylength_of(), Botan::output_length_of(), providers_of(), Botan::retrieve_mac(), set_preferred_provider(), and Botan::valid_keylength_for().
00205 { 00206 return factory_prototype<MessageAuthenticationCode>(algo_spec, provider, 00207 engines, 00208 *this, mac_cache); 00209 }
| const StreamCipher * Botan::Algorithm_Factory::prototype_stream_cipher | ( | const std::string & | algo_spec, | |
| const std::string & | provider = "" | |||
| ) |
| algo_spec | the algorithm we want | |
| provider | the provider we would like to use |
Definition at line 181 of file algo_factory.cpp.
Referenced by Botan::algorithm_benchmark(), Botan::algorithm_kat(), Botan::Default_Engine::find_block_cipher(), Botan::Default_Engine::get_cipher(), Botan::have_algorithm(), Botan::have_stream_cipher(), Botan::keylength_multiple_of(), make_stream_cipher(), Botan::max_keylength_of(), Botan::min_keylength_of(), providers_of(), Botan::retrieve_stream_cipher(), set_preferred_provider(), and Botan::valid_keylength_for().
00183 { 00184 return factory_prototype<StreamCipher>(algo_spec, provider, engines, 00185 *this, stream_cipher_cache); 00186 }
| std::vector< std::string > Botan::Algorithm_Factory::providers_of | ( | const std::string & | algo_spec | ) |
| algo_spec | the algorithm we are querying |
Definition at line 147 of file algo_factory.cpp.
References prototype_block_cipher(), prototype_hash_function(), prototype_mac(), prototype_stream_cipher(), and Botan::Algorithm_Cache< T >::providers_of().
Referenced by Botan::algorithm_benchmark(), and Botan::algorithm_kat().
00148 { 00149 /* The checks with if(prototype_X(algo_spec)) have the effect of 00150 forcing a full search, since otherwise there might not be any 00151 providers at all in the cache. 00152 */ 00153 00154 if(prototype_block_cipher(algo_spec)) 00155 return block_cipher_cache->providers_of(algo_spec); 00156 else if(prototype_stream_cipher(algo_spec)) 00157 return stream_cipher_cache->providers_of(algo_spec); 00158 else if(prototype_hash_function(algo_spec)) 00159 return hash_cache->providers_of(algo_spec); 00160 else if(prototype_mac(algo_spec)) 00161 return mac_cache->providers_of(algo_spec); 00162 else 00163 return std::vector<std::string>(); 00164 }
| void Botan::Algorithm_Factory::set_preferred_provider | ( | const std::string & | algo_spec, | |
| const std::string & | provider | |||
| ) |
| algo_spec | the algorithm we are setting a provider for | |
| provider | the provider we would like to use |
Definition at line 119 of file algo_factory.cpp.
References prototype_block_cipher(), prototype_hash_function(), prototype_mac(), prototype_stream_cipher(), and Botan::Algorithm_Cache< T >::set_preferred_provider().
00121 { 00122 if(prototype_block_cipher(algo_spec)) 00123 block_cipher_cache->set_preferred_provider(algo_spec, provider); 00124 else if(prototype_stream_cipher(algo_spec)) 00125 stream_cipher_cache->set_preferred_provider(algo_spec, provider); 00126 else if(prototype_hash_function(algo_spec)) 00127 hash_cache->set_preferred_provider(algo_spec, provider); 00128 else if(prototype_mac(algo_spec)) 00129 mac_cache->set_preferred_provider(algo_spec, provider); 00130 }
friend class Engine_Iterator [friend] |
Definition at line 178 of file algo_factory.h.
1.5.8