8 #include <botan/libstate.h>
9 #include <botan/charset.h>
10 #include <botan/engine.h>
11 #include <botan/cpuid.h>
12 #include <botan/internal/core_engine.h>
13 #include <botan/internal/stl_util.h>
16 #if defined(BOTAN_HAS_SELFTESTS)
17 #include <botan/selftest.h>
20 #if defined(BOTAN_HAS_ENGINE_ASSEMBLER)
21 #include <botan/internal/asm_engine.h>
24 #if defined(BOTAN_HAS_ENGINE_AES_ISA)
25 #include <botan/internal/aes_isa_engine.h>
28 #if defined(BOTAN_HAS_ENGINE_SIMD)
29 #include <botan/internal/simd_engine.h>
32 #if defined(BOTAN_HAS_ENGINE_GNU_MP)
33 #include <botan/internal/gnump_engine.h>
36 #if defined(BOTAN_HAS_ENGINE_OPENSSL)
37 #include <botan/internal/openssl_engine.h>
46 const std::string& key)
48 std::lock_guard<std::mutex> lock(config_lock);
50 return search_map<std::string, std::string>(config,
51 section +
"/" + key,
"");
58 const std::string& key)
60 std::lock_guard<std::mutex> lock(config_lock);
62 return config.count(section +
"/" + key) != 0;
69 const std::string& value,
bool overwrite)
71 std::lock_guard<std::mutex> lock(config_lock);
73 std::string full_key = section +
"/" + key;
75 auto i = config.find(full_key);
77 if(overwrite || i == config.end() || i->second ==
"")
78 config[full_key] = value;
86 set(
"alias", key, value);
94 std::string result = key;
95 while(
is_set(
"alias", result))
96 result =
get(
"alias", result);
105 if(!m_algorithm_factory)
106 throw Invalid_State(
"Uninitialized in Library_State::algorithm_factory");
107 return *m_algorithm_factory;
115 std::lock_guard<std::mutex> lock(global_rng_lock);
121 return *global_rng_ptr;
131 if(m_algorithm_factory)
132 throw Invalid_State(
"Library_State has already been initialized");
134 load_default_config();
138 #if defined(BOTAN_HAS_ENGINE_GNU_MP)
142 #if defined(BOTAN_HAS_ENGINE_OPENSSL)
146 #if defined(BOTAN_HAS_ENGINE_AES_ISA)
150 #if defined(BOTAN_HAS_ENGINE_SIMD)
154 #if defined(BOTAN_HAS_ENGINE_ASSEMBLER)
160 #if defined(BOTAN_HAS_SELFTESTS)
170 m_algorithm_factory =
nullptr;
172 global_rng_ptr =
nullptr;
180 delete m_algorithm_factory;
181 m_algorithm_factory =
nullptr;
183 delete global_rng_ptr;
184 global_rng_ptr =
nullptr;