diff options
Diffstat (limited to 'src')
-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, |