Crypto++
|
00001 #ifndef __x86_64__ 00002 #define CRYPTOPP_DISABLE_SSE2 00003 #endif 00004 00005 #ifndef CRYPTOPP_CONFIG_H 00006 #define CRYPTOPP_CONFIG_H 00007 00008 // ***************** Important Settings ******************** 00009 00010 // define this if running on a big-endian CPU 00011 #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__s390__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__))) 00012 # define IS_BIG_ENDIAN 00013 #endif 00014 00015 // define this if running on a little-endian CPU 00016 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined 00017 #ifndef IS_BIG_ENDIAN 00018 # define IS_LITTLE_ENDIAN 00019 #endif 00020 00021 // define this if you want to disable all OS-dependent features, 00022 // such as sockets and OS-provided random number generators 00023 // #define NO_OS_DEPENDENCE 00024 00025 // Define this to use features provided by Microsoft's CryptoAPI. 00026 // Currently the only feature used is random number generation. 00027 // This macro will be ignored if NO_OS_DEPENDENCE is defined. 00028 #define USE_MS_CRYPTOAPI 00029 00030 // Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used 00031 #ifndef DSA_1024_BIT_MODULUS_ONLY 00032 # define DSA_1024_BIT_MODULUS_ONLY 1 00033 #endif 00034 00035 // ***************** Less Important Settings *************** 00036 00037 // define this to retain (as much as possible) old deprecated function and class names 00038 // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY 00039 00040 #define GZIP_OS_CODE 0 00041 00042 // Try this if your CPU has 256K internal cache or a slow multiply instruction 00043 // and you want a (possibly) faster IDEA implementation using log tables 00044 // #define IDEA_LARGECACHE 00045 00046 // Define this if, for the linear congruential RNG, you want to use 00047 // the original constants as specified in S.K. Park and K.W. Miller's 00048 // CACM paper. 00049 // #define LCRNG_ORIGINAL_NUMBERS 00050 00051 // choose which style of sockets to wrap (mostly useful for cygwin which has both) 00052 #define PREFER_BERKELEY_STYLE_SOCKETS 00053 // #define PREFER_WINDOWS_STYLE_SOCKETS 00054 00055 // set the name of Rijndael cipher, was "Rijndael" before version 5.3 00056 #define CRYPTOPP_RIJNDAEL_NAME "AES" 00057 00058 // ***************** Important Settings Again ******************** 00059 // But the defaults should be ok. 00060 00061 // namespace support is now required 00062 #ifdef NO_NAMESPACE 00063 # error namespace support is now required 00064 #endif 00065 00066 // Define this to workaround a Microsoft CryptoAPI bug where 00067 // each call to CryptAcquireContext causes a 100 KB memory leak. 00068 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext. 00069 #define WORKAROUND_MS_BUG_Q258000 00070 00071 #ifdef CRYPTOPP_DOXYGEN_PROCESSING 00072 // Avoid putting "CryptoPP::" in front of everything in Doxygen output 00073 # define CryptoPP 00074 # define NAMESPACE_BEGIN(x) 00075 # define NAMESPACE_END 00076 // Get Doxygen to generate better documentation for these typedefs 00077 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {}; 00078 #else 00079 # define NAMESPACE_BEGIN(x) namespace x { 00080 # define NAMESPACE_END } 00081 # define DOCUMENTED_TYPEDEF(x, y) typedef x y; 00082 #endif 00083 #define ANONYMOUS_NAMESPACE_BEGIN namespace { 00084 #define USING_NAMESPACE(x) using namespace x; 00085 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x { 00086 #define DOCUMENTED_NAMESPACE_END } 00087 00088 // What is the type of the third parameter to bind? 00089 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int. 00090 // Unfortunately there is no way to tell whether or not socklen_t is defined. 00091 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile. 00092 #ifndef TYPE_OF_SOCKLEN_T 00093 # if defined(_WIN32) || defined(__CYGWIN__) 00094 # define TYPE_OF_SOCKLEN_T int 00095 # else 00096 # define TYPE_OF_SOCKLEN_T ::socklen_t 00097 # endif 00098 #endif 00099 00100 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS) 00101 # define __USE_W32_SOCKETS 00102 #endif 00103 00104 typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs 00105 00106 NAMESPACE_BEGIN(CryptoPP) 00107 00108 typedef unsigned short word16; 00109 typedef unsigned int word32; 00110 00111 #if defined(_MSC_VER) || defined(__BORLANDC__) 00112 typedef unsigned __int64 word64; 00113 #define W64LIT(x) x##ui64 00114 #else 00115 typedef unsigned long long word64; 00116 #define W64LIT(x) x##ULL 00117 #endif 00118 00119 // define large word type, used for file offsets and such 00120 typedef word64 lword; 00121 const lword LWORD_MAX = W64LIT(0xffffffffffffffff); 00122 00123 #ifdef __GNUC__ 00124 #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 00125 #endif 00126 00127 // define hword, word, and dword. these are used for multiprecision integer arithmetic 00128 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx 00129 #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__)) 00130 typedef word32 hword; 00131 typedef word64 word; 00132 #else 00133 #define CRYPTOPP_NATIVE_DWORD_AVAILABLE 00134 #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) || defined(__s390x__) 00135 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400 00136 // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3 00137 // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4 00138 typedef word32 hword; 00139 typedef word64 word; 00140 typedef __uint128_t dword; 00141 typedef __uint128_t word128; 00142 #define CRYPTOPP_WORD128_AVAILABLE 00143 #else 00144 // 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 00145 typedef word16 hword; 00146 typedef word32 word; 00147 typedef word64 dword; 00148 #endif 00149 #else 00150 // being here means the native register size is probably 32 bits or less 00151 #define CRYPTOPP_BOOL_SLOW_WORD64 1 00152 typedef word16 hword; 00153 typedef word32 word; 00154 typedef word64 dword; 00155 #endif 00156 #endif 00157 #ifndef CRYPTOPP_BOOL_SLOW_WORD64 00158 #define CRYPTOPP_BOOL_SLOW_WORD64 0 00159 #endif 00160 00161 const unsigned int WORD_SIZE = sizeof(word); 00162 const unsigned int WORD_BITS = WORD_SIZE * 8; 00163 00164 NAMESPACE_END 00165 00166 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE 00167 // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks. 00168 #if defined(_M_X64) || defined(__x86_64__) 00169 #define CRYPTOPP_L1_CACHE_LINE_SIZE 64 00170 #else 00171 // L1 cache line size is 32 on Pentium III and earlier 00172 #define CRYPTOPP_L1_CACHE_LINE_SIZE 32 00173 #endif 00174 #endif 00175 00176 #if defined(_MSC_VER) 00177 #if _MSC_VER == 1200 00178 #include <malloc.h> 00179 #endif 00180 #if _MSC_VER > 1200 || defined(_mm_free) 00181 #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later 00182 #else 00183 #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack 00184 #endif 00185 #endif 00186 00187 #ifndef CRYPTOPP_ALIGN_DATA 00188 #if defined(CRYPTOPP_MSVC6PP_OR_LATER) 00189 #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) 00190 #elif defined(__GNUC__) 00191 #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) 00192 #else 00193 #define CRYPTOPP_ALIGN_DATA(x) 00194 #endif 00195 #endif 00196 00197 #ifndef CRYPTOPP_SECTION_ALIGN16 00198 #if defined(__GNUC__) && !defined(__APPLE__) 00199 // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on 00200 #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16"))) 00201 #else 00202 #define CRYPTOPP_SECTION_ALIGN16 00203 #endif 00204 #endif 00205 00206 #if defined(_MSC_VER) || defined(__fastcall) 00207 #define CRYPTOPP_FASTCALL __fastcall 00208 #else 00209 #define CRYPTOPP_FASTCALL 00210 #endif 00211 00212 // VC60 workaround: it doesn't allow typename in some places 00213 #if defined(_MSC_VER) && (_MSC_VER < 1300) 00214 #define CPP_TYPENAME 00215 #else 00216 #define CPP_TYPENAME typename 00217 #endif 00218 00219 // VC60 workaround: can't cast unsigned __int64 to float or double 00220 #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER) 00221 #define CRYPTOPP_VC6_INT64 (__int64) 00222 #else 00223 #define CRYPTOPP_VC6_INT64 00224 #endif 00225 00226 #ifdef _MSC_VER 00227 #define CRYPTOPP_NO_VTABLE __declspec(novtable) 00228 #else 00229 #define CRYPTOPP_NO_VTABLE 00230 #endif 00231 00232 #ifdef _MSC_VER 00233 // 4231: nonstandard extension used : 'extern' before template explicit instantiation 00234 // 4250: dominance 00235 // 4251: member needs to have dll-interface 00236 // 4275: base needs to have dll-interface 00237 // 4660: explicitly instantiating a class that's already implicitly instantiated 00238 // 4661: no suitable definition provided for explicit template instantiation request 00239 // 4786: identifer was truncated in debug information 00240 // 4355: 'this' : used in base member initializer list 00241 // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation 00242 # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910) 00243 #endif 00244 00245 #ifdef __BORLANDC__ 00246 // 8037: non-const function called for const object. needed to work around BCB2006 bug 00247 # pragma warn -8037 00248 #endif 00249 00250 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION) 00251 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION 00252 #endif 00253 00254 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION 00255 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 00256 #endif 00257 00258 #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings 00259 #define CRYPTOPP_DISABLE_ASM 00260 #define CRYPTOPP_DISABLE_SSE2 00261 #endif 00262 00263 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))) 00264 // C++Builder 2010 does not allow "call label" where label is defined within inline assembly 00265 #define CRYPTOPP_X86_ASM_AVAILABLE 00266 00267 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300) 00268 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 00269 #else 00270 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 00271 #endif 00272 00273 // 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. 00274 // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version. 00275 #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102) 00276 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1 00277 #else 00278 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0 00279 #endif 00280 #endif 00281 00282 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64) 00283 #define CRYPTOPP_X64_MASM_AVAILABLE 00284 #endif 00285 00286 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__) 00287 #define CRYPTOPP_X64_ASM_AVAILABLE 00288 #endif 00289 00290 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) 00291 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 00292 #else 00293 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0 00294 #endif 00295 00296 #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) 00297 #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1 00298 #else 00299 #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0 00300 #endif 00301 00302 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) 00303 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1 00304 #else 00305 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0 00306 #endif 00307 00308 // how to allocate 16-byte aligned memory (for SSE2) 00309 #if defined(CRYPTOPP_MSVC6PP_OR_LATER) 00310 #define CRYPTOPP_MM_MALLOC_AVAILABLE 00311 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 00312 #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 00313 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) 00314 #define CRYPTOPP_MEMALIGN_AVAILABLE 00315 #else 00316 #define CRYPTOPP_NO_ALIGNED_ALLOC 00317 #endif 00318 00319 // how to disable inlining 00320 #if defined(_MSC_VER) && _MSC_VER >= 1300 00321 # define CRYPTOPP_NOINLINE_DOTDOTDOT 00322 # define CRYPTOPP_NOINLINE __declspec(noinline) 00323 #elif defined(__GNUC__) 00324 # define CRYPTOPP_NOINLINE_DOTDOTDOT 00325 # define CRYPTOPP_NOINLINE __attribute__((noinline)) 00326 #else 00327 # define CRYPTOPP_NOINLINE_DOTDOTDOT ... 00328 # define CRYPTOPP_NOINLINE 00329 #endif 00330 00331 // how to declare class constants 00332 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) 00333 # define CRYPTOPP_CONSTANT(x) enum {x}; 00334 #else 00335 # define CRYPTOPP_CONSTANT(x) static const int x; 00336 #endif 00337 00338 #if defined(_M_X64) || defined(__x86_64__) 00339 #define CRYPTOPP_BOOL_X64 1 00340 #else 00341 #define CRYPTOPP_BOOL_X64 0 00342 #endif 00343 00344 // see http://predef.sourceforge.net/prearch.html 00345 #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) 00346 #define CRYPTOPP_BOOL_X86 1 00347 #else 00348 #define CRYPTOPP_BOOL_X86 0 00349 #endif 00350 00351 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__) 00352 #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS 00353 #endif 00354 00355 #define CRYPTOPP_VERSION 561 00356 00357 // ***************** determine availability of OS features ******************** 00358 00359 #ifndef NO_OS_DEPENDENCE 00360 00361 #if defined(_WIN32) || defined(__CYGWIN__) 00362 #define CRYPTOPP_WIN32_AVAILABLE 00363 #endif 00364 00365 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun) 00366 #define CRYPTOPP_UNIX_AVAILABLE 00367 #endif 00368 00369 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) 00370 # define HIGHRES_TIMER_AVAILABLE 00371 #endif 00372 00373 #ifdef CRYPTOPP_UNIX_AVAILABLE 00374 # define HAS_BERKELEY_STYLE_SOCKETS 00375 #endif 00376 00377 #ifdef CRYPTOPP_WIN32_AVAILABLE 00378 # define HAS_WINDOWS_STYLE_SOCKETS 00379 #endif 00380 00381 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS)) 00382 # define SOCKETS_AVAILABLE 00383 #endif 00384 00385 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS)) 00386 # define USE_WINDOWS_STYLE_SOCKETS 00387 #else 00388 # define USE_BERKELEY_STYLE_SOCKETS 00389 #endif 00390 00391 #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS) 00392 # define WINDOWS_PIPES_AVAILABLE 00393 #endif 00394 00395 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI) 00396 # define NONBLOCKING_RNG_AVAILABLE 00397 # define OS_RNG_AVAILABLE 00398 #endif 00399 00400 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 00401 # define NONBLOCKING_RNG_AVAILABLE 00402 # define BLOCKING_RNG_AVAILABLE 00403 # define OS_RNG_AVAILABLE 00404 # define HAS_PTHREADS 00405 # define THREADS_AVAILABLE 00406 #endif 00407 00408 #ifdef CRYPTOPP_WIN32_AVAILABLE 00409 # define HAS_WINTHREADS 00410 # define THREADS_AVAILABLE 00411 #endif 00412 00413 #endif // NO_OS_DEPENDENCE 00414 00415 // ***************** DLL related ******************** 00416 00417 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 00418 00419 #ifdef CRYPTOPP_EXPORTS 00420 #define CRYPTOPP_IS_DLL 00421 #define CRYPTOPP_DLL __declspec(dllexport) 00422 #elif defined(CRYPTOPP_IMPORTS) 00423 #define CRYPTOPP_IS_DLL 00424 #define CRYPTOPP_DLL __declspec(dllimport) 00425 #else 00426 #define CRYPTOPP_DLL 00427 #endif 00428 00429 #define CRYPTOPP_API __cdecl 00430 00431 #else // CRYPTOPP_WIN32_AVAILABLE 00432 00433 #define CRYPTOPP_DLL 00434 #define CRYPTOPP_API 00435 00436 #endif // CRYPTOPP_WIN32_AVAILABLE 00437 00438 #if defined(__MWERKS__) 00439 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL 00440 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) 00441 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL 00442 #else 00443 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL 00444 #endif 00445 00446 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS) 00447 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL 00448 #else 00449 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS 00450 #endif 00451 00452 #if defined(__MWERKS__) 00453 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class 00454 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) 00455 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class 00456 #else 00457 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class 00458 #endif 00459 00460 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS) 00461 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class 00462 #else 00463 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS 00464 #endif 00465 00466 #endif