diff options
-rw-r--r-- | src/algo_factory/algo_factory.h | 39 | ||||
-rw-r--r-- | src/libstate/libstate.cpp | 31 | ||||
-rw-r--r-- | src/libstate/libstate.h | 2 |
3 files changed, 37 insertions, 35 deletions
diff --git a/src/algo_factory/algo_factory.h b/src/algo_factory/algo_factory.h index fbaf26ebf..c71594ee3 100644 --- a/src/algo_factory/algo_factory.h +++ b/src/algo_factory/algo_factory.h @@ -21,6 +21,8 @@ class StreamCipher; class HashFunction; class MessageAuthenticationCode; +class Engine; + /** * Algorithm Factory */ @@ -29,20 +31,17 @@ class BOTAN_DLL Algorithm_Factory public: /** * Contructor + * @param engines the list of engines to use * @param mf a mutex factory */ - Algorithm_Factory(Mutex_Factory& mf); + Algorithm_Factory(const std::vector<Engine*>& engines, + Mutex_Factory& mf); /** * Destructor */ ~Algorithm_Factory(); - /** - * Add an engine implementation to this factory (how steampunk) - */ - void add_engine(class Engine*); - /* * Provider management */ @@ -54,37 +53,49 @@ class BOTAN_DLL Algorithm_Factory /* * Block cipher operations */ - const BlockCipher* prototype_block_cipher(const std::string& algo_spec, - const std::string& provider = ""); + const BlockCipher* + prototype_block_cipher(const std::string& algo_spec, + const std::string& provider = ""); + BlockCipher* make_block_cipher(const std::string& algo_spec, const std::string& provider = ""); + void add_block_cipher(BlockCipher* hash, const std::string& provider); /* * Stream cipher operations */ - const StreamCipher* prototype_stream_cipher(const std::string& algo_spec, - const std::string& provider = ""); + const StreamCipher* + prototype_stream_cipher(const std::string& algo_spec, + const std::string& provider = ""); + StreamCipher* make_stream_cipher(const std::string& algo_spec, const std::string& provider = ""); + void add_stream_cipher(StreamCipher* hash, const std::string& provider); /* * Hash function operations */ - const HashFunction* prototype_hash_function(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 = ""); + void add_hash_function(HashFunction* hash, const std::string& provider); /* * MAC operations */ - const MessageAuthenticationCode* prototype_mac(const std::string& algo_spec, - const std::string& provider = ""); + const MessageAuthenticationCode* + prototype_mac(const std::string& algo_spec, + const std::string& provider = ""); + MessageAuthenticationCode* make_mac(const std::string& algo_spec, const std::string& provider = ""); + void add_mac(MessageAuthenticationCode* mac, const std::string& provider); diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 160f07678..b75fbae88 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -275,38 +275,31 @@ void Library_State::initialize(bool thread_safe) load_default_config(); - m_algorithm_factory = new Algorithm_Factory(*mutex_factory); + std::vector<Engine*> engines; - m_algorithm_factory->add_engine(new Default_Engine); - -#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER) - m_algorithm_factory->add_engine(new IA32_Assembler_Engine); +#if defined(BOTAN_HAS_ENGINE_GNU_MP) + engines.push_back(new GMP_Engine); #endif -#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER) - m_algorithm_factory->add_engine(new AMD64_Assembler_Engine); +#if defined(BOTAN_HAS_ENGINE_OPENSSL) + engines.push_back(new OpenSSL_Engine); #endif #if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER) - m_algorithm_factory->add_engine(new SSE2_Assembler_Engine); + engines.push_back(new SSE2_Assembler_Engine); #endif -#if defined(BOTAN_HAS_ENGINE_OPENSSL) - m_algorithm_factory->add_engine(new OpenSSL_Engine); +#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER) + engines.push_back(new AMD64_Assembler_Engine); #endif -#if defined(BOTAN_HAS_ENGINE_GNU_MP) - m_algorithm_factory->add_engine(new GMP_Engine); +#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER) + engines.push_back(new IA32_Assembler_Engine); #endif - } + engines.push_back(new Default_Engine); -/** -* Add a new engine -*/ -void Library_State::add_engine(Engine* engine) - { - m_algorithm_factory->add_engine(engine); + m_algorithm_factory = new Algorithm_Factory(engines, *mutex_factory); } /************************************************* diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h index 53a70a636..e45d1a7f3 100644 --- a/src/libstate/libstate.h +++ b/src/libstate/libstate.h @@ -29,8 +29,6 @@ class BOTAN_DLL Library_State Algorithm_Factory& algorithm_factory(); - void add_engine(class Engine*); - Allocator* get_allocator(const std::string& = "") const; void add_allocator(Allocator*); void set_default_allocator(const std::string&); |