Crypto++  5.6.3
Free C++ class library of cryptographic schemes
config.h
Go to the documentation of this file.
1 // config.h - written and placed in the public domain by Wei Dai
2 
3 //! \file
4 //! \headerfile config.h
5 //! \brief Library configuration file
6 
7 #ifndef CRYPTOPP_CONFIG_H
8 #define CRYPTOPP_CONFIG_H
9 
10 // ***************** Important Settings ********************
11 
12 // define this if running on a big-endian CPU
13 #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
14 # define IS_BIG_ENDIAN
15 #endif
16 
17 // define this if running on a little-endian CPU
18 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
19 #ifndef IS_BIG_ENDIAN
20 # define IS_LITTLE_ENDIAN
21 #endif
22 
23 // Sanity checks. Some processors have more than big-, little- and bi-endian modes. PDP mode, where order results in "4312", should
24 // raise red flags immediately. Additionally, mis-classified machines, like (previosuly) S/390, should raise red flags immediately.
25 #if defined(IS_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
26 # error "IS_BIG_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_BIG_ENDIAN__"
27 #endif
28 #if defined(IS_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
29 # error "IS_LITTLE_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_LITTLE_ENDIAN__"
30 #endif
31 
32 // define this if you want to disable all OS-dependent features,
33 // such as sockets and OS-provided random number generators
34 // #define NO_OS_DEPENDENCE
35 
36 // Define this to use features provided by Microsoft's CryptoAPI.
37 // Currently the only feature used is random number generation.
38 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
39 #define USE_MS_CRYPTOAPI
40 
41 // Define this to ensure C/C++ standard compliance and respect for GCC aliasing rules and other alignment fodder. If you
42 // experience a break with GCC at -O3, you should try this first. Guard it in case its set on the command line (and it differs).
43 #ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
44 // # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
45 #endif
46 
47 // ***************** Less Important Settings ***************
48 
49 // Library version
50 #define CRYPTOPP_VERSION 563
51 
52 // define this to retain (as much as possible) old deprecated function and class names
53 // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
54 
55 // define this to retain (as much as possible) ABI and binary compatibility with Crypto++ 5.6.2.
56 // Also see https://cryptopp.com/wiki/Config.h#Avoid_MAINTAIN_BACKWARDS_COMPATIBILITY
57 #if (CRYPTOPP_VERSION <= 600)
58 # if !defined(CRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562) && !defined(CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562)
59 # define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
60 # endif
61 #endif
62 
63 // Define this if you want or need the library's memcpy_s and memmove_s.
64 // See http://github.com/weidai11/cryptopp/issues/28.
65 // #if !defined(CRYPTOPP_WANT_SECURE_LIB)
66 // # define CRYPTOPP_WANT_SECURE_LIB
67 // #endif
68 
69 // File system code to write to GZIP archive.
70 #if !defined(GZIP_OS_CODE)
71 # define GZIP_OS_CODE 0
72 #endif
73 
74 // Try this if your CPU has 256K internal cache or a slow multiply instruction
75 // and you want a (possibly) faster IDEA implementation using log tables
76 // #define IDEA_LARGECACHE
77 
78 // Define this if, for the linear congruential RNG, you want to use
79 // the original constants as specified in S.K. Park and K.W. Miller's
80 // CACM paper.
81 // #define LCRNG_ORIGINAL_NUMBERS
82 
83 // choose which style of sockets to wrap (mostly useful for MinGW which has both)
84 #if !defined(NO_BERKELEY_STYLE_SOCKETS) && !defined(PREFER_BERKELEY_STYLE_SOCKETS)
85 # define PREFER_BERKELEY_STYLE_SOCKETS
86 #endif
87 
88 // #if !defined(NO_WINDOWS_STYLE_SOCKETS) && !defined(PREFER_WINDOWS_STYLE_SOCKETS)
89 // # define PREFER_WINDOWS_STYLE_SOCKETS
90 // #endif
91 
92 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
93 #define CRYPTOPP_RIJNDAEL_NAME "AES"
94 
95 // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
96 // Under GCC, the library uses init_priority attribute in the range
97 // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
98 // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)".
99 // #define CRYPTOPP_INIT_PRIORITY 250
100 
101 // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
102 // and managing C++ static object creation. It is guaranteed not to conflict with
103 // values used by (or would be used by) the Crypto++ library.
104 #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0)
105 # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101)
106 #else
107 # define CRYPTOPP_USER_PRIORITY 250
108 #endif
109 
110 // ***************** Important Settings Again ********************
111 // But the defaults should be ok.
112 
113 // namespace support is now required
114 #ifdef NO_NAMESPACE
115 # error namespace support is now required
116 #endif
117 
118 // Define this to workaround a Microsoft CryptoAPI bug where
119 // each call to CryptAcquireContext causes a 100 KB memory leak.
120 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
121 #define WORKAROUND_MS_BUG_Q258000
122 
123 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
124 // Document the namespce exists. Put it here before CryptoPP is undefined below.
125 //! \namespace CryptoPP
126 //! \brief Crypto++ library namespace
127 //! \details Nearly all classes are located in the CryptoPP namespace. Within
128 //! the namespace, there are two additional namespaces.
129 //! <ul>
130 //! <li>Name - namespace for names used with \p NameValuePairs and documented in argnames.h
131 //! <li>Weak - namespace for weak and wounded algorithms, like ARC4, MD5 and Pananma
132 //! </ul>
133 namespace CryptoPP { }
134 // Bring in the symbols fund in the weak namespace; and fold Weak1 into Weak
135 # define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
136 # define Weak1 Weak
137 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
138 # define CryptoPP
139 # define NAMESPACE_BEGIN(x)
140 # define NAMESPACE_END
141 // Get Doxygen to generate better documentation for these typedefs
142 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
143 // Make "protected" "private" so the functions and members are not documented
144 # define protected private
145 #else
146 # define NAMESPACE_BEGIN(x) namespace x {
147 # define NAMESPACE_END }
148 # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
149 #endif
150 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
151 #define ANONYMOUS_NAMESPACE_END }
152 #define USING_NAMESPACE(x) using namespace x;
153 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
154 #define DOCUMENTED_NAMESPACE_END }
155 
156 // What is the type of the third parameter to bind?
157 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
158 // Unfortunately there is no way to tell whether or not socklen_t is defined.
159 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
160 #ifndef TYPE_OF_SOCKLEN_T
161 # if defined(_WIN32) || defined(__CYGWIN__)
162 # define TYPE_OF_SOCKLEN_T int
163 # else
164 # define TYPE_OF_SOCKLEN_T ::socklen_t
165 # endif
166 #endif
167 
168 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
169 # define __USE_W32_SOCKETS
170 #endif
171 
172 typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
173 
174 NAMESPACE_BEGIN(CryptoPP)
175 
176 typedef unsigned short word16;
177 typedef unsigned int word32;
178 
179 #if defined(_MSC_VER) || defined(__BORLANDC__)
180  typedef unsigned __int64 word64;
181  #define W64LIT(x) x##ui64
182 #else
183  typedef unsigned long long word64;
184  #define W64LIT(x) x##ULL
185 #endif
186 
187 // define large word type, used for file offsets and such
188 typedef word64 lword;
189 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
190 
191 #ifdef __GNUC__
192  #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
193 #endif
194 
195 // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
196 #if defined(__clang__ ) && !defined(__apple_build_version__)
197  #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
198 #elif defined(__clang__ ) && defined(__apple_build_version__)
199  #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
200 #endif
201 
202 #ifdef _MSC_VER
203  #define CRYPTOPP_MSC_VERSION (_MSC_VER)
204 #endif
205 
206 // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
207 #if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
208  #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
209 #endif
210 
211 // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
212 // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
213 #if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000)
214  #define CRYPTOPP_DISABLE_INTEL_ASM 1
215 #endif
216 
217 // define hword, word, and dword. these are used for multiprecision integer arithmetic
218 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
219 #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1000) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
220  typedef word32 hword;
221  typedef word64 word;
222 #else
223  #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
224  #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
225  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && (CRYPTOPP_GCC_VERSION >= 30400)
226  // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
227  // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
228  #define CRYPTOPP_WORD128_AVAILABLE
229  typedef word32 hword;
230  typedef word64 word;
231  typedef __uint128_t dword;
232  typedef __uint128_t word128;
233  #elif defined(__GNUC__) && (__SIZEOF_INT128__ >= 16)
234  // Detect availabliltiy of int128_t and uint128_t in preprocessor, http://gcc.gnu.org/ml/gcc-help/2015-08/msg00185.html.
235  #define CRYPTOPP_WORD128_AVAILABLE
236  typedef word32 hword;
237  typedef word64 word;
238  typedef __uint128_t dword;
239  typedef __uint128_t word128;
240  #else
241  // 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
242  typedef word16 hword;
243  typedef word32 word;
244  typedef word64 dword;
245  #endif
246  #elif defined(__GNUC__) && (__SIZEOF_INT128__ >= 16)
247  // Detect availabliltiy of int128_t and uint128_t in preprocessor, http://gcc.gnu.org/ml/gcc-help/2015-08/msg00185.html.
248  #define CRYPTOPP_WORD128_AVAILABLE
249  typedef word32 hword;
250  typedef word64 word;
251  typedef __uint128_t dword;
252  typedef __uint128_t word128;
253  #else
254  // being here means the native register size is probably 32 bits or less
255  #define CRYPTOPP_BOOL_SLOW_WORD64 1
256  typedef word16 hword;
257  typedef word32 word;
258  typedef word64 dword;
259  #endif
260 #endif
261 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
262  #define CRYPTOPP_BOOL_SLOW_WORD64 0
263 #endif
264 
265 // Produce a compiler error. It can be commented out, but you may not get the benefit of the fastest integers.
266 #if (__SIZEOF_INT128__ >= 16) && !defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(__aarch64__)
267 # error "An int128_t and uint128_t are available, but CRYPTOPP_WORD128_AVAILABLE is not defined"
268 #endif
269 
270 const unsigned int WORD_SIZE = sizeof(word);
271 const unsigned int WORD_BITS = WORD_SIZE * 8;
272 
273 NAMESPACE_END
274 
275 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
276  // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
277  // Also see http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size.
278  #if defined(_M_X64) || defined(__x86_64__) || (__ILP32__ >= 1)
279  #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
280  #else
281  // L1 cache line size is 32 on Pentium III and earlier
282  #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
283  #endif
284 #endif
285 
286 #if defined(_MSC_VER)
287  #if _MSC_VER == 1200
288  #include <malloc.h>
289  #endif
290  #if _MSC_VER > 1200 || defined(_mm_free)
291  #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
292  #else
293  #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
294  #endif
295 #endif
296 
297 #ifndef CRYPTOPP_ALIGN_DATA
298  #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
299  #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
300  #elif defined(__GNUC__)
301  #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
302  #else
303  #define CRYPTOPP_ALIGN_DATA(x)
304  #endif
305 #endif
306 
307 #ifndef CRYPTOPP_SECTION_ALIGN16
308 #if defined(__GNUC__) && !defined(__APPLE__)
309  // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
310  #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
311  #else
312  #define CRYPTOPP_SECTION_ALIGN16
313  #endif
314 #endif
315 
316 #if defined(_MSC_VER) || defined(__fastcall)
317  #define CRYPTOPP_FASTCALL __fastcall
318 #else
319  #define CRYPTOPP_FASTCALL
320 #endif
321 
322 // VC60 workaround: it doesn't allow typename in some places
323 #if defined(_MSC_VER) && (_MSC_VER < 1300)
324 #define CPP_TYPENAME
325 #else
326 #define CPP_TYPENAME typename
327 #endif
328 
329 // VC60 workaround: can't cast unsigned __int64 to float or double
330 #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
331 #define CRYPTOPP_VC6_INT64 (__int64)
332 #else
333 #define CRYPTOPP_VC6_INT64
334 #endif
335 
336 #ifdef _MSC_VER
337 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
338 #else
339 #define CRYPTOPP_NO_VTABLE
340 #endif
341 
342 #ifdef _MSC_VER
343  // 4127: conditional expression is constant
344  // 4231: nonstandard extension used : 'extern' before template explicit instantiation
345  // 4250: dominance
346  // 4251: member needs to have dll-interface
347  // 4275: base needs to have dll-interface
348  // 4505: unreferenced local function
349  // 4512: assignment operator not generated
350  // 4660: explicitly instantiating a class that's already implicitly instantiated
351  // 4661: no suitable definition provided for explicit template instantiation request
352  // 4786: identifer was truncated in debug information
353  // 4355: 'this' : used in base member initializer list
354  // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
355 # pragma warning(disable: 4127 4231 4250 4251 4275 4505 4512 4660 4661 4786 4355 4910)
356  // Security related, possible defects
357  // http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
358 # pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
359 #endif
360 
361 #ifdef __BORLANDC__
362 // 8037: non-const function called for const object. needed to work around BCB2006 bug
363 # pragma warn -8037
364 #endif
365 
366 // [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
367 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
368 # pragma GCC diagnostic ignored "-Wunknown-pragmas"
369 # pragma GCC diagnostic ignored "-Wunused-function"
370 #endif
371 
372 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
373 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
374 #endif
375 
376 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
377 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
378 #endif
379 
380 #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
381 #define CRYPTOPP_DISABLE_ASM
382 #define CRYPTOPP_DISABLE_SSE2
383 #endif
384 
385 // Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...)
386 #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
387 # define CRYPTOPP_DISABLE_ASM
388 #endif
389 
390 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
391  // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
392  #define CRYPTOPP_X86_ASM_AVAILABLE
393 
394  #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
395  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
396  #else
397  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
398  #endif
399 
400  // SSE3 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.
401  // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version. Also see the output of
402  // `gcc -dM -E -march=native - < /dev/null | grep -i SSE` for preprocessor defines available.
403  #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102 || defined(__SSSE3__) || defined(__SSE3__))
404  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
405  #else
406  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
407  #endif
408 #endif
409 
410 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
411  #define CRYPTOPP_X64_MASM_AVAILABLE
412 #endif
413 
414 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
415  #define CRYPTOPP_X64_ASM_AVAILABLE
416 #endif
417 
418 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
419  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
420 #else
421  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
422 #endif
423 
424 #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 || defined(__AES__))
425  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
426 #else
427  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
428 #endif
429 
430 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
431  #define CRYPTOPP_BOOL_ALIGN16 1
432 #else
433  #define CRYPTOPP_BOOL_ALIGN16 0
434 #endif
435 
436 // how to allocate 16-byte aligned memory (for SSE2)
437 #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
438  #define CRYPTOPP_MM_MALLOC_AVAILABLE
439 #elif defined(__APPLE__)
440  #define CRYPTOPP_APPLE_MALLOC_AVAILABLE
441 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
442  #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
443 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
444  #define CRYPTOPP_MEMALIGN_AVAILABLE
445 #else
446  #define CRYPTOPP_NO_ALIGNED_ALLOC
447 #endif
448 
449 // Apple always provides 16-byte aligned, and tells us to use calloc
450 // http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
451 
452 // how to disable inlining
453 #if defined(_MSC_VER) && _MSC_VER >= 1300
454 # define CRYPTOPP_NOINLINE_DOTDOTDOT
455 # define CRYPTOPP_NOINLINE __declspec(noinline)
456 #elif defined(__GNUC__)
457 # define CRYPTOPP_NOINLINE_DOTDOTDOT
458 # define CRYPTOPP_NOINLINE __attribute__((noinline))
459 #else
460 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
461 # define CRYPTOPP_NOINLINE
462 #endif
463 
464 // how to declare class constants
465 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
466 # define CRYPTOPP_CONSTANT(x) enum {x};
467 #else
468 # define CRYPTOPP_CONSTANT(x) static const int x;
469 #endif
470 
471 // Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
472 // Detect via __ILP32__ (http://wiki.debian.org/X32Port). Both GCC and Clang provide the preprocessor macro.
473 #if ((__ILP32__ >= 1) || (_ILP32 >= 1))
474  #define CRYPTOPP_BOOL_X32 1
475 #else
476  #define CRYPTOPP_BOOL_X32 0
477 #endif
478 
479 // see http://predef.sourceforge.net/prearch.html
480 #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
481  #define CRYPTOPP_BOOL_X86 1
482 #else
483  #define CRYPTOPP_BOOL_X86 0
484 #endif
485 
486 #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
487  #define CRYPTOPP_BOOL_X64 1
488 #else
489  #define CRYPTOPP_BOOL_X64 0
490 #endif
491 
492 // Undo the ASM and Intrinsic related defines due to X32.
493 #if CRYPTOPP_BOOL_X32
494 # undef CRYPTOPP_BOOL_X64
495 # undef CRYPTOPP_X64_ASM_AVAILABLE
496 # undef CRYPTOPP_X64_MASM_AVAILABLE
497 #endif
498 
499 #if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
500 #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1))
501  #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
502 #endif
503 #endif
504 
505 // ***************** determine availability of OS features ********************
506 
507 #ifndef NO_OS_DEPENDENCE
508 
509 #if defined(_WIN32) || defined(__CYGWIN__)
510 #define CRYPTOPP_WIN32_AVAILABLE
511 #endif
512 
513 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
514 #define CRYPTOPP_UNIX_AVAILABLE
515 #endif
516 
517 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
518 #define CRYPTOPP_BSD_AVAILABLE
519 #endif
520 
521 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
522 # define HIGHRES_TIMER_AVAILABLE
523 #endif
524 
525 #ifdef CRYPTOPP_UNIX_AVAILABLE
526 # define HAS_BERKELEY_STYLE_SOCKETS
527 #endif
528 
529 #ifdef CRYPTOPP_WIN32_AVAILABLE
530 # define HAS_WINDOWS_STYLE_SOCKETS
531 #endif
532 
533 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
534 # define SOCKETS_AVAILABLE
535 #endif
536 
537 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
538 # define USE_WINDOWS_STYLE_SOCKETS
539 #else
540 # define USE_BERKELEY_STYLE_SOCKETS
541 #endif
542 
543 #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
544 # define WINDOWS_PIPES_AVAILABLE
545 #endif
546 
547 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
548 # define NONBLOCKING_RNG_AVAILABLE
549 # define OS_RNG_AVAILABLE
550 #endif
551 
552 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
553 # define NONBLOCKING_RNG_AVAILABLE
554 # define BLOCKING_RNG_AVAILABLE
555 # define OS_RNG_AVAILABLE
556 # define HAS_PTHREADS
557 # define THREADS_AVAILABLE
558 #endif
559 
560 #ifdef CRYPTOPP_WIN32_AVAILABLE
561 # define HAS_WINTHREADS
562 # define THREADS_AVAILABLE
563 #endif
564 
565 #endif // NO_OS_DEPENDENCE
566 
567 // ***************** DLL related ********************
568 
569 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
570 
571 #ifdef CRYPTOPP_EXPORTS
572 #define CRYPTOPP_IS_DLL
573 #define CRYPTOPP_DLL __declspec(dllexport)
574 #elif defined(CRYPTOPP_IMPORTS)
575 #define CRYPTOPP_IS_DLL
576 #define CRYPTOPP_DLL __declspec(dllimport)
577 #else
578 #define CRYPTOPP_DLL
579 #endif
580 
581 #define CRYPTOPP_API __cdecl
582 
583 #else // not CRYPTOPP_WIN32_AVAILABLE
584 
585 #define CRYPTOPP_DLL
586 #define CRYPTOPP_API
587 
588 #endif // CRYPTOPP_WIN32_AVAILABLE
589 
590 #if defined(__MWERKS__)
591 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
592 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
593 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
594 #else
595 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
596 #endif
597 
598 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
599 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
600 #else
601 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
602 #endif
603 
604 #if defined(__MWERKS__)
605 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
606 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
607 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
608 #else
609 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
610 #endif
611 
612 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
613 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
614 #else
615 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
616 #endif
617 
618 // ************** Unused variable ***************
619 
620 // Portable way to suppress warnings.
621 // Moved from misc.h due to circular depenedencies.
622 #define CRYPTOPP_UNUSED(x) ((void)x)
623 
624 // ***************** C++11 related ********************
625 
626 // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx.
627 // Intel and C++11 language features, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
628 // GCC and C++11 language features, http://gcc.gnu.org/projects/cxx0x.html
629 // Clang and C++11 language features, http://clang.llvm.org/cxx_status.html
630 #if (_MSC_VER >= 1600) || (__cplusplus >= 201103L)
631 # define CRYPTOPP_CXX11 1
632 #endif
633 
634 // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't
635 // test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same
636 // way. However, modern standard libraries have <forward_list>, so we test for it instead.
637 // Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions.
638 // TODO: test under Xcode 3, where g++ is really g++.
639 #if defined(__APPLE__) && defined(__clang__)
640 # if !(defined(__has_include) && __has_include(<forward_list>))
641 # undef CRYPTOPP_CXX11
642 # endif
643 #endif
644 
645 // C++11 or C++14 is available
646 #if defined(CRYPTOPP_CXX11)
647 
648 // alignof/alignas: MS at VS2013 (19.00); GCC at 4.8; Clang at 3.3; and Intel 15.0.
649 #if (CRYPTOPP_MSC_VERSION >= 1900)
650 # define CRYPTOPP_CXX11_ALIGNAS 1
651 # define CRYPTOPP_CXX11_ALIGNOF 1
652 #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
653 # define CRYPTOPP_CXX11_ALIGNAS 1
654 # define CRYPTOPP_CXX11_ALIGNOF 1
655 #elif defined(__clang__)
656 # if __has_feature(cxx_alignof)
657 # define CRYPTOPP_CXX11_ALIGNAS 1
658 # define CRYPTOPP_CXX11_ALIGNOF 1
659 # endif
660 #elif (CRYPTOPP_GCC_VERSION >= 40800)
661 # define CRYPTOPP_CXX11_ALIGNAS 1
662 # define CRYPTOPP_CXX11_ALIGNOF 1
663 #endif // alignof/alignas
664 
665 // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; and Intel 14.0.
666 #if (CRYPTOPP_MSC_VERSION >= 1900)
667 # define CRYPTOPP_CXX11_NOEXCEPT 1
668 #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1400)
669 # define CRYPTOPP_CXX11_NOEXCEPT 1
670 #elif defined(__clang__)
671 # if __has_feature(cxx_noexcept)
672 # define CRYPTOPP_CXX11_NOEXCEPT 1
673 # endif
674 #elif (CRYPTOPP_GCC_VERSION >= 40600)
675 # define CRYPTOPP_CXX11_NOEXCEPT 1
676 #endif // noexcept compilers
677 
678 // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; and Intel 12.1.
679 #if (CRYPTOPP_MSC_VERSION >= 1800)
680 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
681 #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1210)
682 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
683 #elif defined(__clang__)
684 # if __has_feature(cxx_variadic_templates)
685 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
686 # endif
687 #elif (CRYPTOPP_GCC_VERSION >= 40300)
688 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
689 #endif // variadic templates
690 
691 // TODO: Emplacement, R-values and Move semantics
692 // Needed because we are catching warnings with GCC and MSC
693 
694 #endif // CRYPTOPP_CXX11
695 
696 #if defined(CRYPTOPP_CXX11_NOEXCEPT)
697 # define CRYPTOPP_THROW noexcept(false)
698 # define CRYPTOPP_NO_THROW noexcept(true)
699 #else
700 # define CRYPTOPP_THROW
701 # define CRYPTOPP_NO_THROW
702 #endif // CRYPTOPP_CXX11_NOEXCEPT
703 
704 // OK to comment the following out, but please report it so we can fix it.
705 #if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
706 # error "std::uncaught_exception is not available. This is likely a configuration error."
707 #endif
708 
709 #endif
Crypto++ library namespace.