Crypto++  7.0
Free C++ class library of cryptographic schemes
config.h
Go to the documentation of this file.
1 // config.h - originally 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(CRYPTOPP_LITTLE_ENDIAN) && !defined(CRYPTOPP_BIG_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 CRYPTOPP_BIG_ENDIAN 1
14 #endif
15 
16 // define this if running on a little-endian CPU
17 // big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not defined
18 #if !defined(CRYPTOPP_BIG_ENDIAN) && !defined(CRYPTOPP_LITTLE_ENDIAN)
19 # define CRYPTOPP_LITTLE_ENDIAN 1
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(CRYPTOPP_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
25 # error "CRYPTOPP_BIG_ENDIAN is set, but __BYTE_ORDER__ is not __ORDER_BIG_ENDIAN__"
26 #endif
27 #if defined(CRYPTOPP_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
28 # error "CRYPTOPP_LITTLE_ENDIAN is set, but __BYTE_ORDER__ is not __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
48 // targeting Windows 8 or above.
49 #if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI)
50 # if !defined(_USING_V110_SDK71_) && ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/))
51 # define USE_MS_CNGAPI
52 # else
53 # define USE_MS_CRYPTOAPI
54 # endif
55 #endif
56 
57 // Define this to disable ASM, intrinsics and built-ins. The library will be
58 // compiled using C++ only. The library code will not include SSE2 (and
59 // above), NEON, Aarch32, Aarch64, Power4, Power7 or Power8. Note the compiler
60 // may use higher ISAs depending on compiler options, but the library will not
61 // explictly use the ISAs.
62 // #define CRYPTOPP_DISABLE_ASM 1
63 
64 // Define CRYPTOPP_NO_CXX11 to avoid C++11 related features shown at the
65 // end of this file. Some compilers and standard C++ headers advertise C++11
66 // but they are really just C++03 with some additional C++11 headers and
67 // non-conforming classes. You might also consider `-std=c++03` or
68 // `-std=gnu++03`, but they are required options when building the library
69 // and all programs. CRYPTOPP_NO_CXX11 is probably easier to manage but it may
70 // cause -Wterminate warnings under GCC. MSVC++ has a similar warning.
71 // Also see https://github.com/weidai11/cryptopp/issues/529
72 // #define CRYPTOPP_NO_CXX11 1
73 
74 // Define CRYPTOPP_NO_CXX17 to avoid C++17 related features shown at the end of
75 // this file. At the moment it should only affect std::uncaught_exceptions.
76 // #define CRYPTOPP_NO_CXX17 1
77 
78 // Define this to allow unaligned data access. If you experience a break with
79 // GCC at -O3, you should immediately suspect unaligned data accesses.
80 // #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS 1
81 
82 // ***************** Less Important Settings ***************
83 
84 // Library version macro. Since this macro is in a header, it reflects
85 // the version of the library the headers came from. It is not
86 // necessarily the version of the library built as a shared object if
87 // versions are inadvertently mixed and matched.
88 #define CRYPTOPP_VERSION 700
89 
90 // Define this if you want to set a prefix for TestData/ and TestVectors/
91 // Be mindful of the trailing slash since its simple concatenation.
92 // g++ ... -DCRYPTOPP_DATA_DIR='"/tmp/cryptopp_test/share/"'
93 #ifndef CRYPTOPP_DATA_DIR
94 # define CRYPTOPP_DATA_DIR ""
95 #endif
96 
97 // Define this if you want or need the library's memcpy_s and memmove_s.
98 // See http://github.com/weidai11/cryptopp/issues/28.
99 // #if !defined(CRYPTOPP_WANT_SECURE_LIB)
100 // # define CRYPTOPP_WANT_SECURE_LIB
101 // #endif
102 
103 // File system code to write to GZIP archive.
104 // http://www.gzip.org/format.txt
105 #if !defined(GZIP_OS_CODE)
106 # if defined(__macintosh__)
107 # define GZIP_OS_CODE 7
108 # elif defined(__unix__) || defined(__linux__)
109 # define GZIP_OS_CODE 3
110 # else
111 # define GZIP_OS_CODE 0
112 # endif
113 #endif
114 
115 // Try this if your CPU has 256K internal cache or a slow multiply instruction
116 // and you want a (possibly) faster IDEA implementation using log tables
117 // #define IDEA_LARGECACHE
118 
119 // Define this if, for the linear congruential RNG, you want to use
120 // the original constants as specified in S.K. Park and K.W. Miller's
121 // CACM paper.
122 // #define LCRNG_ORIGINAL_NUMBERS
123 
124 // Define this if you want Integer's operator<< to honor std::showbase (and
125 // std::noshowbase). If defined, Integer will use a suffix of 'b', 'o', 'h'
126 // or '.' (the last for decimal) when std::showbase is in effect. If
127 // std::noshowbase is set, then the suffix is not added to the Integer. If
128 // not defined, existing behavior is preserved and Integer will use a suffix
129 // of 'b', 'o', 'h' or '.' (the last for decimal).
130 // #define CRYPTOPP_USE_STD_SHOWBASE
131 
132 // Define this if ARMv8 shifts are slow. ARM Cortex-A53 and Cortex-A57 shift
133 // operation perform poorly, so NEON and ASIMD code that relies on shifts
134 // or rotates often performs worse than C/C++ code. Also see
135 // http://github.com/weidai11/cryptopp/issues/367.
136 #define CRYPTOPP_SLOW_ARMV8_SHIFT 1
137 
138 // Define this if you want to decouple AlgorithmParameters and Integer
139 // The decoupling should make it easier for the linker to remove Integer
140 // related code for those who do not need Integer, and avoid a potential
141 // race during AssignIntToInteger pointer initialization. Also
142 // see http://github.com/weidai11/cryptopp/issues/389.
143 // #define CRYPTOPP_NO_ASSIGN_TO_INTEGER
144 
145 // choose which style of sockets to wrap (mostly useful for MinGW which has both)
146 #if !defined(NO_BERKELEY_STYLE_SOCKETS) && !defined(PREFER_BERKELEY_STYLE_SOCKETS)
147 # define PREFER_BERKELEY_STYLE_SOCKETS
148 #endif
149 
150 // #if !defined(NO_WINDOWS_STYLE_SOCKETS) && !defined(PREFER_WINDOWS_STYLE_SOCKETS)
151 // # define PREFER_WINDOWS_STYLE_SOCKETS
152 // #endif
153 
154 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
155 #define CRYPTOPP_RIJNDAEL_NAME "AES"
156 
157 // CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT
158 // raises a SIGTRAP (Unix) or calls DebugBreak() (Windows). CRYPTOPP_ASSERT
159 // is only in effect when CRYPTOPP_DEBUG, DEBUG or _DEBUG is defined. Unlike
160 // Posix assert, CRYPTOPP_ASSERT is not affected by NDEBUG (or failure to
161 // define it).
162 // Also see http://github.com/weidai11/cryptopp/issues/277, CVE-2016-7420
163 #if (defined(DEBUG) || defined(_DEBUG)) && !defined(CRYPTOPP_DEBUG)
164 # define CRYPTOPP_DEBUG 1
165 #endif
166 
167 // ***************** Important Settings Again ********************
168 // But the defaults should be ok.
169 
170 // namespace support is now required
171 #ifdef NO_NAMESPACE
172 # error namespace support is now required
173 #endif
174 
175 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
176 // Document the namespce exists. Put it here before CryptoPP is undefined below.
177 /// \namespace CryptoPP
178 /// \brief Crypto++ library namespace
179 /// \details Nearly all classes are located in the CryptoPP namespace. Within
180 /// the namespace, there are two additional namespaces.
181 /// <ul>
182 /// <li>Name - namespace for names used with \p NameValuePairs and documented in argnames.h
183 /// <li>NaCl - namespace for NaCl library functions like crypto_box, crypto_box_open, crypto_sign, and crypto_sign_open
184 /// <li>Test - namespace for testing and benchmarks classes
185 /// <li>Weak - namespace for weak and wounded algorithms, like ARC4, MD5 and Pananma
186 /// </ul>
187 namespace CryptoPP { }
188 // Bring in the symbols found in the weak namespace; and fold Weak1 into Weak
189 # define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
190 # define Weak1 Weak
191 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
192 # define CryptoPP
193 # define NAMESPACE_BEGIN(x)
194 # define NAMESPACE_END
195 // Get Doxygen to generate better documentation for these typedefs
196 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
197 // Make "protected" "private" so the functions and members are not documented
198 # define protected private
199 #else
200 # define NAMESPACE_BEGIN(x) namespace x {
201 # define NAMESPACE_END }
202 # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
203 #endif
204 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
205 #define ANONYMOUS_NAMESPACE_END }
206 #define USING_NAMESPACE(x) using namespace x;
207 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
208 #define DOCUMENTED_NAMESPACE_END }
209 
210 // What is the type of the third parameter to bind?
211 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
212 // Unfortunately there is no way to tell whether or not socklen_t is defined.
213 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
214 #ifndef TYPE_OF_SOCKLEN_T
215 # if defined(_WIN32) || defined(__CYGWIN__)
216 # define TYPE_OF_SOCKLEN_T int
217 # else
218 # define TYPE_OF_SOCKLEN_T ::socklen_t
219 # endif
220 #endif
221 
222 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
223 # define __USE_W32_SOCKETS
224 #endif
225 
226 // Originally in global namespace to avoid ambiguity with other byte typedefs.
227 // Moved to Crypto++ namespace due to C++17, std::byte and potential compile problems. Also see
228 // http://www.cryptopp.com/wiki/std::byte and http://github.com/weidai11/cryptopp/issues/442
229 // typedef unsigned char byte;
230 #define CRYPTOPP_NO_GLOBAL_BYTE 1
231 
232 NAMESPACE_BEGIN(CryptoPP)
233 
234 // Signed words added at Issue 609 for early versions of and Visual Studio and
235 // the NaCl gear. Also see https://github.com/weidai11/cryptopp/issues/609.
236 
237 typedef unsigned char byte;
238 typedef unsigned short word16;
239 typedef unsigned int word32;
240 
241 typedef signed char sbyte;
242 typedef signed short sword16;
243 typedef signed int sword32;
244 
245 #if defined(_MSC_VER) || defined(__BORLANDC__)
246  typedef signed __int64 sword64;
247  typedef unsigned __int64 word64;
248  #define SW64LIT(x) x##i64
249  #define W64LIT(x) x##ui64
250 #elif (_LP64 || __LP64__)
251  typedef signed long sword64;
252  typedef unsigned long word64;
253  #define SW64LIT(x) x##L
254  #define W64LIT(x) x##UL
255 #else
256  typedef signed long long sword64;
257  typedef unsigned long long word64;
258  #define SW64LIT(x) x##LL
259  #define W64LIT(x) x##ULL
260 #endif
261 
262 // define large word type, used for file offsets and such
263 typedef word64 lword;
264 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
265 
266 // Clang pretends to be VC++, too.
267 // See http://github.com/weidai11/cryptopp/issues/147
268 #if defined(_MSC_VER) && defined(__clang__)
269 # error: "Unsupported configuration"
270 #endif
271 
272 #ifdef __GNUC__
273  #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
274 #endif
275 
276 #if defined(__xlc__) || defined(__xlC__)
277  #define CRYPTOPP_XLC_VERSION ((__xlC__ / 256) * 10000 + (__xlC__ % 256) * 100)
278 #endif
279 
280 // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
281 #if defined(__clang__) && defined(__apple_build_version__)
282  #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
283  #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
284 #elif defined(__clang__)
285  #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
286  #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
287 #endif
288 
289 #ifdef _MSC_VER
290  #define CRYPTOPP_MSC_VERSION (_MSC_VER)
291 #endif
292 
293 // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
294 #if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
295  #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
296 #endif
297 
298 // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232. Still broke as of Clang 3.9.
299 // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
300 #if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION <= 200000)) || \
301  (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 200000)) || \
302  defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
303  #define CRYPTOPP_DISABLE_INTEL_ASM 1
304 #endif
305 
306 // define hword, word, and dword. these are used for multiprecision integer arithmetic
307 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
308 #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__))
309  typedef word32 hword;
310  typedef word64 word;
311 #else
312  #define CRYPTOPP_NATIVE_DWORD_AVAILABLE 1
313  #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
314  #if ((CRYPTOPP_GCC_VERSION >= 30400) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30000) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300)) && (__SIZEOF_INT128__ >= 16)
315  // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
316  // GCC 4.8.3 and bad uint128_t ops on PPC64/POWER7 (Issue 421)
317  // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
318  typedef word32 hword;
319  typedef word64 word;
320  typedef __uint128_t dword;
321  typedef __uint128_t word128;
322  #define CRYPTOPP_WORD128_AVAILABLE 1
323  #else
324  // 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
325  typedef word16 hword;
326  typedef word32 word;
327  typedef word64 dword;
328  #endif
329  #else
330  // being here means the native register size is probably 32 bits or less
331  #define CRYPTOPP_BOOL_SLOW_WORD64 1
332  typedef word16 hword;
333  typedef word32 word;
334  typedef word64 dword;
335  #endif
336 #endif
337 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
338  #define CRYPTOPP_BOOL_SLOW_WORD64 0
339 #endif
340 
341 const unsigned int WORD_SIZE = sizeof(word);
342 const unsigned int WORD_BITS = WORD_SIZE * 8;
343 
344 NAMESPACE_END
345 
346 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
347  // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
348  // Also see http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size.
349  #if defined(_M_X64) || defined(__x86_64__) || defined(__arm64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(_ARCH_PPC64)
350  #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
351  #else
352  // L1 cache line size is 32 on Pentium III and earlier
353  #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
354  #endif
355 #endif
356 
357 #ifndef CRYPTOPP_ALIGN_DATA
358  #if defined(_MSC_VER)
359  #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
360  #elif defined(__GNUC__)
361  #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
362  #else
363  #define CRYPTOPP_ALIGN_DATA(x)
364  #endif
365 #endif
366 
367 // The section attribute attempts to initialize CPU flags to avoid Valgrind findings above -O1
368 #if ((defined(__MACH__) && defined(__APPLE__)) && ((CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70100) || (CRYPTOPP_GCC_VERSION >= 40300)))
369  #define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data")))
370 #elif (defined(__ELF__) && (CRYPTOPP_GCC_VERSION >= 40300))
371  #define CRYPTOPP_SECTION_INIT __attribute__((section ("nocommon")))
372 #else
373  #define CRYPTOPP_SECTION_INIT
374 #endif
375 
376 #if defined(_MSC_VER) || defined(__fastcall)
377  #define CRYPTOPP_FASTCALL __fastcall
378 #else
379  #define CRYPTOPP_FASTCALL
380 #endif
381 
382 #ifdef _MSC_VER
383 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
384 #else
385 #define CRYPTOPP_NO_VTABLE
386 #endif
387 
388 #ifdef _MSC_VER
389  // 4127: conditional expression is constant
390  // 4231: nonstandard extension used : 'extern' before template explicit instantiation
391  // 4250: dominance
392  // 4251: member needs to have dll-interface
393  // 4275: base needs to have dll-interface
394  // 4505: unreferenced local function
395  // 4512: assignment operator not generated
396  // 4660: explicitly instantiating a class that's already implicitly instantiated
397  // 4661: no suitable definition provided for explicit template instantiation request
398  // 4786: identifier was truncated in debug information
399  // 4355: 'this' : used in base member initializer list
400  // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
401 # pragma warning(disable: 4127 4512 4661 4910)
402  // Security related, possible defects
403  // http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
404 # pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
405 #endif
406 
407 #ifdef __BORLANDC__
408 // 8037: non-const function called for const object. needed to work around BCB2006 bug
409 # pragma warn -8037
410 #endif
411 
412 // [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
413 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
414 # pragma GCC diagnostic ignored "-Wunknown-pragmas"
415 # pragma GCC diagnostic ignored "-Wunused-function"
416 #endif
417 
418 // You may need to force include a C++ header on Android when using STLPort to ensure
419 // _STLPORT_VERSION is defined: CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -include iosfwd"
420 // TODO: Figure out C++17 and lack of std::uncaught_exception
421 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)))
422 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
423 #endif
424 
425 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
426 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
427 #endif
428 
429 // ***************** Platform and CPU features ********************
430 
431 // Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
432 // Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
433 // the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang.
434 #if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
435  #define CRYPTOPP_BOOL_X32 1
436 #endif
437 
438 // see http://predef.sourceforge.net/prearch.html
439 #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
440  #define CRYPTOPP_BOOL_X86 1
441 #endif
442 
443 #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
444  #define CRYPTOPP_BOOL_X64 1
445 #endif
446 
447 // Undo the ASM and Intrinsic related defines due to X32.
448 #if CRYPTOPP_BOOL_X32
449 # undef CRYPTOPP_BOOL_X64
450 # undef CRYPTOPP_X64_ASM_AVAILABLE
451 # undef CRYPTOPP_X64_MASM_AVAILABLE
452 #endif
453 
454 // Microsoft plans to support ARM-64, but its not clear how to detect it.
455 // TODO: Add MSC_VER and ARM-64 platform define when available
456 #if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
457  #define CRYPTOPP_BOOL_ARM64 1
458 #elif defined(__arm__) || defined(__aarch32__) || defined(_M_ARM)
459  #define CRYPTOPP_BOOL_ARM32 1
460 #endif
461 
462 // AltiVec and Power8 crypto
463 #if defined(__powerpc64__) || defined(_ARCH_PPC64)
464  #define CRYPTOPP_BOOL_PPC64 1
465 #elif defined(__powerpc__) || defined(_ARCH_PPC)
466  #define CRYPTOPP_BOOL_PPC32 1
467 #endif
468 
469 #if defined(_MSC_VER) || defined(__BORLANDC__)
470 # define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 1
471 #else
472 # define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 1
473 #endif
474 
475 // ***************** IA32 CPU features ********************
476 
477 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
478 
479 // Apple Clang prior to 5.0 cannot handle SSE2
480 #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
481 # define CRYPTOPP_DISABLE_ASM
482 #endif
483 
484 // Sun Studio 12 provides GCC inline assembly, http://blogs.oracle.com/x86be/entry/gcc_style_asm_inlining_support
485 // We can enable SSE2 for Sun Studio in the makefile with -D__SSE2__, but users may not compile with it.
486 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(__SSE2__) && defined(__x86_64__) && (__SUNPRO_CC >= 0x5100)
487 # define __SSE2__ 1
488 #endif
489 
490 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
491  // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
492  #define CRYPTOPP_X86_ASM_AVAILABLE 1
493 
494  #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
495  #define CRYPTOPP_SSE2_ASM_AVAILABLE 1
496  #endif
497 
498  #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || defined(__SSSE3__))
499  #define CRYPTOPP_SSSE3_ASM_AVAILABLE 1
500  #endif
501 #endif
502 
503 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
504  #define CRYPTOPP_X64_MASM_AVAILABLE 1
505 #endif
506 
507 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
508  #define CRYPTOPP_X64_ASM_AVAILABLE 1
509 #endif
510 
511 // 32-bit SunCC does not enable SSE2 by default.
512 #if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__))
513  #define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1
514 #endif
515 
516 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSSE3)
517 # if defined(__SSSE3__) || (_MSC_VER >= 1500) || \
518  (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
519  (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000)
520  #define CRYPTOPP_SSSE3_AVAILABLE 1
521 # endif
522 #endif
523 
524 // Intrinsics availible in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and
525 // MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx)
526 // SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4.
527 #if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
528  (defined(__SSE4_1__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
529  (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
530  (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
531  #define CRYPTOPP_SSE41_AVAILABLE 1
532 #endif
533 
534 #if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
535  (defined(__SSE4_2__) || (CRYPTOPP_MSC_VERSION >= 1500) || (__SUNPRO_CC >= 0x5110) || \
536  (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || \
537  (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
538  #define CRYPTOPP_SSE42_AVAILABLE 1
539 #endif
540 
541 // Couple to CRYPTOPP_DISABLE_AES, but use CRYPTOPP_CLMUL_AVAILABLE so we can selectively
542 // disable for misbehaving platofrms and compilers, like Solaris or some Clang.
543 #if defined(CRYPTOPP_DISABLE_AES)
544  #define CRYPTOPP_DISABLE_CLMUL 1
545 #endif
546 
547 // Requires Sun Studio 12.3 (SunCC 0x5120) in theory.
548 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_CLMUL) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
549  (defined(__PCLMUL__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
550  (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
551  (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
552  #define CRYPTOPP_CLMUL_AVAILABLE 1
553 #endif
554 
555 // Requires Sun Studio 12.3 (SunCC 0x5120)
556 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_AES) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
557  (defined(__AES__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
558  (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
559  (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
560  #define CRYPTOPP_AESNI_AVAILABLE 1
561 #endif
562 
563 // Guessing at SHA for SunCC. Its not in Sun Studio 12.6. Also see
564 // http://stackoverflow.com/questions/45872180/which-xarch-for-sha-extensions-on-solaris
565 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SHA) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
566  (defined(__SHA__) || (CRYPTOPP_MSC_VERSION >= 1900) || (__SUNPRO_CC >= 0x5160) || \
567  (CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1300) || \
568  (CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50100))
569  #define CRYPTOPP_SHANI_AVAILABLE 1
570 #endif
571 
572 #endif // X86, X32, X64
573 
574 // ***************** ARM CPU features ********************
575 
576 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
577 
578 // Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains.
579 // Android still uses ARMv5 and ARMv6 so we have to be conservative when enabling NEON.
580 #if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
581 # if defined(__ARM_NEON) || defined(__ARM_NEON_FP) || defined(__ARM_FEATURE_NEON) || \
582  (__ARM_ARCH >= 7) || (CRYPTOPP_MSC_VERSION >= 1700)
583 # define CRYPTOPP_ARM_NEON_AVAILABLE 1
584 # endif
585 #endif
586 
587 // ARMv8 and ASIMD, which is NEON. It is part of ARMv8 core.
588 // TODO: Add MSC_VER and ARM-64 platform define when available
589 #if !defined(CRYPTOPP_ARM_ASIMD_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
590 # if defined(__aarch32__) || defined(__aarch64__) || (CRYPTOPP_MSC_VERSION >= 1910)
591 # define CRYPTOPP_ARM_ASIMD_AVAILABLE 1
592 # endif
593 #endif
594 
595 // Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
596 // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
597 // Microsoft plans to support ARM-64, but its not clear how to detect it.
598 // TODO: Add Android ARMv8 support for CRC32
599 // TODO: Add MSC_VER and ARM-64 platform define when available
600 #if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__apple_build_version__) && !defined(__ANDROID__)
601 # if (defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_MSC_VERSION >= 1910) || \
602  defined(__aarch32__) || defined(__aarch64__))
603 # define CRYPTOPP_ARM_CRC32_AVAILABLE 1
604 # endif
605 #endif
606 
607 // Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
608 // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
609 // Microsoft plans to support ARM-64, but its not clear how to detect it.
610 // TODO: Add Android ARMv8 support for PMULL
611 // TODO: Add MSC_VER and ARM-64 platform define when available
612 #if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__apple_build_version__) && !defined(__ANDROID__)
613 # if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
614  defined(__aarch32__) || defined(__aarch64__)
615 # define CRYPTOPP_ARM_PMULL_AVAILABLE 1
616 # endif
617 #endif
618 
619 // Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
620 // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
621 // Microsoft plans to support ARM-64, but its not clear how to detect it.
622 // TODO: Add Android ARMv8 support for AES and SHA
623 // TODO: Add MSC_VER and ARM-64 platform define when available
624 #if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__ANDROID__)
625 # if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
626  defined(__aarch32__) || defined(__aarch64__)
627 # define CRYPTOPP_ARM_AES_AVAILABLE 1
628 # endif
629 #endif
630 
631 // Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
632 // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
633 // Microsoft plans to support ARM-64, but its not clear how to detect it.
634 // TODO: Add Android ARMv8 support for AES and SHA
635 // TODO: Add MSC_VER and ARM-64 platform define when available
636 #if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__ANDROID__)
637 # if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
638  defined(__aarch32__) || defined(__aarch64__)
639 # define CRYPTOPP_ARM_SHA_AVAILABLE 1
640 # endif
641 #endif
642 
643 // Limit the <arm_acle.h> include.
644 #if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
645 # define CRYPTOPP_ARM_ACLE_AVAILABLE 1
646 #endif
647 
648 // Man, this is borked. Apple Clang defines __ARM_ACLE but then fails
649 // to compile with "fatal error: 'arm_acle.h' file not found"
650 #if defined(__ANDROID__) || defined(ANDROID) || defined(__APPLE__)
651 # undef CRYPTOPP_ARM_ACLE_AVAILABLE
652 #endif
653 
654 #endif // ARM32, ARM64
655 
656 // ***************** AltiVec and Power8 ********************
657 
658 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
659 
660 #if defined(CRYPTOPP_DISABLE_ALTIVEC) || defined(CRYPTOPP_DISABLE_ASM)
661 # undef CRYPTOPP_DISABLE_ALTIVEC
662 # undef CRYPTOPP_DISABLE_POWER7
663 # undef CRYPTOPP_DISABLE_POWER8
664 # define CRYPTOPP_DISABLE_ALTIVEC 1
665 # define CRYPTOPP_DISABLE_POWER7 1
666 # define CRYPTOPP_DISABLE_POWER8 1
667 #endif
668 
669 // An old Apple G5 with GCC 4.01 has AltiVec, but its only Power4 or so.
670 #if !defined(CRYPTOPP_ALTIVEC_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ALTIVEC)
671 # if defined(_ARCH_PWR4) || defined(__ALTIVEC__) || \
672  (CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40001)
673 # define CRYPTOPP_ALTIVEC_AVAILABLE 1
674 # endif
675 #endif
676 
677 // We need Power5 for 'vector unsigned long long'
678 #if !defined(CRYPTOPP_POWER5_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER5) && defined(CRYPTOPP_ALTIVEC_AVAILABLE)
679 # if defined(_ARCH_PWR5) || (CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40100)
680 # define CRYPTOPP_POWER5_AVAILABLE 1
681 # endif
682 #endif
683 
684 // We need Power7 for unaligned loads and stores
685 #if !defined(CRYPTOPP_POWER7_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER7) && defined(CRYPTOPP_ALTIVEC_AVAILABLE)
686 # if defined(_ARCH_PWR7) || (CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40100)
687 # define CRYPTOPP_POWER7_AVAILABLE 1
688 # endif
689 #endif
690 
691 // We need Power8 for in-core crypto
692 #if !defined(CRYPTOPP_POWER8_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8) && defined(CRYPTOPP_POWER7_AVAILABLE)
693 # if defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || (CRYPTOPP_GCC_VERSION >= 40800)
694 # define CRYPTOPP_POWER8_AVAILABLE 1
695 # endif
696 #endif
697 
698 #if !defined(CRYPTOPP_POWER8_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8_AES) && defined(CRYPTOPP_POWER8_AVAILABLE)
699 # if defined(__CRYPTO__) || defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || (CRYPTOPP_GCC_VERSION >= 40800)
700 # define CRYPTOPP_POWER8_AES_AVAILABLE 1
701 # define CRYPTOPP_POWER8_SHA_AVAILABLE 1
702 //# define CRYPTOPP_POWER8_CRC_AVAILABLE 1
703 # endif
704 #endif
705 
706 #endif // PPC, PPC64
707 
708 // ***************** Miscellaneous ********************
709 
710 // Nearly all Intel's and AMD's have SSE. Enable it independent of SSE ASM and intrinscs
711 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) && !defined(CRYPTOPP_DISABLE_ASM)
712  #define CRYPTOPP_BOOL_ALIGN16 1
713 #else
714  #define CRYPTOPP_BOOL_ALIGN16 0
715 #endif
716 
717 // How to allocate 16-byte aligned memory (for SSE2)
718 // posix_memalign see https://forum.kde.org/viewtopic.php?p=66274
719 #if defined(_MSC_VER)
720  #define CRYPTOPP_MM_MALLOC_AVAILABLE
721 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
722  #define CRYPTOPP_MEMALIGN_AVAILABLE
723 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
724  #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
725 #elif (defined(_GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) && (_POSIX_ADVISORY_INFO > 0)
726  #define CRYPTOPP_POSIX_MEMALIGN_AVAILABLE
727 #else
728  #define CRYPTOPP_NO_ALIGNED_ALLOC
729 #endif
730 
731 // how to disable inlining
732 #if defined(_MSC_VER)
733 # define CRYPTOPP_NOINLINE_DOTDOTDOT
734 # define CRYPTOPP_NOINLINE __declspec(noinline)
735 #elif defined(__xlc__) || defined(__xlC__)
736 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
737 # define CRYPTOPP_NOINLINE __attribute__((noinline))
738 #elif defined(__GNUC__)
739 # define CRYPTOPP_NOINLINE_DOTDOTDOT
740 # define CRYPTOPP_NOINLINE __attribute__((noinline))
741 #else
742 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
743 # define CRYPTOPP_NOINLINE
744 #endif
745 
746 // How to declare class constants
747 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) || defined(__BORLANDC__)
748 # define CRYPTOPP_CONSTANT(x) static const int x;
749 #else
750 # define CRYPTOPP_CONSTANT(x) enum {x};
751 #endif
752 
753 // How to disable CPU feature probing. We determine machine
754 // capabilities by performing an os/platform *query* first,
755 // like getauxv(). If the *query* fails, we move onto a
756 // cpu *probe*. The cpu *probe* tries to exeute an instruction
757 // and then catches a SIGILL on Linux or the exception
758 // EXCEPTION_ILLEGAL_INSTRUCTION on Windows. Some OSes
759 // fail to hangle a SIGILL gracefully, like Apple OSes. Apple
760 // machines corrupt memory and variables around the probe.
761 #if defined(__APPLE__)
762 # define CRYPTOPP_NO_CPU_FEATURE_PROBES 1
763 #endif
764 
765 // ***************** Initialization and Constructor priorities ********************
766 
767 // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
768 // Under GCC, the library uses init_priority attribute in the range
769 // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
770 // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". The platforms
771 // with gaps are Apple and Sun because they require linker scripts. Apple and
772 // Sun will use the library's Singletons to initialize and acquire resources.
773 // Also see http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco
774 #ifndef CRYPTOPP_INIT_PRIORITY
775 # define CRYPTOPP_INIT_PRIORITY 250
776 #endif
777 
778 // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
779 // and managing C++ static object creation. It is guaranteed not to conflict with
780 // values used by (or would be used by) the Crypto++ library.
781 #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0)
782 # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101)
783 #else
784 # define CRYPTOPP_USER_PRIORITY 350
785 #endif
786 
787 // Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.
788 #if (CRYPTOPP_INIT_PRIORITY > 0) && !(defined(NO_OS_DEPENDENCE) || defined(__APPLE__) || defined(__sun__))
789 # if (CRYPTOPP_GCC_VERSION >= 30000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 800)
790 # define HAVE_GCC_INIT_PRIORITY 1
791 # elif (CRYPTOPP_MSC_VERSION >= 1310)
792 # define HAVE_MSC_INIT_PRIORITY 1
793 # endif
794 #endif // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun
795 
796 // ***************** determine availability of OS features ********************
797 
798 #ifndef NO_OS_DEPENDENCE
799 
800 #if defined(_WIN32) || defined(__CYGWIN__)
801 #define CRYPTOPP_WIN32_AVAILABLE
802 #endif
803 
804 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
805 #define CRYPTOPP_UNIX_AVAILABLE
806 #endif
807 
808 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
809 #define CRYPTOPP_BSD_AVAILABLE
810 #endif
811 
812 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
813 # define HIGHRES_TIMER_AVAILABLE
814 #endif
815 
816 #ifdef CRYPTOPP_WIN32_AVAILABLE
817 # if !defined(WINAPI_FAMILY)
818 # define THREAD_TIMER_AVAILABLE
819 # elif defined(WINAPI_FAMILY)
820 # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
821 # define THREAD_TIMER_AVAILABLE
822 # endif
823 # endif
824 #endif
825 
826 #ifdef CRYPTOPP_UNIX_AVAILABLE
827 # define HAS_BERKELEY_STYLE_SOCKETS
828 # define SOCKETS_AVAILABLE
829 #endif
830 
831 // Sockets are only available under Windows Runtime desktop partition apps (despite the MSDN literature)
832 #ifdef CRYPTOPP_WIN32_AVAILABLE
833 # define HAS_WINDOWS_STYLE_SOCKETS
834 # if !defined(WINAPI_FAMILY)
835 # define SOCKETS_AVAILABLE
836 # elif defined(WINAPI_FAMILY)
837 # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
838 # define SOCKETS_AVAILABLE
839 # endif
840 # endif
841 #endif
842 
843 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
844 # define USE_WINDOWS_STYLE_SOCKETS
845 #else
846 # define USE_BERKELEY_STYLE_SOCKETS
847 #endif
848 
849 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(SOCKETS_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
850 # define WINDOWS_PIPES_AVAILABLE
851 #endif
852 
853 
854 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
855 # define NONBLOCKING_RNG_AVAILABLE
856 # define BLOCKING_RNG_AVAILABLE
857 # define OS_RNG_AVAILABLE
858 # define HAS_PTHREADS
859 # define THREADS_AVAILABLE
860 #endif
861 
862 // Early IBM XL C on AIX fails to link due to missing pthread gear
863 #if defined(_AIX) && defined(__xlC__)
864 # undef HAS_PTHREADS
865 # undef THREADS_AVAILABLE
866 #endif
867 
868 // Cygwin/Newlib requires _XOPEN_SOURCE=600
869 #if defined(CRYPTOPP_UNIX_AVAILABLE)
870 # define UNIX_SIGNALS_AVAILABLE 1
871 #endif
872 
873 #ifdef CRYPTOPP_WIN32_AVAILABLE
874 # if !defined(WINAPI_FAMILY)
875 # define HAS_WINTHREADS
876 # define THREADS_AVAILABLE
877 # define NONBLOCKING_RNG_AVAILABLE
878 # define OS_RNG_AVAILABLE
879 # elif defined(WINAPI_FAMILY)
880 # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
881 # define HAS_WINTHREADS
882 # define THREADS_AVAILABLE
883 # define NONBLOCKING_RNG_AVAILABLE
884 # define OS_RNG_AVAILABLE
885 # elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
886 # if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
887 # define NONBLOCKING_RNG_AVAILABLE
888 # define OS_RNG_AVAILABLE
889 # endif
890 # endif
891 # endif
892 #endif
893 
894 #endif // NO_OS_DEPENDENCE
895 
896 // ***************** DLL related ********************
897 
898 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
899 
900 #ifdef CRYPTOPP_EXPORTS
901 #define CRYPTOPP_IS_DLL
902 #define CRYPTOPP_DLL __declspec(dllexport)
903 #elif defined(CRYPTOPP_IMPORTS)
904 #define CRYPTOPP_IS_DLL
905 #define CRYPTOPP_DLL __declspec(dllimport)
906 #else
907 #define CRYPTOPP_DLL
908 #endif
909 
910 // C++ makes const internal linkage
911 #define CRYPTOPP_TABLE extern
912 #define CRYPTOPP_API __cdecl
913 
914 #else // not CRYPTOPP_WIN32_AVAILABLE
915 
916 // C++ makes const internal linkage
917 #define CRYPTOPP_TABLE extern
918 #define CRYPTOPP_DLL
919 #define CRYPTOPP_API
920 
921 #endif // CRYPTOPP_WIN32_AVAILABLE
922 
923 #if defined(__MWERKS__)
924 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
925 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
926 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
927 #else
928 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
929 #endif
930 
931 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
932 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
933 #else
934 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
935 #endif
936 
937 #if defined(__MWERKS__)
938 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
939 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
940 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
941 #else
942 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
943 #endif
944 
945 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
946 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
947 #else
948 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
949 #endif
950 
951 // ************** Unused variable ***************
952 
953 // Portable way to suppress warnings.
954 // Moved from misc.h due to circular depenedencies.
955 #define CRYPTOPP_UNUSED(x) ((void)(x))
956 
957 // ************** Deprecated ***************
958 
959 #if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40200)
960 # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg)))
961 #elif (CRYPTOPP_GCC_VERSION)
962 # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated))
963 #else
964 # define CRYPTOPP_DEPRECATED(msg)
965 #endif
966 
967 // ************** Instrumentation ***************
968 
969 // GCC does not support; see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204
970 #if (CRYPTOPP_LLVM_CLANG_VERSION >= 30700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
971 # define CRYPTOPP_NO_SANITIZE(x) __attribute__((no_sanitize(x)))
972 #else
973 # define CRYPTOPP_NO_SANITIZE(x)
974 #endif
975 
976 // ***************** C++11 related ********************
977 
978 // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx
979 // and https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance .
980 // Intel, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
981 // GCC, http://gcc.gnu.org/projects/cxx0x.html
982 // Clang, http://clang.llvm.org/cxx_status.html
983 
984 // Compatibility with non-clang compilers.
985 #ifndef __has_feature
986 # define __has_feature(x) 0
987 #endif
988 
989 #if !defined(CRYPTOPP_NO_CXX11)
990 # if ((_MSC_VER >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION)
991 # define CRYPTOPP_CXX11 1
992 # endif
993 #endif
994 
995 // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't
996 // test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same
997 // way. However, modern standard libraries have <forward_list>, so we test for it instead.
998 // Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions.
999 // TODO: test under Xcode 3, where g++ is really g++.
1000 #if defined(__APPLE__) && defined(__clang__)
1001 # if !(defined(__has_include) && __has_include(<forward_list>))
1002 # undef CRYPTOPP_CXX11
1003 # endif
1004 #endif
1005 
1006 // C++11 or C++14 is available
1007 #if defined(CRYPTOPP_CXX11)
1008 
1009 // atomics: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.1/3.2; Intel 13.0; SunCC 5.14.
1010 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_atomic) || \
1011  (__INTEL_COMPILER >= 1300) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5140)
1012 # define CRYPTOPP_CXX11_ATOMICS 1
1013 #endif // atomics
1014 
1015 // synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 5.13.
1016 // TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang
1017 #if (CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
1018  (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) || (__INTEL_COMPILER >= 1200) || \
1019  (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5130)
1020 // Hack ahead. New GCC compilers like GCC 6 on AIX 7.0 or earlier as well as original MinGW
1021 // don't have the synchronization gear. However, Wakely's test used for Apple does not work
1022 // on the GCC/AIX combination. Another twist is we need other stuff from C++11,
1023 // like no-except destructors. Dumping preprocessors shows the following may
1024 // apply: http://stackoverflow.com/q/14191566/608639.
1025 # include <cstddef>
1026 # if !defined(__GLIBCXX__) || defined(_GLIBCXX_HAS_GTHREADS)
1027 # define CRYPTOPP_CXX11_SYNCHRONIZATION 1
1028 # endif
1029 #endif // synchronization
1030 
1031 // Dynamic Initialization and Destruction with Concurrency ("Magic Statics")
1032 // MS at VS2015 with Vista (19.00); GCC at 4.3; LLVM Clang at 2.9; Apple Clang at 4.0; Intel 11.1; SunCC 5.13.
1033 // Microsoft's implementation only works for Vista and above, so its further
1034 // limited. http://connect.microsoft.com/VisualStudio/feedback/details/1789709
1035 #if (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \
1036  (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || \
1037  (__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
1038 # define CRYPTOPP_CXX11_DYNAMIC_INIT 1
1039 #endif // Dynamic Initialization compilers
1040 
1041 // alignof/alignas: MS at VS2015 (19.00); GCC at 4.8; Clang at 3.0; Intel 15.0; SunCC 5.13.
1042 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignas) || \
1043  (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40800) || (__SUNPRO_CC >= 0x5130)
1044 # define CRYPTOPP_CXX11_ALIGNAS 1
1045 #endif // alignas
1046 
1047 // alignof: MS at VS2015 (19.00); GCC at 4.5; Clang at 2.9; Intel 15.0; SunCC 5.13.
1048 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignof) || \
1049  (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40500) || (__SUNPRO_CC >= 0x5130)
1050 # define CRYPTOPP_CXX11_ALIGNOF 1
1051 #endif // alignof
1052 
1053 // lambdas: MS at VS2012 (17.00); GCC at 4.9; Clang at 3.3; Intel 12.0; SunCC 5.14.
1054 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_lambdas) || \
1055  (__INTEL_COMPILER >= 1200) || (CRYPTOPP_GCC_VERSION >= 40900) || (__SUNPRO_CC >= 0x5140)
1056 # define CRYPTOPP_CXX11_LAMBDA 1
1057 #endif // lambdas
1058 
1059 // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 14.0; SunCC 5.13.
1060 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_noexcept) || \
1061  (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
1062 # define CRYPTOPP_CXX11_NOEXCEPT 1
1063 #endif // noexcept compilers
1064 
1065 // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.
1066 #if (CRYPTOPP_MSC_VERSION >= 1800) || __has_feature(cxx_variadic_templates) || \
1067  (__INTEL_COMPILER >= 1210) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
1068 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
1069 #endif // variadic templates
1070 
1071 // constexpr: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.1; Intel 16.0; SunCC 5.13.
1072 // Intel has mis-supported the feature since at least ICPC 13.00
1073 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_constexpr) || \
1074  (__INTEL_COMPILER >= 1600) || (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
1075 # define CRYPTOPP_CXX11_CONSTEXPR 1
1076 #endif // constexpr compilers
1077 
1078 // strong typed enums: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Intel 14.0; SunCC 5.12.
1079 // Mircorosft and Intel had partial support earlier, but we require full support.
1080 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_strong_enums) || \
1081  (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5120)
1082 # define CRYPTOPP_CXX11_ENUM 1
1083 #endif // constexpr compilers
1084 
1085 // nullptr_t: MS at VS2010 (16.00); GCC at 4.6; Clang at 3.3; Intel 10.0; SunCC 5.13.
1086 #if (CRYPTOPP_MSC_VERSION >= 1600) || __has_feature(cxx_nullptr) || \
1087  (__INTEL_COMPILER >= 1000) || (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
1088 # define CRYPTOPP_CXX11_NULLPTR 1
1089 #endif // nullptr_t compilers
1090 
1091 #endif // CRYPTOPP_CXX11
1092 
1093 // ***************** C++17 related ********************
1094 
1095 // C++17 macro version, https://stackoverflow.com/q/38456127/608639
1096 #if defined(CRYPTOPP_CXX11) && !defined(CRYPTOPP_NO_CXX17)
1097 # if ((_MSC_VER >= 1900) || (__cplusplus >= 201703L)) && !defined(_STLPORT_VERSION)
1098 # define CRYPTOPP_CXX17 1
1099 # endif
1100 #endif
1101 
1102 // C++17 is available
1103 #if defined(CRYPTOPP_CXX17)
1104 
1105 // C++17 uncaught_exceptions: MS at VS2015 (19.00); GCC at 6.0; Clang at 3.5; Intel 18.0.
1106 // Clang and __EXCEPTIONS see http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html
1107 #if defined(__clang__)
1108 # if __EXCEPTIONS && __has_feature(cxx_exceptions)
1109 # define CRYPTOPP_CXX17_EXCEPTIONS 1
1110 # endif
1111 #elif (CRYPTOPP_MSC_VERSION >= 1900) || (__INTEL_COMPILER >= 1800) || (CRYPTOPP_GCC_VERSION >= 60000)
1112 # define CRYPTOPP_CXX17_EXCEPTIONS 1
1113 #endif // uncaught_exceptions compilers
1114 
1115 #endif // CRYPTOPP_CXX17
1116 
1117 // ***************** C++ fixups ********************
1118 
1119 #if defined(CRYPTOPP_CXX11_NOEXCEPT)
1120 # define CRYPTOPP_THROW noexcept(false)
1121 # define CRYPTOPP_NO_THROW noexcept(true)
1122 #else
1123 # define CRYPTOPP_THROW
1124 # define CRYPTOPP_NO_THROW
1125 #endif // CRYPTOPP_CXX11_NOEXCEPT
1126 
1127 // http://stackoverflow.com/a/13867690/608639
1128 #if defined(CRYPTOPP_CXX11_CONSTEXPR)
1129 # define CRYPTOPP_STATIC_CONSTEXPR static constexpr
1130 # define CRYPTOPP_CONSTEXPR constexpr
1131 #else
1132 # define CRYPTOPP_STATIC_CONSTEXPR static
1133 # define CRYPTOPP_CONSTEXPR
1134 #endif // CRYPTOPP_CXX11_CONSTEXPR
1135 
1136 // Hack... CRYPTOPP_ALIGN_DATA is defined earlier, before C++11 alignas availability is determined
1137 #if defined(CRYPTOPP_CXX11_ALIGNAS)
1138 # undef CRYPTOPP_ALIGN_DATA
1139 # define CRYPTOPP_ALIGN_DATA(x) alignas(x)
1140 #endif // CRYPTOPP_CXX11_ALIGNAS
1141 
1142 // Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined
1143 // http://stackoverflow.com/q/35213098/608639
1144 // #if defined(CRYPTOPP_CXX11_CONSTEXPR)
1145 // # undef CRYPTOPP_CONSTANT
1146 // # define CRYPTOPP_CONSTANT(x) constexpr static int x;
1147 // #endif
1148 
1149 // Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined
1150 // http://stackoverflow.com/q/35213098/608639
1151 #if defined(CRYPTOPP_CXX11_ENUM)
1152 # undef CRYPTOPP_CONSTANT
1153 # define CRYPTOPP_CONSTANT(x) enum : int { x };
1154 #elif defined(CRYPTOPP_CXX11_CONSTEXPR)
1155 # undef CRYPTOPP_CONSTANT
1156 # define CRYPTOPP_CONSTANT(x) constexpr static int x;
1157 #endif
1158 
1159 // Hack... C++11 nullptr_t type safety and analysis
1160 #if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)
1161 # define NULLPTR nullptr
1162 #elif !defined(NULLPTR)
1163 # define NULLPTR NULL
1164 #endif // CRYPTOPP_CXX11_NULLPTR
1165 
1166 // OK to comment the following out, but please report it so we can fix it.
1167 // C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf.
1168 #if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
1169 # error "std::uncaught_exception is not available. This is likely a configuration error."
1170 #endif
1171 
1172 #endif // CRYPTOPP_CONFIG_H
Crypto++ library namespace.