1
#ifndef CRYPTOPP_CONFIG_H
2
#define CRYPTOPP_CONFIG_H
4
// ***************** Important Settings ********************
8
#undef IS_LITTLE_ENDIAN
10
// define this if you want to disable all OS-dependent features,
11
// such as sockets and OS-provided random number generators
12
// #define NO_OS_DEPENDENCE
14
// Define this to use features provided by Microsoft's CryptoAPI.
15
// Currently the only feature used is random number generation.
16
// This macro will be ignored if NO_OS_DEPENDENCE is defined.
17
#define USE_MS_CRYPTOAPI
19
// Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used
20
#ifndef DSA_1024_BIT_MODULUS_ONLY
21
# define DSA_1024_BIT_MODULUS_ONLY 1
24
// ***************** Less Important Settings ***************
26
// define this to retain (as much as possible) old deprecated function and class names
27
// #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
29
#define GZIP_OS_CODE 0
31
// Try this if your CPU has 256K internal cache or a slow multiply instruction
32
// and you want a (possibly) faster IDEA implementation using log tables
33
// #define IDEA_LARGECACHE
35
// Define this if, for the linear congruential RNG, you want to use
36
// the original constants as specified in S.K. Park and K.W. Miller's
38
// #define LCRNG_ORIGINAL_NUMBERS
40
// choose which style of sockets to wrap (mostly useful for cygwin which has both)
41
#define PREFER_BERKELEY_STYLE_SOCKETS
42
// #define PREFER_WINDOWS_STYLE_SOCKETS
44
// ***************** Important Settings Again ********************
45
// But the defaults should be ok.
47
// namespace support is now required
49
# error namespace support is now required
52
// Define this to workaround a Microsoft CryptoAPI bug where
53
// each call to CryptAcquireContext causes a 100 KB memory leak.
54
// Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
55
#define WORKAROUND_MS_BUG_Q258000
57
#ifdef CRYPTOPP_DOXYGEN_PROCESSING
58
// Avoid putting "CryptoPP::" in front of everything in Doxygen output
60
# define NAMESPACE_BEGIN(x)
61
# define NAMESPACE_END
62
// Get Doxygen to generate better documentation for these typedefs
63
# define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
65
# define NAMESPACE_BEGIN(x) namespace x {
66
# define NAMESPACE_END }
67
# define DOCUMENTED_TYPEDEF(x, y) typedef x y;
69
#define ANONYMOUS_NAMESPACE_BEGIN namespace {
70
#define USING_NAMESPACE(x) using namespace x;
71
#define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
72
#define DOCUMENTED_NAMESPACE_END }
74
// What is the type of the third parameter to bind?
75
// For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
76
// Unfortunately there is no way to tell whether or not socklen_t is defined.
77
// To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
78
#ifndef TYPE_OF_SOCKLEN_T
79
# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MACH__)
80
# define TYPE_OF_SOCKLEN_T int
82
# define TYPE_OF_SOCKLEN_T ::socklen_t
86
#if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
87
# define __USE_W32_SOCKETS
90
typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
92
NAMESPACE_BEGIN(CryptoPP)
94
typedef unsigned short word16;
95
typedef unsigned int word32;
97
#if defined(__GNUC__) || defined(__MWERKS__)
98
#define WORD64_AVAILABLE
99
typedef unsigned long long word64;
100
#define W64LIT(x) x##LL
101
#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
102
#define WORD64_AVAILABLE
103
typedef unsigned __int64 word64;
104
#define W64LIT(x) x##ui64
107
// define largest word type
108
#ifdef WORD64_AVAILABLE
109
typedef word64 lword;
111
typedef word32 lword;
114
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64)
115
// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers doesn't
116
// allow any way to access the 64-bit by 64-bit multiply instruction without using
117
// assembly, so in order to use word64 as word, the assembly instruction must be defined
118
// in Dword::Multiply().
119
typedef word32 hword;
122
#define CRYPTOPP_NATIVE_DWORD_AVAILABLE
123
#ifdef WORD64_AVAILABLE
124
#define CRYPTOPP_SLOW_WORD64 // defined this if your CPU is not 64-bit to use alternative code that avoids word64
125
typedef word16 hword;
127
typedef word64 dword;
131
typedef word32 dword;
135
const unsigned int WORD_SIZE = sizeof(word);
136
const unsigned int WORD_BITS = WORD_SIZE * 8;
138
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
139
#define INTEL_INTRINSICS
141
#elif defined(__MWERKS__) && TARGET_CPU_PPC
142
#define PPC_INTRINSICS
144
#elif defined(__GNUC__) && defined(__i386__)
145
// GCC does peephole optimizations which should result in using rotate instructions
151
// VC60 workaround: it doesn't allow typename in some places
152
#if defined(_MSC_VER) && (_MSC_VER < 1300)
155
#define CPP_TYPENAME typename
159
#define CRYPTOPP_NO_VTABLE __declspec(novtable)
161
#define CRYPTOPP_NO_VTABLE
165
// 4231: nonstandard extension used : 'extern' before template explicit instantiation
167
// 4251: member needs to have dll-interface
168
// 4275: base needs to have dll-interface
169
// 4660: explicitly instantiating a class that's already implicitly instantiated
170
// 4661: no suitable definition provided for explicit template instantiation request
171
// 4786: identifer was truncated in debug information
172
// 4355: 'this' : used in base member initializer list
173
# pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355)
176
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
177
#define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
180
#ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
181
#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
184
// CodeWarrior defines _MSC_VER
185
#if !defined(CRYPTOPP_DISABLE_X86ASM) && ((defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86)) || (defined(__GNUC__) && defined(__i386__)))
186
#define CRYPTOPP_X86ASM_AVAILABLE
189
// ***************** determine availability of OS features ********************
191
#ifndef NO_OS_DEPENDENCE
193
#if defined(_WIN32) || defined(__CYGWIN__)
194
#define CRYPTOPP_WIN32_AVAILABLE
197
#if defined(__unix__) || defined(__MACH__)
198
#define CRYPTOPP_UNIX_AVAILABLE
201
#if defined(WORD64_AVAILABLE) && (defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE))
202
# define HIGHRES_TIMER_AVAILABLE
205
#ifdef CRYPTOPP_UNIX_AVAILABLE
206
# define HAS_BERKELEY_STYLE_SOCKETS
209
#ifdef CRYPTOPP_WIN32_AVAILABLE
210
# define HAS_WINDOWS_STYLE_SOCKETS
213
#if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
214
# define SOCKETS_AVAILABLE
217
#if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
218
# define USE_WINDOWS_STYLE_SOCKETS
220
# define USE_BERKELEY_STYLE_SOCKETS
223
#if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
224
# define WINDOWS_PIPES_AVAILABLE
227
#if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
228
# define NONBLOCKING_RNG_AVAILABLE
229
# define OS_RNG_AVAILABLE
232
#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
233
# define NONBLOCKING_RNG_AVAILABLE
234
# define BLOCKING_RNG_AVAILABLE
235
# define OS_RNG_AVAILABLE
236
# define HAS_PTHREADS
237
# define THREADS_AVAILABLE
240
#ifdef CRYPTOPP_WIN32_AVAILABLE
241
# define HAS_WINTHREADS
242
# define THREADS_AVAILABLE
245
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
246
# define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
249
#if defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
250
# define CRYPTOPP_MEMALIGN_AVAILABLE
253
#endif // NO_OS_DEPENDENCE
255
// ***************** DLL related ********************
257
#ifdef CRYPTOPP_WIN32_AVAILABLE
259
#ifdef CRYPTOPP_EXPORTS
260
#define CRYPTOPP_IS_DLL
261
#define CRYPTOPP_DLL __declspec(dllexport)
262
#elif defined(CRYPTOPP_IMPORTS)
263
#define CRYPTOPP_IS_DLL
264
#define CRYPTOPP_DLL __declspec(dllimport)
269
#define CRYPTOPP_API __stdcall
270
#define CRYPTOPP_CDECL __cdecl
272
#else // CRYPTOPP_WIN32_AVAILABLE
276
#define CRYPTOPP_CDECL
278
#endif // CRYPTOPP_WIN32_AVAILABLE
280
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
281
#define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
282
#elif defined(__MWERKS__)
283
#define CRYPTOPP_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
285
#define CRYPTOPP_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
288
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
289
#define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
290
#elif defined(__MWERKS__)
291
#define CRYPTOPP_STATIC_TEMPLATE_CLASS extern class
293
#define CRYPTOPP_STATIC_TEMPLATE_CLASS extern template class