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