blob: d38a29c9a4bdd0abf44acdd9c03d1dd64add5321 (
plain)
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
|
/*************************************************
* Module Factory Source File *
* (C) 1999-2008 Jack Lloyd *
*************************************************/
#include <botan/modules.h>
#include <botan/defalloc.h>
#include <botan/eng_def.h>
#include <botan/timers.h>
#include <botan/parsing.h>
#if defined(BOTAN_HAS_MUTEX_PTHREAD)
#include <botan/mux_pthr.h>
#elif defined(BOTAN_HAS_MUTEX_WIN32)
#include <botan/mux_win32.h>
#elif defined(BOTAN_HAS_MUTEX_QT)
#include <botan/mux_qt.h>
#endif
#if defined(BOTAN_HAS_ALLOC_MMAP)
#include <botan/mmap_mem.h>
#endif
#if defined(BOTAN_HAS_ENGINE_GNU_MP)
#include <botan/eng_gmp.h>
#endif
#if defined(BOTAN_HAS_ENGINE_OPENSSL)
#include <botan/eng_ossl.h>
#endif
namespace Botan {
/*************************************************
* Return a mutex factory, if available *
*************************************************/
Mutex_Factory* Builtin_Modules::mutex_factory() const
{
#if defined(BOTAN_HAS_MUTEX_PTHREAD)
return new Pthread_Mutex_Factory;
#elif defined(BOTAN_HAS_MUTEX_WIN32)
return new Win32_Mutex_Factory;
#elif defined(BOTAN_HAS_MUTEX_QT)
return new Qt_Mutex_Factory;
#else
return 0;
#endif
}
/*************************************************
* Find any usable allocators *
*************************************************/
std::vector<Allocator*> Builtin_Modules::allocators() const
{
std::vector<Allocator*> allocators;
#if defined(BOTAN_HAS_ALLOC_MMAP)
allocators.push_back(new MemoryMapping_Allocator);
#endif
allocators.push_back(new Locking_Allocator);
allocators.push_back(new Malloc_Allocator);
return allocators;
}
/*************************************************
* Return the default allocator *
*************************************************/
std::string Builtin_Modules::default_allocator() const
{
if(should_lock)
{
#if defined(BOTAN_HAS_ALLOC_MMAP)
return "mmap";
#else
return "locking";
#endif
}
else
return "malloc";
}
/*************************************************
* Find any usable engines *
*************************************************/
std::vector<Engine*> Builtin_Modules::engines() const
{
std::vector<Engine*> engines;
if(use_engines)
{
#if defined(BOTAN_HAS_ENGINE_GNU_MP)
engines.push_back(new GMP_Engine);
#endif
#if defined(BOTAN_HAS_ENGINE_OPENSSL)
engines.push_back(new OpenSSL_Engine);
#endif
}
engines.push_back(new Default_Engine);
return engines;
}
/*************************************************
* Builtin_Modules Constructor *
*************************************************/
Builtin_Modules::Builtin_Modules(const InitializerOptions& args) :
should_lock(args.secure_memory()),
use_engines(args.use_engines())
{
}
}
|