1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*************************************************
* 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.
*/
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 seeding of the
* global RNG at startup.
* @return true if the seeding at startup is enabled
*/
bool seed_rng() 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;
/**
* Get the full path of the configuration file to be used.
*/
std::string config_file() const;
/**
* 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",
* "seed_rng",
* "use_engines",
* "secure_memory",
* "thread_safe"
*
*/
InitializerOptions(const std::string& options);
private:
std::map<std::string, std::string> args;
};
/**
* This class represents the Library Initialization/Shutdown Object. It has to
* exceed the lifetime of any Botan object used in an application.
*/
class BOTAN_DLL LibraryInitializer
{
public:
static void initialize(const std::string& = "");
static void initialize(const InitializerOptions&);
static void initialize(const InitializerOptions&, class Modules&);
static void deinitialize();
/**
* 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); }
/**
* Construct a library initializer.
* @param args the initializer option object specifying the desired
* library configuration
*/
LibraryInitializer(const InitializerOptions& args) { initialize(args); }
~LibraryInitializer() { deinitialize(); }
};
}
#endif
|