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