aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate/init.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-10 22:33:35 +0000
committerlloyd <[email protected]>2008-11-10 22:33:35 +0000
commita4804e1e606424b8b9421eadb86ffde0a995382c (patch)
tree9d2e007e818b3a796f288ab6158a4bc762d0ad52 /src/libstate/init.cpp
parent675aa7bcc476d8445b6eb2bc3c6b0a2f3ce12958 (diff)
Drop all options except thread safety. Also remove InitializerOptions, etc
and reduce all the arguments to just a bool specifying threads. selftests: off (if desired, run passes_self_test in selftest.h) fips140: Just ran the self tests, totally bogus option. use_engine: On by default (that is, if OpenSSL or asm code is compiled in, it's used by default). One can get better control over this using the provider feature of SCAN_Name (though this doesn't handle cases like nested algorithms yet). secure_memory: On by default.
Diffstat (limited to 'src/libstate/init.cpp')
-rw-r--r--src/libstate/init.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp
new file mode 100644
index 000000000..0256d70dc
--- /dev/null
+++ b/src/libstate/init.cpp
@@ -0,0 +1,43 @@
+/**
+* Default Initialization Function Source File
+* (C) 1999-2007 Jack Lloyd
+*/
+
+#include <botan/init.h>
+#include <botan/libstate.h>
+
+namespace Botan {
+
+/*************************************************
+* Library Initialization *
+*************************************************/
+void LibraryInitializer::initialize(bool thread_safe)
+ {
+ try
+ {
+ /*
+ This two stage initialization process is because Library_State's
+ constructor will implicitly refer to global state through the
+ allocators and so for, so global_state() has to be a valid
+ reference before initialize() can be called. Yeah, gross.
+ */
+ set_global_state(new Library_State);
+
+ global_state().initialize(thread_safe);
+ }
+ catch(...)
+ {
+ deinitialize();
+ throw;
+ }
+ }
+
+/*************************************************
+* Library Shutdown *
+*************************************************/
+void LibraryInitializer::deinitialize()
+ {
+ set_global_state(0);
+ }
+
+}