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