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