1 | // config.h - 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 | extern const char*cryptopp_extra_version; |
---|
10 | |
---|
11 | // ***************** Important Settings ******************** |
---|
12 | |
---|
13 | // define this if running on a big-endian CPU |
---|
14 | #if !defined(IS_LITTLE_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__))) |
---|
15 | # define IS_BIG_ENDIAN |
---|
16 | #endif |
---|
17 | |
---|
18 | // define this if running on a little-endian CPU |
---|
19 | // big endian will be assumed if IS_LITTLE_ENDIAN is not defined |
---|
20 | #ifndef IS_BIG_ENDIAN |
---|
21 | # define IS_LITTLE_ENDIAN |
---|
22 | #endif |
---|
23 | |
---|
24 | // Sanity checks. Some processors have more than big-, little- and bi-endian modes. PDP mode, where order results in "4312", should |
---|
25 | // raise red flags immediately. Additionally, mis-classified machines, like (previosuly) S/390, should raise red flags immediately. |
---|
26 | #if defined(IS_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) |
---|
27 | # error "IS_BIG_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_BIG_ENDIAN__" |
---|
28 | #endif |
---|
29 | #if defined(IS_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) |
---|
30 | # error "IS_LITTLE_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_LITTLE_ENDIAN__" |
---|
31 | #endif |
---|
32 | |
---|
33 | // Define this if you want to disable all OS-dependent features, |
---|
34 | // such as sockets and OS-provided random number generators |
---|
35 | // #define NO_OS_DEPENDENCE |
---|
36 | |
---|
37 | // Define this to use features provided by Microsoft's CryptoAPI. |
---|
38 | // Currently the only feature used is Windows random number generation. |
---|
39 | // This macro will be ignored if NO_OS_DEPENDENCE is defined. |
---|
40 | // #define USE_MS_CRYPTOAPI |
---|
41 | |
---|
42 | // Define this to use features provided by Microsoft's CryptoNG API. |
---|
43 | // CryptoNG API is available in Vista and above and its cross platform, |
---|
44 | // including desktop apps and store apps. Currently the only feature |
---|
45 | // used is Windows random number generation. |
---|
46 | // This macro will be ignored if NO_OS_DEPENDENCE is defined. |
---|
47 | // #define USE_MS_CNGAPI |
---|
48 | |
---|
49 | // If the user did not make a choice, then select CryptoNG if either |
---|
50 | // Visual Studio 2015 is available, or Windows 10 or above is available. |
---|
51 | #if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI) |
---|
52 | # if (_MSC_VER >= 1900) || ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)) |
---|
53 | # define USE_MS_CNGAPI |
---|
54 | # else |
---|
55 | # define USE_MS_CRYPTOAPI |
---|
56 | # endif |
---|
57 | #endif |
---|
58 | |
---|
59 | // Define this to ensure C/C++ standard compliance and respect for GCC aliasing rules and other alignment fodder. If you |
---|
60 | // experience a break with GCC at -O3, you should try this first. Guard it in case its set on the command line (and it differs). |
---|
61 | #ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS |
---|
62 | # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS |
---|
63 | #endif |
---|
64 | |
---|
65 | // ***************** Less Important Settings *************** |
---|
66 | |
---|
67 | // Library version |
---|
68 | #define CRYPTOPP_VERSION 565 |
---|
69 | |
---|
70 | // Define this if you want to set a prefix for TestData/ and TestVectors/ |
---|
71 | // Be mindful of the trailing slash since its simple concatenation. |
---|
72 | // g++ ... -DCRYPTOPP_DATA_DIR='"/tmp/cryptopp_test/share/"' |
---|
73 | #ifndef CRYPTOPP_DATA_DIR |
---|
74 | # define CRYPTOPP_DATA_DIR "" |
---|
75 | #endif |
---|
76 | |
---|
77 | // define this to retain (as much as possible) old deprecated function and class names |
---|
78 | // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY |
---|
79 | |
---|
80 | // Define this to retain (as much as possible) ABI and binary compatibility with Crypto++ 5.6.2. |
---|
81 | // Also see https://cryptopp.com/wiki/Config.h#Avoid_MAINTAIN_BACKWARDS_COMPATIBILITY |
---|
82 | // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 |
---|
83 | |
---|
84 | // Define this if you want or need the library's memcpy_s and memmove_s. |
---|
85 | // See http://github.com/weidai11/cryptopp/issues/28. |
---|
86 | // #if !defined(CRYPTOPP_WANT_SECURE_LIB) |
---|
87 | // # define CRYPTOPP_WANT_SECURE_LIB |
---|
88 | // #endif |
---|
89 | |
---|
90 | // File system code to write to GZIP archive. |
---|
91 | #if !defined(GZIP_OS_CODE) |
---|
92 | # define GZIP_OS_CODE 0 |
---|
93 | #endif |
---|
94 | |
---|
95 | // Try this if your CPU has 256K internal cache or a slow multiply instruction |
---|
96 | // and you want a (possibly) faster IDEA implementation using log tables |
---|
97 | // #define IDEA_LARGECACHE |
---|
98 | |
---|
99 | // Define this if, for the linear congruential RNG, you want to use |
---|
100 | // the original constants as specified in S.K. Park and K.W. Miller's |
---|
101 | // CACM paper. |
---|
102 | // #define LCRNG_ORIGINAL_NUMBERS |
---|
103 | |
---|
104 | // Define this if you want Integer's operator<< to honor std::showbase (and |
---|
105 | // std::noshowbase). If defined, Integer will use a suffix of 'b', 'o', 'h' |
---|
106 | // or '.' (the last for decimal) when std::showbase is in effect. If |
---|
107 | // std::noshowbase is set, then the suffix is not added to the Integer. If |
---|
108 | // not defined, existing behavior is preserved and Integer will use a suffix |
---|
109 | // of 'b', 'o', 'h' or '.' (the last for decimal). |
---|
110 | // #define CRYPTOPP_USE_STD_SHOWBASE |
---|
111 | |
---|
112 | // choose which style of sockets to wrap (mostly useful for MinGW which has both) |
---|
113 | #if !defined(NO_BERKELEY_STYLE_SOCKETS) && !defined(PREFER_BERKELEY_STYLE_SOCKETS) |
---|
114 | # define PREFER_BERKELEY_STYLE_SOCKETS |
---|
115 | #endif |
---|
116 | |
---|
117 | // #if !defined(NO_WINDOWS_STYLE_SOCKETS) && !defined(PREFER_WINDOWS_STYLE_SOCKETS) |
---|
118 | // # define PREFER_WINDOWS_STYLE_SOCKETS |
---|
119 | // #endif |
---|
120 | |
---|
121 | // set the name of Rijndael cipher, was "Rijndael" before version 5.3 |
---|
122 | #define CRYPTOPP_RIJNDAEL_NAME "AES" |
---|
123 | |
---|
124 | // CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT |
---|
125 | // raises a SIGTRAP (Unix) or calls DebugBreak() (Windows). CRYPTOPP_ASSERT |
---|
126 | // is only in effect when CRYPTOPP_DEBUG, DEBUG or _DEBUG is defined. Unlike |
---|
127 | // Posix assert, CRYPTOPP_ASSERT is not affected by NDEBUG (or failure to |
---|
128 | // define it). |
---|
129 | // Also see http://github.com/weidai11/cryptopp/issues/277, CVE-2016-7420 |
---|
130 | #if (defined(DEBUG) || defined(_DEBUG)) && !defined(CRYPTOPP_DEBUG) |
---|
131 | # define CRYPTOPP_DEBUG 1 |
---|
132 | #endif |
---|
133 | |
---|
134 | // ***************** Initialization and Constructor priorities ******************** |
---|
135 | |
---|
136 | // MacPorts/GCC and Solaris/GCC does not provide constructor(priority). Apple/GCC and Fink/GCC do provide it. |
---|
137 | // See http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco |
---|
138 | |
---|
139 | // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects. |
---|
140 | // Under GCC, the library uses init_priority attribute in the range |
---|
141 | // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows, |
---|
142 | // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". |
---|
143 | #ifndef CRYPTOPP_INIT_PRIORITY |
---|
144 | # define CRYPTOPP_INIT_PRIORITY 250 |
---|
145 | #endif |
---|
146 | |
---|
147 | // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++ |
---|
148 | // and managing C++ static object creation. It is guaranteed not to conflict with |
---|
149 | // values used by (or would be used by) the Crypto++ library. |
---|
150 | #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0) |
---|
151 | # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101) |
---|
152 | #else |
---|
153 | # define CRYPTOPP_USER_PRIORITY 350 |
---|
154 | #endif |
---|
155 | |
---|
156 | // __attribute__(init_priority(250)) is supported |
---|
157 | #if (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && ((CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 300)) && !(MACPORTS_GCC_COMPILER > 0) && !defined(__sun__)) |
---|
158 | # define HAVE_GCC_CONSTRUCTOR1 1 |
---|
159 | #endif |
---|
160 | |
---|
161 | // __attribute__(init_priority()) is supported |
---|
162 | #if (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && !HAVE_GCC_CONSTRUCTOR1 && !(MACPORTS_GCC_COMPILER > 0) && !defined(__sun__)) |
---|
163 | # define HAVE_GCC_CONSTRUCTOR0 1 |
---|
164 | #endif |
---|
165 | |
---|
166 | #if (_MSC_VER && (CRYPTOPP_INIT_PRIORITY > 0)) |
---|
167 | # define HAVE_MSC_INIT_PRIORITY 1 |
---|
168 | #endif |
---|
169 | |
---|
170 | // ***************** Important Settings Again ******************** |
---|
171 | // But the defaults should be ok. |
---|
172 | |
---|
173 | // namespace support is now required |
---|
174 | #ifdef NO_NAMESPACE |
---|
175 | # error namespace support is now required |
---|
176 | #endif |
---|
177 | |
---|
178 | // Define this to workaround a Microsoft CryptoAPI bug where |
---|
179 | // each call to CryptAcquireContext causes a 100 KB memory leak. |
---|
180 | // Defining this will cause Crypto++ to make only one call to CryptAcquireContext. |
---|
181 | #define WORKAROUND_MS_BUG_Q258000 |
---|
182 | |
---|
183 | #ifdef CRYPTOPP_DOXYGEN_PROCESSING |
---|
184 | // Document the namespce exists. Put it here before CryptoPP is undefined below. |
---|
185 | //! \namespace CryptoPP |
---|
186 | //! \brief Crypto++ library namespace |
---|
187 | //! \details Nearly all classes are located in the CryptoPP namespace. Within |
---|
188 | //! the namespace, there are two additional namespaces. |
---|
189 | //! <ul> |
---|
190 | //! <li>Name - namespace for names used with \p NameValuePairs and documented in argnames.h |
---|
191 | //! <li>Weak - namespace for weak and wounded algorithms, like ARC4, MD5 and Pananma |
---|
192 | //! </ul> |
---|
193 | namespace CryptoPP { } |
---|
194 | // Bring in the symbols fund in the weak namespace; and fold Weak1 into Weak |
---|
195 | # define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 |
---|
196 | # define Weak1 Weak |
---|
197 | // Avoid putting "CryptoPP::" in front of everything in Doxygen output |
---|
198 | # define CryptoPP |
---|
199 | # define NAMESPACE_BEGIN(x) |
---|
200 | # define NAMESPACE_END |
---|
201 | // Get Doxygen to generate better documentation for these typedefs |
---|
202 | # define DOCUMENTED_TYPEDEF(x, y) class y : public x {}; |
---|
203 | // Make "protected" "private" so the functions and members are not documented |
---|
204 | # define protected private |
---|
205 | #else |
---|
206 | # define NAMESPACE_BEGIN(x) namespace x { |
---|
207 | # define NAMESPACE_END } |
---|
208 | # define DOCUMENTED_TYPEDEF(x, y) typedef x y; |
---|
209 | #endif |
---|
210 | #define ANONYMOUS_NAMESPACE_BEGIN namespace { |
---|
211 | #define ANONYMOUS_NAMESPACE_END } |
---|
212 | #define USING_NAMESPACE(x) using namespace x; |
---|
213 | #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x { |
---|
214 | #define DOCUMENTED_NAMESPACE_END } |
---|
215 | |
---|
216 | // What is the type of the third parameter to bind? |
---|
217 | // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int. |
---|
218 | // Unfortunately there is no way to tell whether or not socklen_t is defined. |
---|
219 | // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile. |
---|
220 | #ifndef TYPE_OF_SOCKLEN_T |
---|
221 | # if defined(_WIN32) || defined(__CYGWIN__) |
---|
222 | # define TYPE_OF_SOCKLEN_T int |
---|
223 | # else |
---|
224 | # define TYPE_OF_SOCKLEN_T ::socklen_t |
---|
225 | # endif |
---|
226 | #endif |
---|
227 | |
---|
228 | #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS) |
---|
229 | # define __USE_W32_SOCKETS |
---|
230 | #endif |
---|
231 | |
---|
232 | typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs |
---|
233 | |
---|
234 | NAMESPACE_BEGIN(CryptoPP) |
---|
235 | |
---|
236 | typedef unsigned short word16; |
---|
237 | typedef unsigned int word32; |
---|
238 | |
---|
239 | #if defined(_MSC_VER) || defined(__BORLANDC__) |
---|
240 | typedef unsigned __int64 word64; |
---|
241 | #define W64LIT(x) x##ui64 |
---|
242 | #elif (_LP64 || __LP64__) |
---|
243 | typedef unsigned long word64; |
---|
244 | #define W64LIT(x) x##UL |
---|
245 | #else |
---|
246 | typedef unsigned long long word64; |
---|
247 | #define W64LIT(x) x##ULL |
---|
248 | #endif |
---|
249 | |
---|
250 | // define large word type, used for file offsets and such |
---|
251 | typedef word64 lword; |
---|
252 | const lword LWORD_MAX = W64LIT(0xffffffffffffffff); |
---|
253 | |
---|
254 | // Clang pretends to be VC++, too. |
---|
255 | // See http://github.com/weidai11/cryptopp/issues/147 |
---|
256 | #if defined(_MSC_VER) && defined(__clang__) |
---|
257 | # error: "Unsupported configuration" |
---|
258 | #endif |
---|
259 | |
---|
260 | #ifdef __GNUC__ |
---|
261 | #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) |
---|
262 | #endif |
---|
263 | |
---|
264 | // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7 |
---|
265 | #if defined(__clang__ ) && !defined(__apple_build_version__) |
---|
266 | #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) |
---|
267 | #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 |
---|
268 | #elif defined(__clang__ ) && defined(__apple_build_version__) |
---|
269 | #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) |
---|
270 | #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 |
---|
271 | #endif |
---|
272 | |
---|
273 | #ifdef _MSC_VER |
---|
274 | #define CRYPTOPP_MSC_VERSION (_MSC_VER) |
---|
275 | #endif |
---|
276 | |
---|
277 | // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}" |
---|
278 | #if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000) |
---|
279 | #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1 |
---|
280 | #endif |
---|
281 | |
---|
282 | // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232 |
---|
283 | // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes. |
---|
284 | #if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) |
---|
285 | #define CRYPTOPP_DISABLE_INTEL_ASM 1 |
---|
286 | #endif |
---|
287 | |
---|
288 | // define hword, word, and dword. these are used for multiprecision integer arithmetic |
---|
289 | // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx |
---|
290 | #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__)) |
---|
291 | typedef word32 hword; |
---|
292 | typedef word64 word; |
---|
293 | #else |
---|
294 | #define CRYPTOPP_NATIVE_DWORD_AVAILABLE 1 |
---|
295 | #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) |
---|
296 | #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400 |
---|
297 | // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3 |
---|
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__) || (__arm64__) || (__aarch64__) |
---|
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 | #if defined(_MSC_VER) |
---|
339 | #if _MSC_VER == 1200 |
---|
340 | #include <malloc.h> |
---|
341 | #endif |
---|
342 | #if _MSC_VER > 1200 || defined(_mm_free) |
---|
343 | #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later |
---|
344 | #else |
---|
345 | #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack |
---|
346 | #endif |
---|
347 | #endif |
---|
348 | |
---|
349 | #ifndef CRYPTOPP_ALIGN_DATA |
---|
350 | #if defined(CRYPTOPP_MSVC6PP_OR_LATER) |
---|
351 | #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) |
---|
352 | #elif defined(__GNUC__) |
---|
353 | #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) |
---|
354 | #else |
---|
355 | #define CRYPTOPP_ALIGN_DATA(x) |
---|
356 | #endif |
---|
357 | #endif |
---|
358 | |
---|
359 | #ifndef CRYPTOPP_SECTION_ALIGN16 |
---|
360 | #if defined(__GNUC__) && !defined(__APPLE__) |
---|
361 | // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on |
---|
362 | #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16"))) |
---|
363 | #else |
---|
364 | #define CRYPTOPP_SECTION_ALIGN16 |
---|
365 | #endif |
---|
366 | #endif |
---|
367 | |
---|
368 | // The section attribute attempts to initialize CPU flags to avoid Valgrind findings above -O1 |
---|
369 | #if ((__MACH__ >= 1) && ((CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70100) || (CRYPTOPP_GCC_VERSION >= 40300))) |
---|
370 | #define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data"))) |
---|
371 | #elif ((__ELF__ >= 1) && (CRYPTOPP_GCC_VERSION >= 40300)) |
---|
372 | #define CRYPTOPP_SECTION_INIT __attribute__((section ("nocommon"))) |
---|
373 | #else |
---|
374 | #define CRYPTOPP_SECTION_INIT |
---|
375 | #endif |
---|
376 | |
---|
377 | #if defined(_MSC_VER) || defined(__fastcall) |
---|
378 | #define CRYPTOPP_FASTCALL __fastcall |
---|
379 | #else |
---|
380 | #define CRYPTOPP_FASTCALL |
---|
381 | #endif |
---|
382 | |
---|
383 | // VC60 workaround: it doesn't allow typename in some places |
---|
384 | #if defined(_MSC_VER) && (_MSC_VER < 1300) |
---|
385 | #define CPP_TYPENAME |
---|
386 | #else |
---|
387 | #define CPP_TYPENAME typename |
---|
388 | #endif |
---|
389 | |
---|
390 | // VC60 workaround: can't cast unsigned __int64 to float or double |
---|
391 | #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER) |
---|
392 | #define CRYPTOPP_VC6_INT64 (__int64) |
---|
393 | #else |
---|
394 | #define CRYPTOPP_VC6_INT64 |
---|
395 | #endif |
---|
396 | |
---|
397 | #ifdef _MSC_VER |
---|
398 | #define CRYPTOPP_NO_VTABLE __declspec(novtable) |
---|
399 | #else |
---|
400 | #define CRYPTOPP_NO_VTABLE |
---|
401 | #endif |
---|
402 | |
---|
403 | #ifdef _MSC_VER |
---|
404 | // 4127: conditional expression is constant |
---|
405 | // 4231: nonstandard extension used : 'extern' before template explicit instantiation |
---|
406 | // 4250: dominance |
---|
407 | // 4251: member needs to have dll-interface |
---|
408 | // 4275: base needs to have dll-interface |
---|
409 | // 4505: unreferenced local function |
---|
410 | // 4512: assignment operator not generated |
---|
411 | // 4660: explicitly instantiating a class that's already implicitly instantiated |
---|
412 | // 4661: no suitable definition provided for explicit template instantiation request |
---|
413 | // 4786: identifer was truncated in debug information |
---|
414 | // 4355: 'this' : used in base member initializer list |
---|
415 | // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation |
---|
416 | # pragma warning(disable: 4127 4231 4250 4251 4275 4505 4512 4660 4661 4786 4355 4910) |
---|
417 | // Security related, possible defects |
---|
418 | // http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx |
---|
419 | # pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928) |
---|
420 | #endif |
---|
421 | |
---|
422 | #ifdef __BORLANDC__ |
---|
423 | // 8037: non-const function called for const object. needed to work around BCB2006 bug |
---|
424 | # pragma warn -8037 |
---|
425 | #endif |
---|
426 | |
---|
427 | // [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it. |
---|
428 | #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE |
---|
429 | # pragma GCC diagnostic ignored "-Wunknown-pragmas" |
---|
430 | # pragma GCC diagnostic ignored "-Wunused-function" |
---|
431 | #endif |
---|
432 | |
---|
433 | // You may need to force include a C++ header on Android when using STLPort to ensure |
---|
434 | // _STLPORT_VERSION is defined: CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -include iosfwd" |
---|
435 | // TODO: Figure out C++17 and lack of std::uncaught_exception |
---|
436 | #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT))) |
---|
437 | #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION |
---|
438 | #endif |
---|
439 | |
---|
440 | #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION |
---|
441 | #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE |
---|
442 | #endif |
---|
443 | |
---|
444 | #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings |
---|
445 | #define CRYPTOPP_DISABLE_ASM |
---|
446 | #define CRYPTOPP_DISABLE_SSE2 |
---|
447 | #endif |
---|
448 | |
---|
449 | // Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...) |
---|
450 | #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000) |
---|
451 | # define CRYPTOPP_DISABLE_ASM |
---|
452 | #endif |
---|
453 | |
---|
454 | // Sun Studio 12 provides GCC inline assembly, http://blogs.oracle.com/x86be/entry/gcc_style_asm_inlining_support |
---|
455 | // We can enable SSE2 for Sun Studio in the makefile with -D__SSE2__, but users may not compile with it. |
---|
456 | #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(__SSE2__) && defined(__x86_64__) && (__SUNPRO_CC >= 0x5100) |
---|
457 | # define __SSE2__ 1 |
---|
458 | #endif |
---|
459 | |
---|
460 | #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))) |
---|
461 | // C++Builder 2010 does not allow "call label" where label is defined within inline assembly |
---|
462 | #define CRYPTOPP_X86_ASM_AVAILABLE |
---|
463 | |
---|
464 | #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__)) |
---|
465 | #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 |
---|
466 | #else |
---|
467 | #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 |
---|
468 | #endif |
---|
469 | |
---|
470 | #if !defined(CRYPTOPP_DISABLE_SSE3) && (_MSC_VER >= 1500 || (defined(__SSE3__) && defined(__SSSE3__))) |
---|
471 | #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1 |
---|
472 | #else |
---|
473 | #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0 |
---|
474 | #endif |
---|
475 | #endif |
---|
476 | |
---|
477 | #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64) |
---|
478 | #define CRYPTOPP_X64_MASM_AVAILABLE |
---|
479 | #endif |
---|
480 | |
---|
481 | #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__) |
---|
482 | #define CRYPTOPP_X64_ASM_AVAILABLE |
---|
483 | #endif |
---|
484 | |
---|
485 | #if !defined(CRYPTOPP_DISABLE_ASM) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM) |
---|
486 | #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 |
---|
487 | #else |
---|
488 | #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0 |
---|
489 | #endif |
---|
490 | |
---|
491 | // Intrinsics availible in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and |
---|
492 | // MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx) |
---|
493 | // SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4. |
---|
494 | #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSE4) && !defined(_M_ARM) && ((_MSC_VER >= 1500) || (defined(__SSE4_1__) && defined(__SSE4_2__))) |
---|
495 | #define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 1 |
---|
496 | #else |
---|
497 | #define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 0 |
---|
498 | #endif |
---|
499 | |
---|
500 | // Don't disgorge AES-NI from CLMUL. There will be two to four subtle breaks |
---|
501 | #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_AESNI) && !defined(_M_ARM) && (_MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110 || (defined(__AES__) && defined(__PCLMUL__))) |
---|
502 | #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1 |
---|
503 | #else |
---|
504 | #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0 |
---|
505 | #endif |
---|
506 | |
---|
507 | // AVX2 in MSC 18.00 |
---|
508 | #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_AVX) && !defined(_M_ARM) && ((_MSC_VER >= 1600) || (defined(__RDRND__) || defined(__RDSEED__) || defined(__AVX__))) |
---|
509 | #define CRYPTOPP_BOOL_AVX_AVAILABLE 1 |
---|
510 | #else |
---|
511 | #define CRYPTOPP_BOOL_AVX_AVAILABLE 0 |
---|
512 | #endif |
---|
513 | |
---|
514 | // Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains. |
---|
515 | #if !defined(CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) |
---|
516 | # if defined(__ARM_NEON__) || defined(__ARM_NEON) || defined(_M_ARM) |
---|
517 | # define CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE 1 |
---|
518 | # endif |
---|
519 | #endif |
---|
520 | |
---|
521 | // Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. |
---|
522 | // Microsoft plans to support ARM-64, but its not clear how to detect it. |
---|
523 | // TODO: Add MSC_VER and ARM-64 platform define when available |
---|
524 | #if !defined(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) |
---|
525 | # if defined(__ARM_FEATURE_CRC32) || defined(_M_ARM64) |
---|
526 | # define CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE 1 |
---|
527 | # endif |
---|
528 | #endif |
---|
529 | |
---|
530 | // Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. |
---|
531 | // Microsoft plans to support ARM-64, but its not clear how to detect it. |
---|
532 | // TODO: Add MSC_VER and ARM-64 platform define when available |
---|
533 | #if !defined(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) |
---|
534 | # if defined(__ARM_FEATURE_CRYPTO) || defined(_M_ARM64) |
---|
535 | # define CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE 1 |
---|
536 | # endif |
---|
537 | #endif |
---|
538 | |
---|
539 | #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) |
---|
540 | #define CRYPTOPP_BOOL_ALIGN16 1 |
---|
541 | #else |
---|
542 | #define CRYPTOPP_BOOL_ALIGN16 0 |
---|
543 | #endif |
---|
544 | |
---|
545 | // how to allocate 16-byte aligned memory (for SSE2) |
---|
546 | #if defined(CRYPTOPP_MSVC6PP_OR_LATER) |
---|
547 | #define CRYPTOPP_MM_MALLOC_AVAILABLE |
---|
548 | #elif defined(__APPLE__) |
---|
549 | #define CRYPTOPP_APPLE_MALLOC_AVAILABLE |
---|
550 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
---|
551 | #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 |
---|
552 | #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) |
---|
553 | #define CRYPTOPP_MEMALIGN_AVAILABLE |
---|
554 | #else |
---|
555 | #define CRYPTOPP_NO_ALIGNED_ALLOC |
---|
556 | #endif |
---|
557 | |
---|
558 | // Apple always provides 16-byte aligned, and tells us to use calloc |
---|
559 | // http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html |
---|
560 | |
---|
561 | // how to disable inlining |
---|
562 | #if defined(_MSC_VER) && _MSC_VER >= 1300 |
---|
563 | # define CRYPTOPP_NOINLINE_DOTDOTDOT |
---|
564 | # define CRYPTOPP_NOINLINE __declspec(noinline) |
---|
565 | #elif defined(__GNUC__) |
---|
566 | # define CRYPTOPP_NOINLINE_DOTDOTDOT |
---|
567 | # define CRYPTOPP_NOINLINE __attribute__((noinline)) |
---|
568 | #else |
---|
569 | # define CRYPTOPP_NOINLINE_DOTDOTDOT ... |
---|
570 | # define CRYPTOPP_NOINLINE |
---|
571 | #endif |
---|
572 | |
---|
573 | // How to declare class constants |
---|
574 | // Use enum for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255 |
---|
575 | #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__) |
---|
576 | # define CRYPTOPP_CONSTANT(x) enum {x}; |
---|
577 | #else |
---|
578 | # define CRYPTOPP_CONSTANT(x) static const int x; |
---|
579 | #endif |
---|
580 | |
---|
581 | // Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set. |
---|
582 | // Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than |
---|
583 | // the System V ABI specs calls out, like on just about any 32-bit system with Clang. |
---|
584 | #if ((__ILP32__ >= 1) || (_ILP32 >= 1)) && defined(__x86_64__) |
---|
585 | #define CRYPTOPP_BOOL_X32 1 |
---|
586 | #else |
---|
587 | #define CRYPTOPP_BOOL_X32 0 |
---|
588 | #endif |
---|
589 | |
---|
590 | // see http://predef.sourceforge.net/prearch.html |
---|
591 | #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32 |
---|
592 | #define CRYPTOPP_BOOL_X86 1 |
---|
593 | #else |
---|
594 | #define CRYPTOPP_BOOL_X86 0 |
---|
595 | #endif |
---|
596 | |
---|
597 | #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32 |
---|
598 | #define CRYPTOPP_BOOL_X64 1 |
---|
599 | #else |
---|
600 | #define CRYPTOPP_BOOL_X64 0 |
---|
601 | #endif |
---|
602 | |
---|
603 | // Undo the ASM and Intrinsic related defines due to X32. |
---|
604 | #if CRYPTOPP_BOOL_X32 |
---|
605 | # undef CRYPTOPP_BOOL_X64 |
---|
606 | # undef CRYPTOPP_X64_ASM_AVAILABLE |
---|
607 | # undef CRYPTOPP_X64_MASM_AVAILABLE |
---|
608 | #endif |
---|
609 | |
---|
610 | #if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM) |
---|
611 | #define CRYPTOPP_BOOL_ARM32 1 |
---|
612 | #else |
---|
613 | #define CRYPTOPP_BOOL_ARM32 0 |
---|
614 | #endif |
---|
615 | |
---|
616 | // Microsoft plans to support ARM-64, but its not clear how to detect it. |
---|
617 | // TODO: Add MSC_VER and ARM-64 platform define when available |
---|
618 | #if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) |
---|
619 | #define CRYPTOPP_BOOL_ARM64 1 |
---|
620 | #else |
---|
621 | #define CRYPTOPP_BOOL_ARM64 0 |
---|
622 | #endif |
---|
623 | |
---|
624 | #if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) |
---|
625 | #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1)) |
---|
626 | #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS |
---|
627 | #endif |
---|
628 | #endif |
---|
629 | |
---|
630 | // ***************** determine availability of OS features ******************** |
---|
631 | |
---|
632 | #ifndef NO_OS_DEPENDENCE |
---|
633 | |
---|
634 | #if defined(_WIN32) || defined(__CYGWIN__) |
---|
635 | #define CRYPTOPP_WIN32_AVAILABLE |
---|
636 | #endif |
---|
637 | |
---|
638 | #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun) |
---|
639 | #define CRYPTOPP_UNIX_AVAILABLE |
---|
640 | #endif |
---|
641 | |
---|
642 | #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
---|
643 | #define CRYPTOPP_BSD_AVAILABLE |
---|
644 | #endif |
---|
645 | |
---|
646 | #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) |
---|
647 | # define HIGHRES_TIMER_AVAILABLE |
---|
648 | #endif |
---|
649 | |
---|
650 | #ifdef CRYPTOPP_WIN32_AVAILABLE |
---|
651 | # if !defined(WINAPI_FAMILY) |
---|
652 | # define THREAD_TIMER_AVAILABLE |
---|
653 | # elif defined(WINAPI_FAMILY) |
---|
654 | # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) |
---|
655 | # define THREAD_TIMER_AVAILABLE |
---|
656 | # endif |
---|
657 | # endif |
---|
658 | #endif |
---|
659 | |
---|
660 | #ifdef CRYPTOPP_UNIX_AVAILABLE |
---|
661 | # define HAS_BERKELEY_STYLE_SOCKETS |
---|
662 | # define SOCKETS_AVAILABLE |
---|
663 | #endif |
---|
664 | |
---|
665 | // Sockets are only available under Windows Runtime desktop partition apps (despite the MSDN literature) |
---|
666 | #ifdef CRYPTOPP_WIN32_AVAILABLE |
---|
667 | # define HAS_WINDOWS_STYLE_SOCKETS |
---|
668 | # if !defined(WINAPI_FAMILY) |
---|
669 | # define SOCKETS_AVAILABLE |
---|
670 | # elif defined(WINAPI_FAMILY) |
---|
671 | # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) |
---|
672 | # define SOCKETS_AVAILABLE |
---|
673 | # endif |
---|
674 | # endif |
---|
675 | #endif |
---|
676 | |
---|
677 | #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS)) |
---|
678 | # define USE_WINDOWS_STYLE_SOCKETS |
---|
679 | #else |
---|
680 | # define USE_BERKELEY_STYLE_SOCKETS |
---|
681 | #endif |
---|
682 | |
---|
683 | #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(SOCKETS_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS) |
---|
684 | # define WINDOWS_PIPES_AVAILABLE |
---|
685 | #endif |
---|
686 | |
---|
687 | #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) |
---|
688 | # define NONBLOCKING_RNG_AVAILABLE |
---|
689 | # define BLOCKING_RNG_AVAILABLE |
---|
690 | # define OS_RNG_AVAILABLE |
---|
691 | # define HAS_PTHREADS |
---|
692 | # define THREADS_AVAILABLE |
---|
693 | #endif |
---|
694 | |
---|
695 | #if defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) || defined(__CYGWIN__) |
---|
696 | # define UNIX_SIGNALS_AVAILABLE 1 |
---|
697 | #endif |
---|
698 | |
---|
699 | #ifdef CRYPTOPP_WIN32_AVAILABLE |
---|
700 | # if !defined(WINAPI_FAMILY) |
---|
701 | # define HAS_WINTHREADS |
---|
702 | # define THREADS_AVAILABLE |
---|
703 | # define NONBLOCKING_RNG_AVAILABLE |
---|
704 | # define OS_RNG_AVAILABLE |
---|
705 | # elif defined(WINAPI_FAMILY) |
---|
706 | # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) |
---|
707 | # define HAS_WINTHREADS |
---|
708 | # define THREADS_AVAILABLE |
---|
709 | # define NONBLOCKING_RNG_AVAILABLE |
---|
710 | # define OS_RNG_AVAILABLE |
---|
711 | # elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) |
---|
712 | # if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)) |
---|
713 | # define NONBLOCKING_RNG_AVAILABLE |
---|
714 | # define OS_RNG_AVAILABLE |
---|
715 | # endif |
---|
716 | # endif |
---|
717 | # endif |
---|
718 | #endif |
---|
719 | |
---|
720 | #endif // NO_OS_DEPENDENCE |
---|
721 | |
---|
722 | // ***************** DLL related ******************** |
---|
723 | |
---|
724 | #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) |
---|
725 | |
---|
726 | #ifdef CRYPTOPP_EXPORTS |
---|
727 | #define CRYPTOPP_IS_DLL |
---|
728 | #define CRYPTOPP_DLL __declspec(dllexport) |
---|
729 | #elif defined(CRYPTOPP_IMPORTS) |
---|
730 | #define CRYPTOPP_IS_DLL |
---|
731 | #define CRYPTOPP_DLL __declspec(dllimport) |
---|
732 | #else |
---|
733 | #define CRYPTOPP_DLL |
---|
734 | #endif |
---|
735 | |
---|
736 | #define CRYPTOPP_API __cdecl |
---|
737 | |
---|
738 | #else // not CRYPTOPP_WIN32_AVAILABLE |
---|
739 | |
---|
740 | #define CRYPTOPP_DLL |
---|
741 | #define CRYPTOPP_API |
---|
742 | |
---|
743 | #endif // CRYPTOPP_WIN32_AVAILABLE |
---|
744 | |
---|
745 | #if defined(__MWERKS__) |
---|
746 | #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL |
---|
747 | #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) |
---|
748 | #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL |
---|
749 | #else |
---|
750 | #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL |
---|
751 | #endif |
---|
752 | |
---|
753 | #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS) |
---|
754 | #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL |
---|
755 | #else |
---|
756 | #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS |
---|
757 | #endif |
---|
758 | |
---|
759 | #if defined(__MWERKS__) |
---|
760 | #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class |
---|
761 | #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) |
---|
762 | #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class |
---|
763 | #else |
---|
764 | #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class |
---|
765 | #endif |
---|
766 | |
---|
767 | #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS) |
---|
768 | #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class |
---|
769 | #else |
---|
770 | #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS |
---|
771 | #endif |
---|
772 | |
---|
773 | // ************** Unused variable *************** |
---|
774 | |
---|
775 | // Portable way to suppress warnings. |
---|
776 | // Moved from misc.h due to circular depenedencies. |
---|
777 | #define CRYPTOPP_UNUSED(x) ((void)(x)) |
---|
778 | |
---|
779 | // ************** Deprecated *************** |
---|
780 | |
---|
781 | #if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) |
---|
782 | # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg))); |
---|
783 | #elif (CRYPTOPP_GCC_VERSION) |
---|
784 | # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated)); |
---|
785 | #else |
---|
786 | # define CRYPTOPP_DEPRECATED(msg) |
---|
787 | #endif |
---|
788 | |
---|
789 | // ***************** C++11 related ******************** |
---|
790 | |
---|
791 | // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx. |
---|
792 | // Intel and C++11 language features, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler |
---|
793 | // GCC and C++11 language features, http://gcc.gnu.org/projects/cxx0x.html |
---|
794 | // Clang and C++11 language features, http://clang.llvm.org/cxx_status.html |
---|
795 | #if ((_MSC_VER >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION) |
---|
796 | # define CRYPTOPP_CXX11 1 |
---|
797 | #endif |
---|
798 | |
---|
799 | // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't |
---|
800 | // test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same |
---|
801 | // way. However, modern standard libraries have <forward_list>, so we test for it instead. |
---|
802 | // Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions. |
---|
803 | // TODO: test under Xcode 3, where g++ is really g++. |
---|
804 | #if defined(__APPLE__) && defined(__clang__) |
---|
805 | # if !(defined(__has_include) && __has_include(<forward_list>)) |
---|
806 | # undef CRYPTOPP_CXX11 |
---|
807 | # endif |
---|
808 | #endif |
---|
809 | |
---|
810 | // C++11 or C++14 is available |
---|
811 | #if defined(CRYPTOPP_CXX11) |
---|
812 | |
---|
813 | // atomics: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.1/3.2; Intel 13.0; SunCC 12.5. |
---|
814 | #if (CRYPTOPP_MSC_VERSION >= 1700) |
---|
815 | # define CRYPTOPP_CXX11_ATOMICS 1 |
---|
816 | #elif (__INTEL_COMPILER >= 1300) |
---|
817 | # define CRYPTOPP_CXX11_ATOMICS 1 |
---|
818 | #elif defined(__clang__) |
---|
819 | # if __has_feature(cxx_atomic) |
---|
820 | # define CRYPTOPP_CXX11_ATOMICS 1 |
---|
821 | # endif |
---|
822 | #elif (CRYPTOPP_GCC_VERSION >= 40400) |
---|
823 | # define CRYPTOPP_CXX11_ATOMICS 1 |
---|
824 | #elif (__SUNPRO_CC >= 0x5140) |
---|
825 | # define CRYPTOPP_CXX11_ATOMICS 1 |
---|
826 | #endif // atomics |
---|
827 | |
---|
828 | // synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 12.4. |
---|
829 | // TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang |
---|
830 | #if (CRYPTOPP_MSC_VERSION >= 1700) |
---|
831 | # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 |
---|
832 | #elif (__INTEL_COMPILER >= 1200) |
---|
833 | # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 |
---|
834 | #elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) |
---|
835 | # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 |
---|
836 | #elif (CRYPTOPP_GCC_VERSION >= 40400) |
---|
837 | # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 |
---|
838 | #elif (__SUNPRO_CC >= 0x5130) |
---|
839 | # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 |
---|
840 | #endif // synchronization |
---|
841 | |
---|
842 | // alignof/alignas: MS at VS2015 (19.00); GCC at 4.8; Clang at 3.3; Intel 15.0; SunCC 12.4. |
---|
843 | #if (CRYPTOPP_MSC_VERSION >= 1900) |
---|
844 | # define CRYPTOPP_CXX11_ALIGNAS 1 |
---|
845 | # define CRYPTOPP_CXX11_ALIGNOF 1 |
---|
846 | #elif (__INTEL_COMPILER >= 1500) |
---|
847 | # define CRYPTOPP_CXX11_ALIGNAS 1 |
---|
848 | # define CRYPTOPP_CXX11_ALIGNOF 1 |
---|
849 | #elif defined(__clang__) |
---|
850 | # if __has_feature(cxx_alignas) |
---|
851 | # define CRYPTOPP_CXX11_ALIGNAS 1 |
---|
852 | # endif |
---|
853 | # if __has_feature(cxx_alignof) |
---|
854 | # define CRYPTOPP_CXX11_ALIGNOF 1 |
---|
855 | # endif |
---|
856 | #elif (CRYPTOPP_GCC_VERSION >= 40800) |
---|
857 | # define CRYPTOPP_CXX11_ALIGNAS 1 |
---|
858 | # define CRYPTOPP_CXX11_ALIGNOF 1 |
---|
859 | #elif (__SUNPRO_CC >= 0x5130) |
---|
860 | # define CRYPTOPP_CXX11_ALIGNAS 1 |
---|
861 | # define CRYPTOPP_CXX11_ALIGNOF 1 |
---|
862 | #endif // alignof/alignas |
---|
863 | |
---|
864 | // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 14.0; SunCC 12.4. |
---|
865 | #if (CRYPTOPP_MSC_VERSION >= 1900) |
---|
866 | # define CRYPTOPP_CXX11_NOEXCEPT 1 |
---|
867 | #elif (__INTEL_COMPILER >= 1400) |
---|
868 | # define CRYPTOPP_CXX11_NOEXCEPT 1 |
---|
869 | #elif defined(__clang__) |
---|
870 | # if __has_feature(cxx_noexcept) |
---|
871 | # define CRYPTOPP_CXX11_NOEXCEPT 1 |
---|
872 | # endif |
---|
873 | #elif (CRYPTOPP_GCC_VERSION >= 40600) |
---|
874 | # define CRYPTOPP_CXX11_NOEXCEPT 1 |
---|
875 | #elif (__SUNPRO_CC >= 0x5130) |
---|
876 | # define CRYPTOPP_CXX11_NOEXCEPT 1 |
---|
877 | #endif // noexcept compilers |
---|
878 | |
---|
879 | // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 12.4. |
---|
880 | #if (CRYPTOPP_MSC_VERSION >= 1800) |
---|
881 | # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1 |
---|
882 | #elif (__INTEL_COMPILER >= 1210) |
---|
883 | # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1 |
---|
884 | #elif defined(__clang__) |
---|
885 | # if __has_feature(cxx_variadic_templates) |
---|
886 | # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1 |
---|
887 | # endif |
---|
888 | #elif (CRYPTOPP_GCC_VERSION >= 40300) |
---|
889 | # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1 |
---|
890 | #elif (__SUNPRO_CC >= 0x5130) |
---|
891 | # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1 |
---|
892 | #endif // variadic templates |
---|
893 | |
---|
894 | // constexpr: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 16.0; SunCC 12.4. |
---|
895 | // Intel has mis-supported the feature since at least ICPC 13.00 |
---|
896 | #if (CRYPTOPP_MSC_VERSION >= 1900) |
---|
897 | # define CRYPTOPP_CXX11_CONSTEXPR 1 |
---|
898 | #elif (__INTEL_COMPILER >= 1600) |
---|
899 | # define CRYPTOPP_CXX11_CONSTEXPR 1 |
---|
900 | #elif defined(__clang__) |
---|
901 | # if __has_feature(cxx_constexpr) |
---|
902 | # define CRYPTOPP_CXX11_CONSTEXPR 1 |
---|
903 | # endif |
---|
904 | #elif (CRYPTOPP_GCC_VERSION >= 40600) |
---|
905 | # define CRYPTOPP_CXX11_CONSTEXPR 1 |
---|
906 | #elif (__SUNPRO_CC >= 0x5130) |
---|
907 | # define CRYPTOPP_CXX11_CONSTEXPR 1 |
---|
908 | #endif // constexpr compilers |
---|
909 | |
---|
910 | // TODO: Emplacement, R-values and Move semantics |
---|
911 | // Needed because we are catching warnings with GCC and MSC |
---|
912 | |
---|
913 | #endif // CRYPTOPP_CXX11 |
---|
914 | |
---|
915 | #if defined(CRYPTOPP_CXX11_NOEXCEPT) |
---|
916 | # define CRYPTOPP_THROW noexcept(false) |
---|
917 | # define CRYPTOPP_NO_THROW noexcept(true) |
---|
918 | #else |
---|
919 | # define CRYPTOPP_THROW |
---|
920 | # define CRYPTOPP_NO_THROW |
---|
921 | #endif // CRYPTOPP_CXX11_NOEXCEPT |
---|
922 | |
---|
923 | #if defined(CRYPTOPP_CXX11_CONSTEXPR) |
---|
924 | # define CRYPTOPP_CONSTEXPR constexpr |
---|
925 | #else |
---|
926 | # define CRYPTOPP_CONSTEXPR |
---|
927 | #endif // CRYPTOPP_CXX11_CONSTEXPR |
---|
928 | |
---|
929 | // Hack... CRYPTOPP_ALIGN_DATA is defined earlier, before C++11 alignas availability is determined |
---|
930 | #if defined(CRYPTOPP_CXX11_ALIGNAS) |
---|
931 | # undef CRYPTOPP_ALIGN_DATA |
---|
932 | # define CRYPTOPP_ALIGN_DATA(x) alignas(x) |
---|
933 | #endif // CRYPTOPP_CXX11_ALIGNAS |
---|
934 | |
---|
935 | // Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined |
---|
936 | #if defined(CRYPTOPP_CXX11_CONSTEXPR) |
---|
937 | # undef CRYPTOPP_CONSTANT |
---|
938 | # define CRYPTOPP_CONSTANT(x) constexpr static int x; |
---|
939 | #endif |
---|
940 | |
---|
941 | // OK to comment the following out, but please report it so we can fix it. |
---|
942 | // C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf. |
---|
943 | #if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE) |
---|
944 | # error "std::uncaught_exception is not available. This is likely a configuration error." |
---|
945 | #endif |
---|
946 | |
---|
947 | #endif |
---|