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