aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/libstate/libstate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libstate/libstate.h')
-rw-r--r--src/lib/libstate/libstate.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/lib/libstate/libstate.h b/src/lib/libstate/libstate.h
new file mode 100644
index 000000000..d8734966a
--- /dev/null
+++ b/src/lib/libstate/libstate.h
@@ -0,0 +1,60 @@
+/*
+* Library Internal/Global State
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_LIB_STATE_H__
+#define BOTAN_LIB_STATE_H__
+
+#include <botan/global_state.h>
+#include <botan/algo_factory.h>
+#include <botan/rng.h>
+#include <mutex>
+#include <string>
+#include <vector>
+#include <map>
+#include <memory>
+
+namespace Botan {
+
+/**
+* Global Library State
+*/
+class BOTAN_DLL Library_State
+ {
+ public:
+ Library_State() {}
+
+ Library_State(const Library_State&) = delete;
+ Library_State& operator=(const Library_State&) = delete;
+
+ void initialize();
+
+ /**
+ * @return global Algorithm_Factory
+ */
+ Algorithm_Factory& algorithm_factory() const;
+
+ /**
+ * @return global RandomNumberGenerator
+ */
+ RandomNumberGenerator& global_rng();
+
+ void poll_available_sources(class Entropy_Accumulator& accum);
+
+ private:
+ static std::vector<std::unique_ptr<EntropySource>> entropy_sources();
+
+ std::unique_ptr<Serialized_RNG> m_global_prng;
+
+ std::mutex m_entropy_src_mutex;
+ std::vector<std::unique_ptr<EntropySource>> m_sources;
+
+ std::unique_ptr<Algorithm_Factory> m_algorithm_factory;
+ };
+
+}
+
+#endif