~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to third-party/qca/qca/src/botantools/botan/modules.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 1999-2007 The Botan Project. All rights reserved.
 
3
 
 
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:
 
6
 
 
7
1. Redistributions of source code must retain the above copyright notice, this
 
8
list of conditions, and the following disclaimer.
 
9
 
 
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.
 
13
 
 
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.
 
17
 
 
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.
 
25
*/
 
26
// LICENSEHEADER_END
 
27
namespace QCA { // WRAPNS_LINE
 
28
/*************************************************
 
29
* Module Factory Source File                     *
 
30
* (C) 1999-2007 The Botan Project                *
 
31
*************************************************/
 
32
 
 
33
} // WRAPNS_LINE
 
34
#include <botan/modules.h>
 
35
namespace QCA { // WRAPNS_LINE
 
36
} // WRAPNS_LINE
 
37
#include <botan/defalloc.h>
 
38
namespace QCA { // WRAPNS_LINE
 
39
#ifndef BOTAN_TOOLS_ONLY
 
40
} // WRAPNS_LINE
 
41
#include <botan/def_char.h>
 
42
namespace QCA { // WRAPNS_LINE
 
43
} // WRAPNS_LINE
 
44
#include <botan/eng_def.h>
 
45
namespace QCA { // WRAPNS_LINE
 
46
} // WRAPNS_LINE
 
47
#include <botan/es_file.h>
 
48
namespace QCA { // WRAPNS_LINE
 
49
} // WRAPNS_LINE
 
50
#include <botan/timers.h>
 
51
namespace QCA { // WRAPNS_LINE
 
52
#endif
 
53
 
 
54
#if defined(BOTAN_EXT_MUTEX_PTHREAD)
 
55
} // WRAPNS_LINE
 
56
#  include <botan/mux_pthr.h>
 
57
namespace QCA { // WRAPNS_LINE
 
58
#elif defined(BOTAN_EXT_MUTEX_WIN32)
 
59
} // WRAPNS_LINE
 
60
#  include <botan/mux_win32.h>
 
61
namespace QCA { // WRAPNS_LINE
 
62
#elif defined(BOTAN_EXT_MUTEX_QT)
 
63
} // WRAPNS_LINE
 
64
#  include <botan/mux_qt.h>
 
65
namespace QCA { // WRAPNS_LINE
 
66
#endif
 
67
 
 
68
#if defined(BOTAN_EXT_ALLOC_MMAP)
 
69
} // WRAPNS_LINE
 
70
#  include <botan/mmap_mem.h>
 
71
namespace QCA { // WRAPNS_LINE
 
72
#endif
 
73
 
 
74
#ifndef BOTAN_TOOLS_ONLY
 
75
 
 
76
#if defined(BOTAN_EXT_TIMER_HARDWARE)
 
77
} // WRAPNS_LINE
 
78
#  include <botan/tm_hard.h>
 
79
namespace QCA { // WRAPNS_LINE
 
80
#elif defined(BOTAN_EXT_TIMER_POSIX)
 
81
} // WRAPNS_LINE
 
82
#  include <botan/tm_posix.h>
 
83
namespace QCA { // WRAPNS_LINE
 
84
#elif defined(BOTAN_EXT_TIMER_UNIX)
 
85
} // WRAPNS_LINE
 
86
#  include <botan/tm_unix.h>
 
87
namespace QCA { // WRAPNS_LINE
 
88
#elif defined(BOTAN_EXT_TIMER_WIN32)
 
89
} // WRAPNS_LINE
 
90
#  include <botan/tm_win32.h>
 
91
namespace QCA { // WRAPNS_LINE
 
92
#endif
 
93
 
 
94
#if defined(BOTAN_EXT_ENGINE_AEP)
 
95
} // WRAPNS_LINE
 
96
#  include <botan/eng_aep.h>
 
97
namespace QCA { // WRAPNS_LINE
 
98
#endif
 
99
 
 
100
#if defined(BOTAN_EXT_ENGINE_GNU_MP)
 
101
} // WRAPNS_LINE
 
102
#  include <botan/eng_gmp.h>
 
103
namespace QCA { // WRAPNS_LINE
 
104
#endif
 
105
 
 
106
#if defined(BOTAN_EXT_ENGINE_OPENSSL)
 
107
} // WRAPNS_LINE
 
108
#  include <botan/eng_ossl.h>
 
109
namespace QCA { // WRAPNS_LINE
 
110
#endif
 
111
 
 
112
#if defined(BOTAN_EXT_ENTROPY_SRC_AEP)
 
113
} // WRAPNS_LINE
 
114
#  include <botan/es_aep.h>
 
115
namespace QCA { // WRAPNS_LINE
 
116
#endif
 
117
 
 
118
#if defined(BOTAN_EXT_ENTROPY_SRC_EGD)
 
119
} // WRAPNS_LINE
 
120
#  include <botan/es_egd.h>
 
121
namespace QCA { // WRAPNS_LINE
 
122
#endif
 
123
 
 
124
#if defined(BOTAN_EXT_ENTROPY_SRC_UNIX)
 
125
} // WRAPNS_LINE
 
126
#  include <botan/es_unix.h>
 
127
namespace QCA { // WRAPNS_LINE
 
128
#endif
 
129
 
 
130
#if defined(BOTAN_EXT_ENTROPY_SRC_BEOS)
 
131
} // WRAPNS_LINE
 
132
#  include <botan/es_beos.h>
 
133
namespace QCA { // WRAPNS_LINE
 
134
#endif
 
135
 
 
136
#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI)
 
137
} // WRAPNS_LINE
 
138
#  include <botan/es_capi.h>
 
139
namespace QCA { // WRAPNS_LINE
 
140
#endif
 
141
 
 
142
#if defined(BOTAN_EXT_ENTROPY_SRC_WIN32)
 
143
} // WRAPNS_LINE
 
144
#  include <botan/es_win32.h>
 
145
namespace QCA { // WRAPNS_LINE
 
146
#endif
 
147
 
 
148
#if defined(BOTAN_EXT_ENTROPY_SRC_FTW)
 
149
} // WRAPNS_LINE
 
150
#  include <botan/es_ftw.h>
 
151
namespace QCA { // WRAPNS_LINE
 
152
#endif
 
153
 
 
154
#endif
 
155
 
 
156
namespace Botan {
 
157
 
 
158
/*************************************************
 
159
* Return a mutex factory, if available           *
 
160
*************************************************/
 
161
Mutex_Factory* Builtin_Modules::mutex_factory() const
 
162
   {
 
163
#if defined(BOTAN_EXT_MUTEX_PTHREAD)
 
164
   return new Pthread_Mutex_Factory;
 
165
#elif defined(BOTAN_EXT_MUTEX_WIN32)
 
166
   return new Win32_Mutex_Factory;
 
167
#elif defined(BOTAN_EXT_MUTEX_QT)
 
168
   return new Qt_Mutex_Factory;
 
169
#else
 
170
   return 0;
 
171
#endif
 
172
   }
 
173
 
 
174
/*************************************************
 
175
* Find a high resolution timer, if possible      *
 
176
*************************************************/
 
177
#ifndef BOTAN_TOOLS_ONLY
 
178
Timer* Builtin_Modules::timer() const
 
179
   {
 
180
#if defined(BOTAN_EXT_TIMER_HARDWARE)
 
181
   return new Hardware_Timer;
 
182
#elif defined(BOTAN_EXT_TIMER_POSIX)
 
183
   return new POSIX_Timer;
 
184
#elif defined(BOTAN_EXT_TIMER_UNIX)
 
185
   return new Unix_Timer;
 
186
#elif defined(BOTAN_EXT_TIMER_WIN32)
 
187
   return new Win32_Timer;
 
188
#else
 
189
   return new Timer;
 
190
#endif
 
191
   }
 
192
#endif
 
193
 
 
194
/*************************************************
 
195
* Find any usable allocators                     *
 
196
*************************************************/
 
197
std::vector<Allocator*> Builtin_Modules::allocators() const
 
198
   {
 
199
   std::vector<Allocator*> allocators;
 
200
 
 
201
#if defined(BOTAN_EXT_ALLOC_MMAP)
 
202
   allocators.push_back(new MemoryMapping_Allocator);
 
203
#endif
 
204
 
 
205
   allocators.push_back(new Locking_Allocator);
 
206
   allocators.push_back(new Malloc_Allocator);
 
207
 
 
208
   return allocators;
 
209
   }
 
210
 
 
211
/*************************************************
 
212
* Return the default allocator                   *
 
213
*************************************************/
 
214
std::string Builtin_Modules::default_allocator() const
 
215
   {
 
216
   if(should_lock)
 
217
      {
 
218
#if defined(BOTAN_EXT_ALLOC_MMAP)
 
219
      return "mmap";
 
220
#else
 
221
      return "locking";
 
222
#endif
 
223
      }
 
224
   else
 
225
      return "malloc";
 
226
   }
 
227
 
 
228
#ifndef BOTAN_TOOLS_ONLY
 
229
 
 
230
/*************************************************
 
231
* Register any usable entropy sources            *
 
232
*************************************************/
 
233
std::vector<EntropySource*> Builtin_Modules::entropy_sources() const
 
234
   {
 
235
   std::vector<EntropySource*> sources;
 
236
 
 
237
   sources.push_back(new File_EntropySource);
 
238
 
 
239
#if defined(BOTAN_EXT_ENTROPY_SRC_AEP)
 
240
   sources.push_back(new AEP_EntropySource);
 
241
#endif
 
242
 
 
243
#if defined(BOTAN_EXT_ENTROPY_SRC_EGD)
 
244
   sources.push_back(new EGD_EntropySource);
 
245
#endif
 
246
 
 
247
#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI)
 
248
   sources.push_back(new Win32_CAPI_EntropySource);
 
249
#endif
 
250
 
 
251
#if defined(BOTAN_EXT_ENTROPY_SRC_WIN32)
 
252
   sources.push_back(new Win32_EntropySource);
 
253
#endif
 
254
 
 
255
#if defined(BOTAN_EXT_ENTROPY_SRC_UNIX)
 
256
   sources.push_back(new Unix_EntropySource);
 
257
#endif
 
258
 
 
259
#if defined(BOTAN_EXT_ENTROPY_SRC_BEOS)
 
260
   sources.push_back(new BeOS_EntropySource);
 
261
#endif
 
262
 
 
263
#if defined(BOTAN_EXT_ENTROPY_SRC_FTW)
 
264
   sources.push_back(new FTW_EntropySource);
 
265
#endif
 
266
 
 
267
   return sources;
 
268
   }
 
269
 
 
270
/*************************************************
 
271
* Find any usable engines                        *
 
272
*************************************************/
 
273
std::vector<Engine*> Builtin_Modules::engines() const
 
274
   {
 
275
   std::vector<Engine*> engines;
 
276
 
 
277
   if(use_engines)
 
278
      {
 
279
#if defined(BOTAN_EXT_ENGINE_AEP)
 
280
      engines.push_back(new AEP_Engine);
 
281
#endif
 
282
 
 
283
#if defined(BOTAN_EXT_ENGINE_GNU_MP)
 
284
      engines.push_back(new GMP_Engine);
 
285
#endif
 
286
 
 
287
#if defined(BOTAN_EXT_ENGINE_OPENSSL)
 
288
      engines.push_back(new OpenSSL_Engine);
 
289
#endif
 
290
      }
 
291
 
 
292
   engines.push_back(new Default_Engine);
 
293
 
 
294
   return engines;
 
295
   }
 
296
 
 
297
/*************************************************
 
298
* Find the best transcoder option                *
 
299
*************************************************/
 
300
Charset_Transcoder* Builtin_Modules::transcoder() const
 
301
   {
 
302
   return new Default_Charset_Transcoder;
 
303
   }
 
304
 
 
305
#endif
 
306
 
 
307
/*************************************************
 
308
* Builtin_Modules Constructor                    *
 
309
*************************************************/
 
310
#ifdef BOTAN_TOOLS_ONLY
 
311
Builtin_Modules::Builtin_Modules() :
 
312
   should_lock(true)
 
313
   {
 
314
   }
 
315
#else
 
316
Builtin_Modules::Builtin_Modules(const InitializerOptions& args) :
 
317
   should_lock(args.secure_memory()),
 
318
   use_engines(args.use_engines())
 
319
   {
 
320
   }
 
321
#endif
 
322
 
 
323
}
 
324
} // WRAPNS_LINE