diff options
author | lloyd <[email protected]> | 2008-11-10 22:33:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-10 22:33:35 +0000 |
commit | a4804e1e606424b8b9421eadb86ffde0a995382c (patch) | |
tree | 9d2e007e818b3a796f288ab6158a4bc762d0ad52 /src/libstate/init.h | |
parent | 675aa7bcc476d8445b6eb2bc3c6b0a2f3ce12958 (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.h')
-rw-r--r-- | src/libstate/init.h | 111 |
1 files changed, 17 insertions, 94 deletions
diff --git a/src/libstate/init.h b/src/libstate/init.h index e3eec3ce9..794fbd39e 100644 --- a/src/libstate/init.h +++ b/src/libstate/init.h @@ -1,113 +1,36 @@ -/************************************************* -* Library Initialization Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_INIT_H__ -#define BOTAN_INIT_H__ - -#include <botan/build.h> -#include <string> -#include <map> - -namespace Botan { - /** -* This class represents options for initializing the library. +* Library Initialization Header File +* (C) 1999-2008 Jack Lloyd */ -class BOTAN_DLL InitializerOptions - { - public: - /** - * Check whether this set of options has thread safety enabled. - * @return true if thread safety is enabled - */ - bool thread_safe() const; - - /** - * Check whether this set of options has the usage of alternative engines - * enabled. - * @return true if the usage of alternative engines - * is enabled - */ - bool use_engines() const; - - /** - * Check whether this set of options has enabled the memory - * locking feature. This is implemented for Unix and Win32, but - * it only reliably works for Unix. There, all SecureVectors and - * SecureBuffers are kept from being ever swapped to disk. On - * Win32 plattforms, the corresponding pages are locked into the - * working set of the process, reducing the chance of being - * swapped to disk, but not strictly preventing it. - * @return true if the memory locking feature is enabled - */ - bool secure_memory() const; - /** - * Check whether this set of options has the self-test-at-startup - * enabled. Same as self_test(). - * @param return true if the self-test is enabled - */ - bool fips_mode() const; - - /** - * Check whether this set of options has the self-test-at-startup enabled. - * Same as fips_mode(). - * @param return true if the self-test is enabled - */ - bool self_test() const; +#ifndef BOTAN_LIBRARY_INITIALIZER_H__ +#define BOTAN_LIBRARY_INITIALIZER_H__ - /** - * Get the full path of the configuration file to be used. - */ - std::string config_file() const; +#include <botan/libstate.h> - /** - * Create an initializer options object. The option are set based on the - * input string. The options can be set by building a white space separated - * list of elements out of the - * following set of strings: - * "config=<file name>", - * "selftest", - * "fips140", - * "use_engines", - * "secure_memory", - * "thread_safe" - * - */ - InitializerOptions(const std::string& options); - private: - std::map<std::string, std::string> args; - }; +namespace Botan { /** -* This class represents the Library Initialization/Shutdown Object. It has to -* exceed the lifetime of any Botan object used in an application. +* This class represents the Library Initialization/Shutdown Object. It +* has to exceed the lifetime of any Botan object used in an +* application. You can call initialize/deinitialize or use +* LibraryInitializer in the RAII style. */ class BOTAN_DLL LibraryInitializer { public: - static void initialize(const std::string& = ""); - static void initialize(const InitializerOptions&); - static void deinitialize(); + static void initialize(bool thread_safe); - /** - * Construct a library initializer from a string. Does exactly the same - * as if an InitializerOptions object created with that string was used as - * the argument. - * @param args the string determining the desired library configuration - */ - LibraryInitializer(const std::string& args = "") { initialize(args); } + static void deinitialize(); /** - * Construct a library initializer. - * @param args the initializer option object specifying the desired - * library configuration + * Initialize the library + * @param thread_safe if the library should use a thread-safe mutex */ - LibraryInitializer(const InitializerOptions& args) { initialize(args); } + LibraryInitializer(bool thread_safe = false) + { LibraryInitializer::initialize(thread_safe); } - ~LibraryInitializer() { deinitialize(); } + ~LibraryInitializer() { LibraryInitializer::deinitialize(); } }; } |