- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# config.h

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