diff options
author | lloyd <[email protected]> | 2008-11-11 02:20:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 02:20:57 +0000 |
commit | 507b1b0996b3640c038d236f60ea86ee6315aeb4 (patch) | |
tree | 18073171e522ca1f5a7046b4b5959b606adfa763 /src/libstate | |
parent | daffc235589fb8ec2f4090ba5fb8511462b4a843 (diff) |
Remove a global_state() dependency on Engine without breaking Monotone
via two-stage initialization.
Diffstat (limited to 'src/libstate')
-rw-r--r-- | src/libstate/engine/engine.cpp | 28 | ||||
-rw-r--r-- | src/libstate/engine/engine.h | 2 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/libstate/engine/engine.cpp b/src/libstate/engine/engine.cpp index cd9db5141..c6a82f5fc 100644 --- a/src/libstate/engine/engine.cpp +++ b/src/libstate/engine/engine.cpp @@ -4,7 +4,6 @@ */ #include <botan/engine.h> -#include <botan/libstate.h> #include <botan/stl_util.h> #include <botan/mode_pad.h> @@ -172,22 +171,21 @@ void Engine::add_algorithm(MessageAuthenticationCode* algo) const cache_of_mac->add(algo); } -/************************************************* -* Create an Engine * -*************************************************/ -Engine::Engine() +void Engine::initialize(Mutex_Factory& mf) { - cache_of_bc = new Algorithm_Cache_Impl<BlockCipher>( - global_state().get_mutex()); - - cache_of_sc = new Algorithm_Cache_Impl<StreamCipher>( - global_state().get_mutex()); - - cache_of_hf = new Algorithm_Cache_Impl<HashFunction>( - global_state().get_mutex()); + cache_of_bc = new Algorithm_Cache_Impl<BlockCipher>(mf.make()); + cache_of_sc = new Algorithm_Cache_Impl<StreamCipher>(mf.make()); + cache_of_hf = new Algorithm_Cache_Impl<HashFunction>(mf.make()); + cache_of_mac = + new Algorithm_Cache_Impl<MessageAuthenticationCode>(mf.make()); + } - cache_of_mac = new Algorithm_Cache_Impl<MessageAuthenticationCode>( - global_state().get_mutex()); +Engine::Engine() + { + cache_of_bc = 0; + cache_of_sc = 0; + cache_of_hf = 0; + cache_of_mac = 0; } /************************************************* diff --git a/src/libstate/engine/engine.h b/src/libstate/engine/engine.h index 42fc1e0d7..3df973b0e 100644 --- a/src/libstate/engine/engine.h +++ b/src/libstate/engine/engine.h @@ -146,6 +146,8 @@ class BOTAN_DLL Engine virtual bool can_add_algorithms() { return false; } virtual std::string provider_name() const = 0; + void initialize(Mutex_Factory& mf); + Engine(); virtual ~Engine(); private: |