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