Crypto++
config.h
1 #ifndef __x86_64__
2 #define CRYPTOPP_DISABLE_SSE2
3 #endif
4 
5 #ifndef CRYPTOPP_CONFIG_H
6 #define CRYPTOPP_CONFIG_H
7 
8 // ***************** Important Settings ********************
9 
10 // define this if running on a big-endian CPU
11 #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__s390__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
12 # define IS_BIG_ENDIAN
13 #endif
14 
15 // define this if running on a little-endian CPU
16 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
17 #ifndef IS_BIG_ENDIAN
18 # define IS_LITTLE_ENDIAN
19 #endif
20 
21 // define this if you want to disable all OS-dependent features,
22 // such as sockets and OS-provided random number generators
23 // #define NO_OS_DEPENDENCE
24 
25 // Define this to use features provided by Microsoft's CryptoAPI.
26 // Currently the only feature used is random number generation.
27 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
28 #define USE_MS_CRYPTOAPI
29 
30 // ***************** Less Important Settings ***************
31 
32 // define this to retain (as much as possible) old deprecated function and class names
33 // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
34 
35 #define GZIP_OS_CODE 0
36 
37 // Try this if your CPU has 256K internal cache or a slow multiply instruction
38 // and you want a (possibly) faster IDEA implementation using log tables
39 // #define IDEA_LARGECACHE
40 
41 // Define this if, for the linear congruential RNG, you want to use
42 // the original constants as specified in S.K. Park and K.W. Miller's
43 // CACM paper.
44 // #define LCRNG_ORIGINAL_NUMBERS
45 
46 // choose which style of sockets to wrap (mostly useful for cygwin which has both)
47 #define PREFER_BERKELEY_STYLE_SOCKETS
48 // #define PREFER_WINDOWS_STYLE_SOCKETS
49 
50 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
51 #define CRYPTOPP_RIJNDAEL_NAME "AES"
52 
53 // ***************** Important Settings Again ********************
54 // But the defaults should be ok.
55 
56 // namespace support is now required
57 #ifdef NO_NAMESPACE
58 # error namespace support is now required
59 #endif
60 
61 // Define this to workaround a Microsoft CryptoAPI bug where
62 // each call to CryptAcquireContext causes a 100 KB memory leak.
63 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
64 #define WORKAROUND_MS_BUG_Q258000
65 
66 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
67 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
68 # define CryptoPP
69 # define NAMESPACE_BEGIN(x)
70 # define NAMESPACE_END
71 // Get Doxygen to generate better documentation for these typedefs
72 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
73 #else
74 # define NAMESPACE_BEGIN(x) namespace x {
75 # define NAMESPACE_END }
76 # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
77 #endif
78 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
79 #define USING_NAMESPACE(x) using namespace x;
80 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
81 #define DOCUMENTED_NAMESPACE_END }
82 
83 // What is the type of the third parameter to bind?
84 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
85 // Unfortunately there is no way to tell whether or not socklen_t is defined.
86 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
87 #ifndef TYPE_OF_SOCKLEN_T
88 # if defined(_WIN32) || defined(__CYGWIN__)
89 # define TYPE_OF_SOCKLEN_T int
90 # else
91 # define TYPE_OF_SOCKLEN_T ::socklen_t
92 # endif
93 #endif
94 
95 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
96 # define __USE_W32_SOCKETS
97 #endif
98 
99 typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
100 
101 NAMESPACE_BEGIN(CryptoPP)
102 
103 typedef unsigned short word16;
104 typedef unsigned int word32;
105 
106 #if defined(_MSC_VER) || defined(__BORLANDC__)
107  typedef unsigned __int64 word64;
108  #define W64LIT(x) x##ui64
109 #else
110  typedef unsigned long long word64;
111  #define W64LIT(x) x##ULL
112 #endif
113 
114 // define large word type, used for file offsets and such
115 typedef word64 lword;
116 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
117 
118 #ifdef __GNUC__
119  #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
120 #endif
121 
122 // define hword, word, and dword. these are used for multiprecision integer arithmetic
123 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
124 #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
125  typedef word32 hword;
126  typedef word64 word;
127 #else
128  #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
129  #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) || defined(__s390x__)
130  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
131  // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
132  // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
133  typedef word32 hword;
134  typedef word64 word;
135  typedef __uint128_t dword;
136  typedef __uint128_t word128;
137  #define CRYPTOPP_WORD128_AVAILABLE
138  #else
139  // if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results
140  typedef word16 hword;
141  typedef word32 word;
142  typedef word64 dword;
143  #endif
144  #else
145  // being here means the native register size is probably 32 bits or less
146  #define CRYPTOPP_BOOL_SLOW_WORD64 1
147  typedef word16 hword;
148  typedef word32 word;
149  typedef word64 dword;
150  #endif
151 #endif
152 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
153  #define CRYPTOPP_BOOL_SLOW_WORD64 0
154 #endif
155 
156 const unsigned int WORD_SIZE = sizeof(word);
157 const unsigned int WORD_BITS = WORD_SIZE * 8;
158 
159 NAMESPACE_END
160 
161 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
162  // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
163  #if defined(_M_X64) || defined(__x86_64__)
164  #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
165  #else
166  // L1 cache line size is 32 on Pentium III and earlier
167  #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
168  #endif
169 #endif
170 
171 #if defined(_MSC_VER)
172  #if _MSC_VER == 1200
173  #include <malloc.h>
174  #endif
175  #if _MSC_VER > 1200 || defined(_mm_free)
176  #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
177  #else
178  #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
179  #endif
180 #endif
181 
182 #ifndef CRYPTOPP_ALIGN_DATA
183  #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
184  #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
185  #elif defined(__GNUC__)
186  #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
187  #else
188  #define CRYPTOPP_ALIGN_DATA(x)
189  #endif
190 #endif
191 
192 #ifndef CRYPTOPP_SECTION_ALIGN16
193  #if defined(__GNUC__) && !defined(__APPLE__)
194  // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
195  #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
196  #else
197  #define CRYPTOPP_SECTION_ALIGN16
198  #endif
199 #endif
200 
201 #if defined(_MSC_VER) || defined(__fastcall)
202  #define CRYPTOPP_FASTCALL __fastcall
203 #else
204  #define CRYPTOPP_FASTCALL
205 #endif
206 
207 // VC60 workaround: it doesn't allow typename in some places
208 #if defined(_MSC_VER) && (_MSC_VER < 1300)
209 #define CPP_TYPENAME
210 #else
211 #define CPP_TYPENAME typename
212 #endif
213 
214 // VC60 workaround: can't cast unsigned __int64 to float or double
215 #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
216 #define CRYPTOPP_VC6_INT64 (__int64)
217 #else
218 #define CRYPTOPP_VC6_INT64
219 #endif
220 
221 #ifdef _MSC_VER
222 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
223 #else
224 #define CRYPTOPP_NO_VTABLE
225 #endif
226 
227 #ifdef _MSC_VER
228  // 4231: nonstandard extension used : 'extern' before template explicit instantiation
229  // 4250: dominance
230  // 4251: member needs to have dll-interface
231  // 4275: base needs to have dll-interface
232  // 4660: explicitly instantiating a class that's already implicitly instantiated
233  // 4661: no suitable definition provided for explicit template instantiation request
234  // 4786: identifer was truncated in debug information
235  // 4355: 'this' : used in base member initializer list
236  // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
237 # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910)
238 #endif
239 
240 #ifdef __BORLANDC__
241 // 8037: non-const function called for const object. needed to work around BCB2006 bug
242 # pragma warn -8037
243 #endif
244 
245 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
246 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
247 #endif
248 
249 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
250 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
251 #endif
252 
253 #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
254 #define CRYPTOPP_DISABLE_ASM
255 #define CRYPTOPP_DISABLE_SSE2
256 #endif
257 
258 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
259  // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
260  #define CRYPTOPP_X86_ASM_AVAILABLE
261 
262  #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
263  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
264  #else
265  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
266  #endif
267 
268  // SSSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed.
269  // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
270  #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
271  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
272  #else
273  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
274  #endif
275 #endif
276 
277 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
278  #define CRYPTOPP_X64_MASM_AVAILABLE
279 #endif
280 
281 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
282  #define CRYPTOPP_X64_ASM_AVAILABLE
283 #endif
284 
285 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
286  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
287 #else
288  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
289 #endif
290 
291 #if !defined(CRYPTOPP_DISABLE_SSSE3) && !defined(CRYPTOPP_DISABLE_AESNI) && CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && (CRYPTOPP_GCC_VERSION >= 40400 || _MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110)
292  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
293 #else
294  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
295 #endif
296 
297 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
298  #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
299 #else
300  #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
301 #endif
302 
303 // how to allocate 16-byte aligned memory (for SSE2)
304 #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
305  #define CRYPTOPP_MM_MALLOC_AVAILABLE
306 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
307  #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
308 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
309  #define CRYPTOPP_MEMALIGN_AVAILABLE
310 #else
311  #define CRYPTOPP_NO_ALIGNED_ALLOC
312 #endif
313 
314 // how to disable inlining
315 #if defined(_MSC_VER) && _MSC_VER >= 1300
316 # define CRYPTOPP_NOINLINE_DOTDOTDOT
317 # define CRYPTOPP_NOINLINE __declspec(noinline)
318 #elif defined(__GNUC__)
319 # define CRYPTOPP_NOINLINE_DOTDOTDOT
320 # define CRYPTOPP_NOINLINE __attribute__((noinline))
321 #else
322 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
323 # define CRYPTOPP_NOINLINE
324 #endif
325 
326 // how to declare class constants
327 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
328 # define CRYPTOPP_CONSTANT(x) enum {x};
329 #else
330 # define CRYPTOPP_CONSTANT(x) static const int x;
331 #endif
332 
333 #if defined(_M_X64) || defined(__x86_64__)
334  #define CRYPTOPP_BOOL_X64 1
335 #else
336  #define CRYPTOPP_BOOL_X64 0
337 #endif
338 
339 // see http://predef.sourceforge.net/prearch.html
340 #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)
341  #define CRYPTOPP_BOOL_X86 1
342 #else
343  #define CRYPTOPP_BOOL_X86 0
344 #endif
345 
346 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)
347  #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
348 #endif
349 
350 #define CRYPTOPP_VERSION 562
351 
352 // ***************** determine availability of OS features ********************
353 
354 #ifndef NO_OS_DEPENDENCE
355 
356 #if defined(_WIN32) || defined(__CYGWIN__)
357 #define CRYPTOPP_WIN32_AVAILABLE
358 #endif
359 
360 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
361 #define CRYPTOPP_UNIX_AVAILABLE
362 #endif
363 
364 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
365 # define HIGHRES_TIMER_AVAILABLE
366 #endif
367 
368 #ifdef CRYPTOPP_UNIX_AVAILABLE
369 # define HAS_BERKELEY_STYLE_SOCKETS
370 #endif
371 
372 #ifdef CRYPTOPP_WIN32_AVAILABLE
373 # define HAS_WINDOWS_STYLE_SOCKETS
374 #endif
375 
376 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
377 # define SOCKETS_AVAILABLE
378 #endif
379 
380 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
381 # define USE_WINDOWS_STYLE_SOCKETS
382 #else
383 # define USE_BERKELEY_STYLE_SOCKETS
384 #endif
385 
386 #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
387 # define WINDOWS_PIPES_AVAILABLE
388 #endif
389 
390 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
391 # define NONBLOCKING_RNG_AVAILABLE
392 # define OS_RNG_AVAILABLE
393 #endif
394 
395 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
396 # define NONBLOCKING_RNG_AVAILABLE
397 # define BLOCKING_RNG_AVAILABLE
398 # define OS_RNG_AVAILABLE
399 # define HAS_PTHREADS
400 # define THREADS_AVAILABLE
401 #endif
402 
403 #ifdef CRYPTOPP_WIN32_AVAILABLE
404 # define HAS_WINTHREADS
405 # define THREADS_AVAILABLE
406 #endif
407 
408 #endif // NO_OS_DEPENDENCE
409 
410 // ***************** DLL related ********************
411 
412 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
413 
414 #ifdef CRYPTOPP_EXPORTS
415 #define CRYPTOPP_IS_DLL
416 #define CRYPTOPP_DLL __declspec(dllexport)
417 #elif defined(CRYPTOPP_IMPORTS)
418 #define CRYPTOPP_IS_DLL
419 #define CRYPTOPP_DLL __declspec(dllimport)
420 #else
421 #define CRYPTOPP_DLL
422 #endif
423 
424 #define CRYPTOPP_API __cdecl
425 
426 #else // CRYPTOPP_WIN32_AVAILABLE
427 
428 #define CRYPTOPP_DLL
429 #define CRYPTOPP_API
430 
431 #endif // CRYPTOPP_WIN32_AVAILABLE
432 
433 #if defined(__MWERKS__)
434 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
435 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
436 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
437 #else
438 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
439 #endif
440 
441 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
442 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
443 #else
444 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
445 #endif
446 
447 #if defined(__MWERKS__)
448 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
449 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
450 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
451 #else
452 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
453 #endif
454 
455 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
456 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
457 #else
458 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
459 #endif
460 
461 #endif