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