2
Copyright (C) 1999-2007 The Botan Project. All rights reserved.
4
Redistribution and use in source and binary forms, for any use, with or without
5
modification, is permitted provided that the following conditions are met:
7
1. Redistributions of source code must retain the above copyright notice, this
8
list of conditions, and the following disclaimer.
10
2. Redistributions in binary form must reproduce the above copyright notice,
11
this list of conditions, and the following disclaimer in the documentation
12
and/or other materials provided with the distribution.
14
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED
15
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
18
IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT,
19
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
namespace QCA { // WRAPNS_LINE
28
/*************************************************
29
* Library Internal/Global State Header File *
30
* (C) 1999-2007 The Botan Project *
31
*************************************************/
33
#ifndef BOTAN_LIB_STATE_H__
34
#define BOTAN_LIB_STATE_H__
36
#ifdef BOTAN_TOOLS_ONLY
38
#include <botan/allocate.h>
39
namespace QCA { // WRAPNS_LINE
42
#include <botan/base.h>
43
namespace QCA { // WRAPNS_LINE
45
#include <botan/enums.h>
46
namespace QCA { // WRAPNS_LINE
49
namespace QCA { // WRAPNS_LINE
53
namespace QCA { // WRAPNS_LINE
56
namespace QCA { // WRAPNS_LINE
59
namespace QCA { // WRAPNS_LINE
63
/*************************************************
64
* Global State Container Base *
65
*************************************************/
69
#ifndef BOTAN_TOOLS_ONLY
74
Engine_Iterator(const Library_State& l) : lib(l) { n = 0; }
76
const Library_State& lib;
79
friend class Engine_Iterator;
84
virtual void pulse(Pulse_Type) {}
90
Allocator* get_allocator(const std::string& = "") const;
91
void add_allocator(Allocator*);
92
#ifdef BOTAN_TOOLS_ONLY
93
void set_default_allocator(const std::string&);
95
void set_default_allocator(const std::string&) const;
98
#ifndef BOTAN_TOOLS_ONLY
99
bool rng_is_seeded() const { return rng->is_seeded(); }
100
void randomize(byte[], u32bit);
102
void set_prng(RandomNumberGenerator*);
103
void add_entropy_source(EntropySource*, bool = true);
104
void add_entropy(const byte[], u32bit);
105
void add_entropy(EntropySource&, bool);
106
u32bit seed_prng(bool, u32bit);
109
void load(class Modules&);
111
#ifndef BOTAN_TOOLS_ONLY
112
void set_timer(class Timer*);
113
u64bit system_clock() const;
115
class Config& config() const;
117
void add_engine(class Engine*);
120
class Mutex* get_mutex() const;
121
class Mutex* get_named_mutex(const std::string&);
123
#ifndef BOTAN_TOOLS_ONLY
124
void set_x509_state(class X509_GlobalState*);
125
class X509_GlobalState& x509_state();
127
void pulse(Pulse_Type) const;
130
void set_transcoder(class Charset_Transcoder*);
131
std::string transcode(const std::string,
132
Character_Set, Character_Set) const;
135
Library_State(class Mutex_Factory*);
138
Library_State(const Library_State&) {}
139
Library_State& operator=(const Library_State&) { return (*this); }
141
#ifndef BOTAN_TOOLS_ONLY
142
class Engine* get_engine_n(u32bit) const;
145
class Mutex_Factory* mutex_factory;
146
#ifndef BOTAN_TOOLS_ONLY
148
class Config* config_obj;
149
class X509_GlobalState* x509_state_obj;
152
std::map<std::string, class Mutex*> locks;
153
std::map<std::string, Allocator*> alloc_factory;
154
mutable Allocator* cached_default_allocator;
155
#ifdef BOTAN_TOOLS_ONLY
156
std::string default_allocator_type;
159
#ifndef BOTAN_TOOLS_ONLY
161
class Charset_Transcoder* transcoder;
162
RandomNumberGenerator* rng;
164
std::vector<Allocator*> allocators;
165
#ifndef BOTAN_TOOLS_ONLY
166
std::vector<EntropySource*> entropy_sources;
167
std::vector<class Engine*> engines;
171
/*************************************************
173
*************************************************/
174
Library_State& global_state();
175
void set_global_state(Library_State*);
176
Library_State* swap_global_state(Library_State*);