aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/algo_factory/algo_factory.cpp1
-rw-r--r--src/algo_factory/algo_factory.h3
-rw-r--r--src/libstate/engine/engine.cpp28
-rw-r--r--src/libstate/engine/engine.h2
4 files changed, 19 insertions, 15 deletions
diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp
index 2f7921ce0..b5d088881 100644
--- a/src/algo_factory/algo_factory.cpp
+++ b/src/algo_factory/algo_factory.cpp
@@ -31,6 +31,7 @@ Algorithm_Factory::~Algorithm_Factory()
*/
void Algorithm_Factory::add_engine(Engine* engine)
{
+ engine->initialize(mutex_factory);
engines.push_back(engine);
}
diff --git a/src/algo_factory/algo_factory.h b/src/algo_factory/algo_factory.h
index fb41b4882..f29683b79 100644
--- a/src/algo_factory/algo_factory.h
+++ b/src/algo_factory/algo_factory.h
@@ -24,6 +24,7 @@ class MessageAuthenticationCode;
class BOTAN_DLL Algorithm_Factory
{
public:
+ Algorithm_Factory(Mutex_Factory& mf) : mutex_factory(mf) {}
~Algorithm_Factory();
void add_engine(class Engine*);
@@ -62,6 +63,8 @@ class BOTAN_DLL Algorithm_Factory
void add_mac(MessageAuthenticationCode* mac);
private:
+ Mutex_Factory& mutex_factory;
+
class Engine* get_engine_n(u32bit) const;
std::vector<class Engine*> engines;
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: