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