diff options
author | lloyd <[email protected]> | 2008-11-10 20:51:46 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-10 20:51:46 +0000 |
commit | 2fe47f9071f37591a2016c16bb9b04f8e191e1c8 (patch) | |
tree | b9fb9041b18fd41b533ec2a3d63fc32d3eb2088d | |
parent | b1905058bdc3e96ca4311ac8cfa82aa736f73eb4 (diff) |
Move add_algorithm for hashes also to Algorithm_Factory
-rw-r--r-- | src/libstate/algo_factory.cpp | 14 | ||||
-rw-r--r-- | src/libstate/algo_factory.h | 8 | ||||
-rw-r--r-- | src/libstate/lookup.cpp | 27 |
3 files changed, 27 insertions, 22 deletions
diff --git a/src/libstate/algo_factory.cpp b/src/libstate/algo_factory.cpp index cbb3c8faa..282f6795e 100644 --- a/src/libstate/algo_factory.cpp +++ b/src/libstate/algo_factory.cpp @@ -71,4 +71,18 @@ HashFunction* Algorithm_Factory::make_hash_function(const SCAN_Name& request) throw Algorithm_Not_Found(request.as_string()); } +void Algorithm_Factory::add_hash_function(HashFunction* hash) + { + for(u32bit i = 0; i != engines.size(); ++i) + { + if(engines[i]->can_add_algorithms()) + { + engines[i]->add_algorithm(hash); + return; + } + } + + throw Exception("Algorithm_Factory::add_hash_function: No engine found"); + } + } diff --git a/src/libstate/algo_factory.h b/src/libstate/algo_factory.h index 57b94fbb3..9591d1dd0 100644 --- a/src/libstate/algo_factory.h +++ b/src/libstate/algo_factory.h @@ -22,9 +22,6 @@ class BOTAN_DLL Algorithm_Factory public: ~Algorithm_Factory(); - const HashFunction* prototype_hash_function(const SCAN_Name& request); - HashFunction* make_hash_function(const SCAN_Name& request); - void add_engine(class Engine*); class BOTAN_DLL Engine_Iterator @@ -38,6 +35,11 @@ class BOTAN_DLL Algorithm_Factory }; friend class Engine_Iterator; + // Hash function operations + const HashFunction* prototype_hash_function(const SCAN_Name& request); + HashFunction* make_hash_function(const SCAN_Name& request); + void add_hash_function(HashFunction* hash); + private: class Engine* get_engine_n(u32bit) const; diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp index 52e986ff2..f53b1a099 100644 --- a/src/libstate/lookup.cpp +++ b/src/libstate/lookup.cpp @@ -27,6 +27,14 @@ HashFunction* get_hash(const std::string& algo_spec) } /************************************************* +* Add a new hash function * +*************************************************/ +void add_algorithm(Library_State& libstate, HashFunction* algo) + { + libstate.algo_factory().add_hash_function(algo); + } + +/************************************************* * Query if Botan has the named hash function * *************************************************/ bool have_hash(const std::string& algo_spec) @@ -312,25 +320,6 @@ void add_algorithm(Library_State& libstate, StreamCipher* algo) } /************************************************* -* Add a new hash function * -*************************************************/ -void add_algorithm(Library_State& libstate, HashFunction* algo) - { - Algorithm_Factory::Engine_Iterator i(libstate.algo_factory()); - - while(Engine* engine = i.next()) - { - if(engine->can_add_algorithms()) - { - engine->add_algorithm(algo); - return; - } - } - - throw Invalid_State("add_algorithm: Couldn't find the Default_Engine"); - } - -/************************************************* * Add a new authentication code * *************************************************/ void add_algorithm(Library_State& libstate, |