Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | 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(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__PPC__) || 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 // Try this if you have a large cache or your CPU is slow manipulating
    00043 // individual bytes.
    00044 // #define DIAMOND_USE_PERMTABLE
    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 // ***************** Important Settings Again ********************
    00056 // But the defaults should be ok.
    00057
    00058 // namespace support is now required
    00059 #ifdef NO_NAMESPACE
    00060 #       error namespace support is now required
    00061 #endif
    00062
    00063 // Define this to workaround a Microsoft CryptoAPI bug where
    00064 // each call to CryptAcquireContext causes a 100 KB memory leak.
    00065 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
    00066 #define WORKAROUND_MS_BUG_Q258000
    00067
    00068 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
    00069 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
    00070 #       define CryptoPP
    00071 #       define NAMESPACE_BEGIN(x)
    00072 #       define NAMESPACE_END
    00073 #else
    00074 #       define NAMESPACE_BEGIN(x) namespace x {
    00075 #       define NAMESPACE_END }
    00076 #endif
    00077 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
    00078 #define USING_NAMESPACE(x) using namespace x;
    00079 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
    00080 #define DOCUMENTED_NAMESPACE_END }
    00081
    00082 // What is the type of the third parameter to bind?
    00083 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
    00084 // Unfortunately there is no way to tell whether or not socklen_t is defined.
    00085 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
    00086 #ifndef TYPE_OF_SOCKLEN_T
    00087 #       if defined(_WIN32) || defined(__CYGWIN__)
    00088 #               define TYPE_OF_SOCKLEN_T int
    00089 #       else
    00090 #               define TYPE_OF_SOCKLEN_T ::socklen_t
    00091 #       endif
    00092 #endif
    00093
    00094 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
    00095 #       define __USE_W32_SOCKETS
    00096 #endif
    00097
    00098 typedef unsigned char byte;     // moved outside namespace for Borland C++Builder 5
    00099
    00100 NAMESPACE_BEGIN(CryptoPP)
    00101
    00102 typedef unsigned short word16;
    00103 typedef unsigned int word32;
    00104
    00105 #if defined(__GNUC__) || defined(__MWERKS__)
    00106 #       define WORD64_AVAILABLE
    00107         typedef unsigned long long word64;
    00108 #       define W64LIT(x) x##LL
    00109 #elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
    00110 #       define WORD64_AVAILABLE
    00111         typedef unsigned __int64 word64;
    00112 #       define W64LIT(x) x##ui64
    00113 #endif
    00114
    00115 // defined this if your CPU is not 64-bit
    00116 #if defined(WORD64_AVAILABLE) && !defined(__alpha)
    00117 #       define SLOW_WORD64
    00118 #endif
    00119
    00120 // word should have the same size as your CPU registers
    00121 // dword should be twice as big as word
    00122
    00123 #if (defined(__GNUC__) && !defined(__alpha)) || defined(__MWERKS__)
    00124         typedef unsigned long word;
    00125         typedef unsigned long long dword;
    00126 #elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
    00127         typedef unsigned __int32 word;
    00128         typedef unsigned __int64 dword;
    00129 #else
    00130         typedef unsigned int word;
    00131         typedef unsigned long dword;
    00132 #endif
    00133
    00134 const unsigned int WORD_SIZE = sizeof(word);
    00135 const unsigned int WORD_BITS = WORD_SIZE * 8;
    00136
    00137 #define LOW_WORD(x) (word)(x)
    00138
    00139 union dword_union
    00140 {
    00141         dword_union (const dword &dw) : dw(dw) {}
    00142         dword dw;
    00143         word w[2];
    00144 };
    00145
    00146 #ifdef IS_LITTLE_ENDIAN
    00147 #       define HIGH_WORD(x) (dword_union(x).w[1])
    00148 #else
    00149 #       define HIGH_WORD(x) (dword_union(x).w[0])
    00150 #endif
    00151
    00152 // if the above HIGH_WORD macro doesn't work (if you are not sure, compile it
    00153 // and run the validation tests), try this:
    00154 // #define HIGH_WORD(x) (word)((x)>>WORD_BITS)
    00155
    00156 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
    00157 #       define INTEL_INTRINSICS
    00158 #       define FAST_ROTATE
    00159 #elif defined(__MWERKS__) && TARGET_CPU_PPC
    00160 #       define PPC_INTRINSICS
    00161 #       define FAST_ROTATE
    00162 #elif defined(__GNUC__) && defined(__i386__)
    00163         // GCC does peephole optimizations which should result in using rotate instructions
    00164 #       define FAST_ROTATE
    00165 #endif
    00166
    00167 NAMESPACE_END
    00168
    00169 // VC60 workaround: it doesn't allow typename in some places
    00170 #if defined(_MSC_VER) && (_MSC_VER < 1300)
    00171 #define CPP_TYPENAME
    00172 #else
    00173 #define CPP_TYPENAME typename
    00174 #endif
    00175
    00176 #ifdef _MSC_VER
    00177         // 4231: nonstandard extension used : 'extern' before template explicit instantiation
    00178         // 4250: dominance
    00179         // 4251: member needs to have dll-interface
    00180         // 4275: base needs to have dll-interface
    00181         // 4660: explicitly instantiating a class that's already implicitly instantiated
    00182         // 4661: no suitable definition provided for explicit template instantiation request
    00183         // 4786: identifer was truncated in debug information
    00184         // 4355: 'this' : used in base member initializer list
    00185 #       pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355)
    00186 #endif
    00187
    00188 #ifdef _MSC_VER
    00189
    00190 #ifdef CRYPTOPP_EXPORTS
    00191 #define CRYPTOPP_IS_DLL
    00192 #define CRYPTOPP_DLL __declspec(dllexport)
    00193 #elif defined(CRYPTOPP_IMPORTS)
    00194 #define CRYPTOPP_IS_DLL
    00195 #define CRYPTOPP_DLL __declspec(dllimport)
    00196 #else
    00197 #define CRYPTOPP_DLL
    00198 #endif
    00199
    00200 #define CRYPTOPP_API __stdcall
    00201
    00202 #else   // _MSC_VER
    00203
    00204 #define CRYPTOPP_DLL
    00205 #define CRYPTOPP_API
    00206
    00207 #endif  // _MSC_VER
    00208
    00209 #ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
    00210 #define CRYPTOPP_MANUAL_EXTERN
    00211 #else
    00212 #define CRYPTOPP_MANUAL_EXTERN extern
    00213 #endif
    00214
    00215 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_MANUAL_EXTERN template class CRYPTOPP_DLL
    00216
    00217 // ***************** determine availability of OS features ********************
    00218
    00219 #ifndef NO_OS_DEPENDENCE
    00220
    00221 #if defined(_WIN32) || defined(__CYGWIN__)
    00222 #define CRYPTOPP_WIN32_AVAILABLE
    00223 #endif
    00224
    00225 #if !defined(NO_OS_DEPENDENCE) && defined(WORD64_AVAILABLE) && (defined(_WIN32) || defined(__unix__) || defined(macintosh))
    00226 #       define HIGHRES_TIMER_AVAILABLE
    00227 #endif
    00228
    00229 #if defined(__unix__)
    00230 #       define HAS_BERKELEY_STYLE_SOCKETS
    00231 #endif
    00232
    00233 #ifdef CRYPTOPP_WIN32_AVAILABLE
    00234 #       define HAS_WINDOWS_STYLE_SOCKETS
    00235 #endif
    00236
    00237 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
    00238 #       define SOCKETS_AVAILABLE
    00239 #endif
    00240
    00241 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
    00242 #       define USE_WINDOWS_STYLE_SOCKETS
    00243 #else
    00244 #       define USE_BERKELEY_STYLE_SOCKETS
    00245 #endif
    00246
    00247 #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
    00248 #       define WINDOWS_PIPES_AVAILABLE
    00249 #endif
    00250
    00251 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
    00252 #       define NONBLOCKING_RNG_AVAILABLE
    00253 #       define OS_RNG_AVAILABLE
    00254 #endif
    00255
    00256 #if (defined(__FreeBSD__) || defined(__linux__) || defined(__MACH__))
    00257 #       define NONBLOCKING_RNG_AVAILABLE
    00258 #       define BLOCKING_RNG_AVAILABLE
    00259 #       define OS_RNG_AVAILABLE
    00260 #endif
    00261
    00262 #ifdef __unix__
    00263 #       define HAS_PTHREADS
    00264 #       define THREADS_AVAILABLE
    00265 #endif
    00266
    00267 #ifdef CRYPTOPP_WIN32_AVAILABLE
    00268 #       define HAS_WINTHREADS
    00269 #       define THREADS_AVAILABLE
    00270 #endif
    00271
    00272 #endif  // NO_OS_DEPENDENCE
    00273
    00274 #endif