Crypto++
config.h
1 #ifndef __x86_64__
2 #define CRYPTOPP_DISABLE_SSE2
3 #endif
4 
5 #ifndef CRYPTOPP_CONFIG_H
6 #define CRYPTOPP_CONFIG_H
7 
8 // ***************** Important Settings ********************
9 
10 // define this if running on a big-endian CPU
11 #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__s390__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
12 # define IS_BIG_ENDIAN
13 #endif
14 
15 // define this if running on a little-endian CPU
16 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
17 #ifndef IS_BIG_ENDIAN
18 # define IS_LITTLE_ENDIAN
19 #endif
20 
21 // define this if you want to disable all OS-dependent features,
22 // such as sockets and OS-provided random number generators
23 // #define NO_OS_DEPENDENCE
24 
25 // Define this to use features provided by Microsoft's CryptoAPI.
26 // Currently the only feature used is random number generation.
27 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
28 #define USE_MS_CRYPTOAPI
29 
30 // Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used
31 #ifndef DSA_1024_BIT_MODULUS_ONLY
32 # define DSA_1024_BIT_MODULUS_ONLY 1
33 #endif
34 
35 // ***************** Less Important Settings ***************
36 
37 // define this to retain (as much as possible) old deprecated function and class names
38 // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
39 
40 #define GZIP_OS_CODE 0
41 
42 // Try this if your CPU has 256K internal cache or a slow multiply instruction
43 // and you want a (possibly) faster IDEA implementation using log tables
44 // #define IDEA_LARGECACHE
45 
46 // Define this if, for the linear congruential RNG, you want to use
47 // the original constants as specified in S.K. Park and K.W. Miller's
48 // CACM paper.
49 // #define LCRNG_ORIGINAL_NUMBERS
50 
51 // choose which style of sockets to wrap (mostly useful for cygwin which has both)
52 #define PREFER_BERKELEY_STYLE_SOCKETS
53 // #define PREFER_WINDOWS_STYLE_SOCKETS
54 
55 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
56 #define CRYPTOPP_RIJNDAEL_NAME "AES"
57 
58 // ***************** Important Settings Again ********************
59 // But the defaults should be ok.
60 
61 // namespace support is now required
62 #ifdef NO_NAMESPACE
63 # error namespace support is now required
64 #endif
65 
66 // Define this to workaround a Microsoft CryptoAPI bug where
67 // each call to CryptAcquireContext causes a 100 KB memory leak.
68 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
69 #define WORKAROUND_MS_BUG_Q258000
70 
71 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
72 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
73 # define CryptoPP
74 # define NAMESPACE_BEGIN(x)
75 # define NAMESPACE_END
76 // Get Doxygen to generate better documentation for these typedefs
77 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
78 #else
79 # define NAMESPACE_BEGIN(x) namespace x {
80 # define NAMESPACE_END }
81 # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
82 #endif
83 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
84 #define USING_NAMESPACE(x) using namespace x;
85 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
86 #define DOCUMENTED_NAMESPACE_END }
87 
88 // What is the type of the third parameter to bind?
89 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
90 // Unfortunately there is no way to tell whether or not socklen_t is defined.
91 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
92 #ifndef TYPE_OF_SOCKLEN_T
93 # if defined(_WIN32) || defined(__CYGWIN__)
94 # define TYPE_OF_SOCKLEN_T int
95 # else
96 # define TYPE_OF_SOCKLEN_T ::socklen_t
97 # endif
98 #endif
99 
100 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
101 # define __USE_W32_SOCKETS
102 #endif
103 
104 typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
105 
106 NAMESPACE_BEGIN(CryptoPP)
107 
108 typedef unsigned short word16;
109 typedef unsigned int word32;
110 
111 #if defined(_MSC_VER) || defined(__BORLANDC__)
112  typedef unsigned __int64 word64;
113  #define W64LIT(x) x##ui64
114 #else
115  typedef unsigned long long word64;
116  #define W64LIT(x) x##ULL
117 #endif
118 
119 // define large word type, used for file offsets and such
120 typedef word64 lword;
121 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
122 
123 #ifdef __GNUC__
124  #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
125 #endif
126 
127 // define hword, word, and dword. these are used for multiprecision integer arithmetic
128 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
129 #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__))
130  typedef word32 hword;
131  typedef word64 word;
132 #else
133  #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
134  #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) || defined(__s390x__)
135  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
136  // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
137  // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
138  typedef word32 hword;
139  typedef word64 word;
140  typedef __uint128_t dword;
141  typedef __uint128_t word128;
142  #define CRYPTOPP_WORD128_AVAILABLE
143  #else
144  // 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
145  typedef word16 hword;
146  typedef word32 word;
147  typedef word64 dword;
148  #endif
149  #else
150  // being here means the native register size is probably 32 bits or less
151  #define CRYPTOPP_BOOL_SLOW_WORD64 1
152  typedef word16 hword;
153  typedef word32 word;
154  typedef word64 dword;
155  #endif
156 #endif
157 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
158  #define CRYPTOPP_BOOL_SLOW_WORD64 0
159 #endif
160 
161 const unsigned int WORD_SIZE = sizeof(word);
162 const unsigned int WORD_BITS = WORD_SIZE * 8;
163 
164 NAMESPACE_END
165 
166 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
167  // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
168  #if defined(_M_X64) || defined(__x86_64__)
169  #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
170  #else
171  // L1 cache line size is 32 on Pentium III and earlier
172  #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
173  #endif
174 #endif
175 
176 #if defined(_MSC_VER)
177  #if _MSC_VER == 1200
178  #include <malloc.h>
179  #endif
180  #if _MSC_VER > 1200 || defined(_mm_free)
181  #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
182  #else
183  #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
184  #endif
185 #endif
186 
187 #ifndef CRYPTOPP_ALIGN_DATA
188  #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
189  #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
190  #elif defined(__GNUC__)
191  #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
192  #else
193  #define CRYPTOPP_ALIGN_DATA(x)
194  #endif
195 #endif
196 
197 #ifndef CRYPTOPP_SECTION_ALIGN16
198  #if defined(__GNUC__) && !defined(__APPLE__)
199  // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
200  #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
201  #else
202  #define CRYPTOPP_SECTION_ALIGN16
203  #endif
204 #endif
205 
206 #if defined(_MSC_VER) || defined(__fastcall)
207  #define CRYPTOPP_FASTCALL __fastcall
208 #else
209  #define CRYPTOPP_FASTCALL
210 #endif
211 
212 // VC60 workaround: it doesn't allow typename in some places
213 #if defined(_MSC_VER) && (_MSC_VER < 1300)
214 #define CPP_TYPENAME
215 #else
216 #define CPP_TYPENAME typename
217 #endif
218 
219 // VC60 workaround: can't cast unsigned __int64 to float or double
220 #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
221 #define CRYPTOPP_VC6_INT64 (__int64)
222 #else
223 #define CRYPTOPP_VC6_INT64
224 #endif
225 
226 #ifdef _MSC_VER
227 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
228 #else
229 #define CRYPTOPP_NO_VTABLE
230 #endif
231 
232 #ifdef _MSC_VER
233  // 4231: nonstandard extension used : 'extern' before template explicit instantiation
234  // 4250: dominance
235  // 4251: member needs to have dll-interface
236  // 4275: base needs to have dll-interface
237  // 4660: explicitly instantiating a class that's already implicitly instantiated
238  // 4661: no suitable definition provided for explicit template instantiation request
239  // 4786: identifer was truncated in debug information
240  // 4355: 'this' : used in base member initializer list
241  // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
242 # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910)
243 #endif
244 
245 #ifdef __BORLANDC__
246 // 8037: non-const function called for const object. needed to work around BCB2006 bug
247 # pragma warn -8037
248 #endif
249 
250 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
251 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
252 #endif
253 
254 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
255 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
256 #endif
257 
258 #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
259 #define CRYPTOPP_DISABLE_ASM
260 #define CRYPTOPP_DISABLE_SSE2
261 #endif
262 
263 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
264  // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
265  #define CRYPTOPP_X86_ASM_AVAILABLE
266 
267  #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
268  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
269  #else
270  #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
271  #endif
272 
273  // SSSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed.
274  // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
275  #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
276  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
277  #else
278  #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
279  #endif
280 #endif
281 
282 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
283  #define CRYPTOPP_X64_MASM_AVAILABLE
284 #endif
285 
286 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
287  #define CRYPTOPP_X64_ASM_AVAILABLE
288 #endif
289 
290 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
291  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
292 #else
293  #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
294 #endif
295 
296 #if !defined(CRYPTOPP_DISABLE_SSSE3) && !defined(CRYPTOPP_DISABLE_AESNI) && CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && (CRYPTOPP_GCC_VERSION >= 40400 || _MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110)
297  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
298 #else
299  #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
300 #endif
301 
302 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
303  #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
304 #else
305  #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
306 #endif
307 
308 // how to allocate 16-byte aligned memory (for SSE2)
309 #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
310  #define CRYPTOPP_MM_MALLOC_AVAILABLE
311 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
312  #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
313 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
314  #define CRYPTOPP_MEMALIGN_AVAILABLE
315 #else
316  #define CRYPTOPP_NO_ALIGNED_ALLOC
317 #endif
318 
319 // how to disable inlining
320 #if defined(_MSC_VER) && _MSC_VER >= 1300
321 # define CRYPTOPP_NOINLINE_DOTDOTDOT
322 # define CRYPTOPP_NOINLINE __declspec(noinline)
323 #elif defined(__GNUC__)
324 # define CRYPTOPP_NOINLINE_DOTDOTDOT
325 # define CRYPTOPP_NOINLINE __attribute__((noinline))
326 #else
327 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
328 # define CRYPTOPP_NOINLINE
329 #endif
330 
331 // how to declare class constants
332 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
333 # define CRYPTOPP_CONSTANT(x) enum {x};
334 #else
335 # define CRYPTOPP_CONSTANT(x) static const int x;
336 #endif
337 
338 #if defined(_M_X64) || defined(__x86_64__)
339  #define CRYPTOPP_BOOL_X64 1
340 #else
341  #define CRYPTOPP_BOOL_X64 0
342 #endif
343 
344 // see http://predef.sourceforge.net/prearch.html
345 #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)
346  #define CRYPTOPP_BOOL_X86 1
347 #else
348  #define CRYPTOPP_BOOL_X86 0
349 #endif
350 
351 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)
352  #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
353 #endif
354 
355 #define CRYPTOPP_VERSION 561
356 
357 // ***************** determine availability of OS features ********************
358 
359 #ifndef NO_OS_DEPENDENCE
360 
361 #if defined(_WIN32) || defined(__CYGWIN__)
362 #define CRYPTOPP_WIN32_AVAILABLE
363 #endif
364 
365 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
366 #define CRYPTOPP_UNIX_AVAILABLE
367 #endif
368 
369 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
370 # define HIGHRES_TIMER_AVAILABLE
371 #endif
372 
373 #ifdef CRYPTOPP_UNIX_AVAILABLE
374 # define HAS_BERKELEY_STYLE_SOCKETS
375 #endif
376 
377 #ifdef CRYPTOPP_WIN32_AVAILABLE
378 # define HAS_WINDOWS_STYLE_SOCKETS
379 #endif
380 
381 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
382 # define SOCKETS_AVAILABLE
383 #endif
384 
385 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
386 # define USE_WINDOWS_STYLE_SOCKETS
387 #else
388 # define USE_BERKELEY_STYLE_SOCKETS
389 #endif
390 
391 #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
392 # define WINDOWS_PIPES_AVAILABLE
393 #endif
394 
395 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
396 # define NONBLOCKING_RNG_AVAILABLE
397 # define OS_RNG_AVAILABLE
398 #endif
399 
400 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
401 # define NONBLOCKING_RNG_AVAILABLE
402 # define BLOCKING_RNG_AVAILABLE
403 # define OS_RNG_AVAILABLE
404 # define HAS_PTHREADS
405 # define THREADS_AVAILABLE
406 #endif
407 
408 #ifdef CRYPTOPP_WIN32_AVAILABLE
409 # define HAS_WINTHREADS
410 # define THREADS_AVAILABLE
411 #endif
412 
413 #endif // NO_OS_DEPENDENCE
414 
415 // ***************** DLL related ********************
416 
417 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
418 
419 #ifdef CRYPTOPP_EXPORTS
420 #define CRYPTOPP_IS_DLL
421 #define CRYPTOPP_DLL __declspec(dllexport)
422 #elif defined(CRYPTOPP_IMPORTS)
423 #define CRYPTOPP_IS_DLL
424 #define CRYPTOPP_DLL __declspec(dllimport)
425 #else
426 #define CRYPTOPP_DLL
427 #endif
428 
429 #define CRYPTOPP_API __cdecl
430 
431 #else // CRYPTOPP_WIN32_AVAILABLE
432 
433 #define CRYPTOPP_DLL
434 #define CRYPTOPP_API
435 
436 #endif // CRYPTOPP_WIN32_AVAILABLE
437 
438 #if defined(__MWERKS__)
439 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
440 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
441 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
442 #else
443 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
444 #endif
445 
446 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
447 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
448 #else
449 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
450 #endif
451 
452 #if defined(__MWERKS__)
453 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
454 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
455 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
456 #else
457 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
458 #endif
459 
460 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
461 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
462 #else
463 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
464 #endif
465 
466 #endif