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(__sparc__) || defined(__hppa__) || defined(__ppc__) || 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 if your compiler does not support namespaces
27 // #define NO_NAMESPACE
28 #ifdef NO_NAMESPACE
29 #define std
30 #define CryptoPP
31 #define USING_NAMESPACE(x)
32 #define NAMESPACE_BEGIN(x)
33 #define NAMESPACE_END
34 #define ANONYMOUS_NAMESPACE_BEGIN
35 #else
36 #define USING_NAMESPACE(x) using namespace x;
37 #define NAMESPACE_BEGIN(x) namespace x {
38 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
39 #define NAMESPACE_END }
40 #endif
41 
42 // ***************** Less Important Settings ***************
43 
44 // switch between different secure memory allocation mechnisms, this is the only
45 // one available right now
46 #define SECALLOC_DEFAULT
47 
48 #define GZIP_OS_CODE 0
49 
50 // Try this if your CPU has 256K internal cache or a slow multiply instruction
51 // and you want a (possibly) faster IDEA implementation using log tables
52 // #define IDEA_LARGECACHE
53 
54 // Try this if you have a large cache or your CPU is slow manipulating
55 // individual bytes.
56 // #define DIAMOND_USE_PERMTABLE
57 
58 // Define this if, for the linear congruential RNG, you want to use
59 // the original constants as specified in S.K. Park and K.W. Miller's
60 // CACM paper.
61 // #define LCRNG_ORIGINAL_NUMBERS
62 
63 // choose which style of sockets to wrap (mostly useful for cygwin which has both)
64 #define PREFER_BERKELEY_STYLE_SOCKETS
65 // #define PREFER_WINDOWS_STYLE_SOCKETS
66 
67 // ***************** Important Settings Again ********************
68 // But the defaults should be ok.
69 
70 typedef unsigned char byte;     // moved outside namespace for Borland C++Builder 5
71 
72 NAMESPACE_BEGIN(CryptoPP)
73 
74 typedef unsigned short word16;
75 #if defined(__alpha) && !defined(_MSC_VER)
76 typedef unsigned int word32;
77 #else
78 typedef unsigned long word32;
79 #endif
80 
81 #if defined(__GNUC__) || defined(__MWERKS__)
82 #define WORD64_AVAILABLE
83 typedef unsigned long long word64;
84 #define W64LIT(x) x##LL
85 #elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
86 #define WORD64_AVAILABLE
87 typedef unsigned __int64 word64;
88 #define W64LIT(x) x##ui64
89 #endif
90 
91 // defined this if your CPU is not 64-bit
92 #if defined(WORD64_AVAILABLE) && !defined(__alpha)
93 #define SLOW_WORD64
94 #endif
95 
96 // word should have the same size as your CPU registers
97 // dword should be twice as big as word
98 
99 #if (defined(__GNUC__) && !defined(__alpha)) || defined(__MWERKS__)
100 typedef unsigned long word;
101 typedef unsigned long long dword;
102 #elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
103 typedef unsigned __int32 word;
104 typedef unsigned __int64 dword;
105 #else
106 typedef unsigned int word;
107 typedef unsigned long dword;
108 #endif
109 
110 const unsigned int WORD_SIZE = sizeof(word);
111 const unsigned int WORD_BITS = WORD_SIZE * 8;
112 
113 #define LOW_WORD(x) (word)(x)
114 
115 union dword_union
116 {
dword_union(const dword & dw)117 	dword_union (const dword &dw) : dw(dw) {}
118 	dword dw;
119 	word w[2];
120 };
121 
122 #ifdef IS_LITTLE_ENDIAN
123 #define HIGH_WORD(x) (dword_union(x).w[1])
124 #else
125 #define HIGH_WORD(x) (dword_union(x).w[0])
126 #endif
127 
128 // if the above HIGH_WORD macro doesn't work (if you are not sure, compile it
129 // and run the validation tests), try this:
130 // #define HIGH_WORD(x) (word)((x)>>WORD_BITS)
131 
132 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
133 #define INTEL_INTRINSICS
134 #define FAST_ROTATE
135 #elif defined(__MWERKS__) && TARGET_CPU_PPC
136 #define PPC_INTRINSICS
137 #define FAST_ROTATE
138 #elif defined(__GNUC__) && defined(__i386__)
139 // GCC does peephole optimizations which should result in using rotate instructions
140 #define FAST_ROTATE
141 #endif
142 
143 // can't use std::min or std::max in MSVC60 or Cygwin 1.1.0
144 template <class _Tp>
STDMIN(const _Tp & __a,const _Tp & __b)145 inline const _Tp& STDMIN(const _Tp& __a, const _Tp& __b) {
146   return __b < __a ? __b : __a;
147 }
148 
149 template <class _Tp>
STDMAX(const _Tp & __a,const _Tp & __b)150 inline const _Tp& STDMAX(const _Tp& __a, const _Tp& __b) {
151   return  __a < __b ? __b : __a;
152 }
153 
154 #ifdef _MSC_VER
155 // 4250: dominance
156 // 4660: explicitly instantiating a class that's already implicitly instantiated
157 // 4786: identifer was truncated in debug information
158 // 4355: 'this' : used in base member initializer list
159 // 4800: converting int to bool
160 #pragma warning(disable: 4250 4660 4786 4355 4800)
161 #endif
162 
163 NAMESPACE_END
164 
165 #endif
166