diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/def_engine/eng_def.h | 2 | ||||
-rw-r--r-- | src/engine/engine.cpp | 26 | ||||
-rw-r--r-- | src/engine/engine.h | 2 |
3 files changed, 14 insertions, 16 deletions
diff --git a/src/engine/def_engine/eng_def.h b/src/engine/def_engine/eng_def.h index 36ef14a69..3d3fba809 100644 --- a/src/engine/def_engine/eng_def.h +++ b/src/engine/def_engine/eng_def.h @@ -55,6 +55,8 @@ class BOTAN_DLL Default_Engine : public Engine Modular_Exponentiator* mod_exp(const BigInt&, Power_Mod::Usage_Hints) const; + virtual bool can_add_algorithms() { return true; } + Keyed_Filter* get_cipher(const std::string&, Cipher_Dir); private: BlockCipher* find_block_cipher(const std::string&) const; diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index ce32fa3b4..75b49b6a6 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -7,7 +7,6 @@ #include <botan/libstate.h> #include <botan/lookup.h> #include <botan/look_add.h> -#include <botan/eng_def.h> namespace Botan { @@ -287,10 +286,9 @@ void add_algorithm(Library_State& libstate, BlockCipher* algo) { Library_State::Engine_Iterator i(libstate); - while(Engine* engine_base = i.next()) + while(Engine* engine = i.next()) { - Default_Engine* engine = dynamic_cast<Default_Engine*>(engine_base); - if(engine) + if(engine->can_add_algorithms()) { engine->add_algorithm(algo); return; @@ -307,10 +305,9 @@ void add_algorithm(Library_State& libstate, StreamCipher* algo) { Library_State::Engine_Iterator i(libstate); - while(Engine* engine_base = i.next()) + while(Engine* engine = i.next()) { - Default_Engine* engine = dynamic_cast<Default_Engine*>(engine_base); - if(engine) + if(engine->can_add_algorithms()) { engine->add_algorithm(algo); return; @@ -327,10 +324,9 @@ void add_algorithm(Library_State& libstate, HashFunction* algo) { Library_State::Engine_Iterator i(libstate); - while(Engine* engine_base = i.next()) + while(Engine* engine = i.next()) { - Default_Engine* engine = dynamic_cast<Default_Engine*>(engine_base); - if(engine) + if(engine->can_add_algorithms()) { engine->add_algorithm(algo); return; @@ -348,10 +344,9 @@ void add_algorithm(Library_State& libstate, { Library_State::Engine_Iterator i(libstate); - while(Engine* engine_base = i.next()) + while(Engine* engine = i.next()) { - Default_Engine* engine = dynamic_cast<Default_Engine*>(engine_base); - if(engine) + if(engine->can_add_algorithms()) { engine->add_algorithm(algo); return; @@ -369,10 +364,9 @@ void add_algorithm(Library_State& libstate, { Library_State::Engine_Iterator i(libstate); - while(Engine* engine_base = i.next()) + while(Engine* engine = i.next()) { - Default_Engine* engine = dynamic_cast<Default_Engine*>(engine_base); - if(engine) + if(engine->can_add_algorithms()) { engine->add_algorithm(algo); return; diff --git a/src/engine/engine.h b/src/engine/engine.h index d7fae2348..f21c67a79 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -122,6 +122,8 @@ class BOTAN_DLL Engine const class BlockCipherModePaddingMethod* bc_pad(const std::string&) const; + virtual bool can_add_algorithms() { return false; } + void add_algorithm(BlockCipher*) const; void add_algorithm(StreamCipher*) const; void add_algorithm(HashFunction*) const; |