diff options
author | lloyd <[email protected]> | 2008-11-23 21:17:20 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-23 21:17:20 +0000 |
commit | c243688f6062cf4577610d8ef71ba0ec60a932e2 (patch) | |
tree | 1c9f21adcdffc476f520255623016466ec4d5b96 /src | |
parent | dfd6e089a95f2c7a7179b366afbbbebf3fedc576 (diff) |
Add an Algorithm_Factory& argument to Engine::get_cipher to avoid a
dependency on libstate.h
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/def_engine/def_eng.h | 4 | ||||
-rw-r--r-- | src/engine/def_engine/def_mode.cpp | 7 | ||||
-rw-r--r-- | src/engine/engine.h | 4 | ||||
-rw-r--r-- | src/libstate/lookup.cpp | 6 |
4 files changed, 13 insertions, 8 deletions
diff --git a/src/engine/def_engine/def_eng.h b/src/engine/def_engine/def_eng.h index 0c95c08c5..0cdf7ffb4 100644 --- a/src/engine/def_engine/def_eng.h +++ b/src/engine/def_engine/def_eng.h @@ -59,7 +59,9 @@ class BOTAN_DLL Default_Engine : public Engine virtual bool can_add_algorithms() { return true; } - Keyed_Filter* get_cipher(const std::string&, Cipher_Dir); + Keyed_Filter* get_cipher(const std::string&, Cipher_Dir, + Algorithm_Factory&); + private: BlockCipher* find_block_cipher(const SCAN_Name&, Algorithm_Factory&) const; diff --git a/src/engine/def_engine/def_mode.cpp b/src/engine/def_engine/def_mode.cpp index a2015e6d3..a2594c13f 100644 --- a/src/engine/def_engine/def_mode.cpp +++ b/src/engine/def_engine/def_mode.cpp @@ -6,7 +6,7 @@ #include <botan/def_eng.h> #include <botan/parsing.h> #include <botan/filters.h> -#include <botan/libstate.h> +#include <botan/algo_factory.h> #include <botan/mode_pad.h> #include <memory> @@ -72,7 +72,8 @@ BlockCipherModePaddingMethod* get_bc_pad(const std::string& algo_spec) * Get a cipher object * *************************************************/ Keyed_Filter* Default_Engine::get_cipher(const std::string& algo_spec, - Cipher_Dir direction) + Cipher_Dir direction, + Algorithm_Factory& af) { std::vector<std::string> algo_parts = split_on(algo_spec, '/'); if(algo_parts.empty()) @@ -80,8 +81,6 @@ Keyed_Filter* Default_Engine::get_cipher(const std::string& algo_spec, const std::string cipher_name = algo_parts[0]; - Algorithm_Factory& af = global_state().algorithm_factory(); - // check if it is a stream cipher first (easy case) const StreamCipher* stream_cipher = af.prototype_stream_cipher(cipher_name); if(stream_cipher) diff --git a/src/engine/engine.h b/src/engine/engine.h index f73ecb0a0..b0861d134 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -83,7 +83,9 @@ class BOTAN_DLL Engine mod_exp(const BigInt&, Power_Mod::Usage_Hints) const { return 0; } - virtual Keyed_Filter* get_cipher(const std::string&, Cipher_Dir) + virtual Keyed_Filter* get_cipher(const std::string&, + Cipher_Dir, + Algorithm_Factory&) { return 0; } #if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp index 24a8a8ecd..adf3d80ed 100644 --- a/src/libstate/lookup.cpp +++ b/src/libstate/lookup.cpp @@ -249,11 +249,13 @@ u32bit keylength_multiple_of(const std::string& name) Keyed_Filter* get_cipher(const std::string& algo_spec, Cipher_Dir direction) { - Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); + Algorithm_Factory& af = global_state().algorithm_factory(); + + Algorithm_Factory::Engine_Iterator i(af); while(Engine* engine = i.next()) { - Keyed_Filter* algo = engine->get_cipher(algo_spec, direction); + Keyed_Filter* algo = engine->get_cipher(algo_spec, direction, af); if(algo) return algo; } |