Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

469 lines
16 KiB

  1. #ifndef CRYPTOPP_CONFIG_H
  2. #define CRYPTOPP_CONFIG_H
  3. // ***************** Important Settings ********************
  4. // define this if running on a big-endian CPU
  5. #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
  6. # define IS_BIG_ENDIAN
  7. #endif
  8. // define this if running on a little-endian CPU
  9. // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
  10. #ifndef IS_BIG_ENDIAN
  11. # define IS_LITTLE_ENDIAN
  12. #endif
  13. // define this if you want to disable all OS-dependent features,
  14. // such as sockets and OS-provided random number generators
  15. // #define NO_OS_DEPENDENCE
  16. // Define this to use features provided by Microsoft's CryptoAPI.
  17. // Currently the only feature used is random number generation.
  18. // This macro will be ignored if NO_OS_DEPENDENCE is defined.
  19. #define USE_MS_CRYPTOAPI
  20. // Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used
  21. #ifndef DSA_1024_BIT_MODULUS_ONLY
  22. # define DSA_1024_BIT_MODULUS_ONLY 1
  23. #endif
  24. // ***************** Less Important Settings ***************
  25. // define this to retain (as much as possible) old deprecated function and class names
  26. // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
  27. #define GZIP_OS_CODE 0
  28. // Try this if your CPU has 256K internal cache or a slow multiply instruction
  29. // and you want a (possibly) faster IDEA implementation using log tables
  30. // #define IDEA_LARGECACHE
  31. // Define this if, for the linear congruential RNG, you want to use
  32. // the original constants as specified in S.K. Park and K.W. Miller's
  33. // CACM paper.
  34. // #define LCRNG_ORIGINAL_NUMBERS
  35. // choose which style of sockets to wrap (mostly useful for cygwin which has both)
  36. #define PREFER_BERKELEY_STYLE_SOCKETS
  37. // #define PREFER_WINDOWS_STYLE_SOCKETS
  38. // set the name of Rijndael cipher, was "Rijndael" before version 5.3
  39. #define CRYPTOPP_RIJNDAEL_NAME "AES"
  40. // ***************** Important Settings Again ********************
  41. // But the defaults should be ok.
  42. // namespace support is now required
  43. #ifdef NO_NAMESPACE
  44. # error namespace support is now required
  45. #endif
  46. // Define this to workaround a Microsoft CryptoAPI bug where
  47. // each call to CryptAcquireContext causes a 100 KB memory leak.
  48. // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
  49. // VALVE: This only applies to Windows 95 and older, we don't need it.
  50. //#define WORKAROUND_MS_BUG_Q258000
  51. #ifdef CRYPTOPP_DOXYGEN_PROCESSING
  52. // Avoid putting "CryptoPP::" in front of everything in Doxygen output
  53. # define CryptoPP
  54. # define NAMESPACE_BEGIN(x)
  55. # define NAMESPACE_END
  56. // Get Doxygen to generate better documentation for these typedefs
  57. # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
  58. #else
  59. # define NAMESPACE_BEGIN(x) namespace x {
  60. # define NAMESPACE_END }
  61. # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
  62. #endif
  63. #define ANONYMOUS_NAMESPACE_BEGIN namespace {
  64. #define USING_NAMESPACE(x) using namespace x;
  65. #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
  66. #define DOCUMENTED_NAMESPACE_END }
  67. // What is the type of the third parameter to bind?
  68. // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
  69. // Unfortunately there is no way to tell whether or not socklen_t is defined.
  70. // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
  71. #ifndef TYPE_OF_SOCKLEN_T
  72. # if defined(_WIN32) || defined(__CYGWIN__)
  73. # define TYPE_OF_SOCKLEN_T int
  74. # else
  75. # define TYPE_OF_SOCKLEN_T ::socklen_t
  76. # endif
  77. #endif
  78. #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
  79. # define __USE_W32_SOCKETS
  80. #endif
  81. typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
  82. NAMESPACE_BEGIN(CryptoPP)
  83. typedef unsigned short word16;
  84. typedef unsigned int word32;
  85. #if defined(_MSC_VER) || defined(__BORLANDC__)
  86. typedef unsigned __int64 word64;
  87. #define W64LIT(x) x##ui64
  88. #else
  89. typedef unsigned long long word64;
  90. #define W64LIT(x) x##ULL
  91. #endif
  92. // define large word type, used for file offsets and such
  93. typedef word64 lword;
  94. const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
  95. #ifdef __GNUC__
  96. #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  97. #endif
  98. // define hword, word, and dword. these are used for multiprecision integer arithmetic
  99. // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
  100. #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__))
  101. typedef word32 hword;
  102. typedef word64 word;
  103. #else
  104. #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
  105. #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
  106. #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
  107. // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
  108. // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
  109. typedef word32 hword;
  110. typedef word64 word;
  111. typedef __uint128_t dword;
  112. typedef __uint128_t word128;
  113. #define CRYPTOPP_WORD128_AVAILABLE
  114. #else
  115. // 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
  116. typedef word16 hword;
  117. typedef word32 word;
  118. typedef word64 dword;
  119. #endif
  120. #else
  121. // being here means the native register size is probably 32 bits or less
  122. #define CRYPTOPP_BOOL_SLOW_WORD64 1
  123. typedef word16 hword;
  124. typedef word32 word;
  125. typedef word64 dword;
  126. #endif
  127. #endif
  128. #ifndef CRYPTOPP_BOOL_SLOW_WORD64
  129. #define CRYPTOPP_BOOL_SLOW_WORD64 0
  130. #endif
  131. const unsigned int WORD_SIZE = sizeof(word);
  132. const unsigned int WORD_BITS = WORD_SIZE * 8;
  133. NAMESPACE_END
  134. #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
  135. // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
  136. #if defined(_M_X64) || defined(__x86_64__)
  137. #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
  138. #else
  139. // L1 cache line size is 32 on Pentium III and earlier
  140. #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
  141. #endif
  142. #endif
  143. #if defined(_MSC_VER)
  144. #if _MSC_VER == 1200
  145. #include <malloc.h>
  146. #endif
  147. #if _MSC_VER > 1200 || defined(_mm_free)
  148. #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
  149. #else
  150. #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
  151. #endif
  152. #endif
  153. #ifndef CRYPTOPP_ALIGN_DATA
  154. #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
  155. #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
  156. #elif defined(__GNUC__)
  157. #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
  158. #else
  159. #define CRYPTOPP_ALIGN_DATA(x)
  160. #endif
  161. #endif
  162. #ifndef CRYPTOPP_SECTION_ALIGN16
  163. #if defined(__GNUC__) && !defined(__APPLE__)
  164. // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
  165. #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
  166. #else
  167. #define CRYPTOPP_SECTION_ALIGN16
  168. #endif
  169. #endif
  170. #if defined(_MSC_VER) || defined(__fastcall)
  171. #define CRYPTOPP_FASTCALL __fastcall
  172. #else
  173. #define CRYPTOPP_FASTCALL
  174. #endif
  175. // VC60 workaround: it doesn't allow typename in some places
  176. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  177. #define CPP_TYPENAME
  178. #else
  179. #define CPP_TYPENAME typename
  180. #endif
  181. // VC60 workaround: can't cast unsigned __int64 to float or double
  182. #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
  183. #define CRYPTOPP_VC6_INT64 (__int64)
  184. #else
  185. #define CRYPTOPP_VC6_INT64
  186. #endif
  187. #ifdef _MSC_VER
  188. #define CRYPTOPP_NO_VTABLE __declspec(novtable)
  189. #else
  190. #define CRYPTOPP_NO_VTABLE
  191. #endif
  192. #ifdef _MSC_VER
  193. // 4231: nonstandard extension used : 'extern' before template explicit instantiation
  194. // 4250: dominance
  195. // 4251: member needs to have dll-interface
  196. // 4275: base needs to have dll-interface
  197. // 4660: explicitly instantiating a class that's already implicitly instantiated
  198. // 4661: no suitable definition provided for explicit template instantiation request
  199. // 4786: identifer was truncated in debug information
  200. // 4355: 'this' : used in base member initializer list
  201. // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
  202. # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910)
  203. #endif
  204. #ifdef __BORLANDC__
  205. // 8037: non-const function called for const object. needed to work around BCB2006 bug
  206. # pragma warn -8037
  207. #endif
  208. #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
  209. #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
  210. #endif
  211. #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
  212. #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
  213. #endif
  214. #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
  215. #define CRYPTOPP_DISABLE_ASM
  216. #define CRYPTOPP_DISABLE_SSE2
  217. #endif
  218. #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
  219. // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
  220. #define CRYPTOPP_X86_ASM_AVAILABLE
  221. #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
  222. #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
  223. #else
  224. #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
  225. #endif
  226. // 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.
  227. // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
  228. #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
  229. #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
  230. #else
  231. #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
  232. #endif
  233. #endif
  234. #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
  235. #define CRYPTOPP_X64_MASM_AVAILABLE
  236. #endif
  237. #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
  238. #define CRYPTOPP_X64_ASM_AVAILABLE
  239. #endif
  240. #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
  241. #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
  242. #else
  243. #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
  244. #endif
  245. #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)
  246. #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
  247. #else
  248. #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
  249. #endif
  250. #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
  251. #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
  252. #else
  253. #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
  254. #endif
  255. // VALVE: Our allocator does not return aligned memory
  256. #if defined(WIN32)
  257. #define MEMALIGN_OVERRIDE
  258. #endif
  259. // how to allocate 16-byte aligned memory (for SSE2)
  260. #if defined(CRYPTOPP_MSVC6PP_OR_LATER) && !defined(MEMALIGN_OVERRIDE)
  261. #define CRYPTOPP_MM_MALLOC_AVAILABLE
  262. #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
  263. #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
  264. #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
  265. #define CRYPTOPP_MEMALIGN_AVAILABLE
  266. #else
  267. #define CRYPTOPP_NO_ALIGNED_ALLOC
  268. #endif
  269. // how to disable inlining
  270. #if defined(_MSC_VER) && _MSC_VER >= 1300
  271. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  272. # define CRYPTOPP_NOINLINE __declspec(noinline)
  273. #elif defined(__GNUC__)
  274. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  275. # define CRYPTOPP_NOINLINE __attribute__((noinline))
  276. #else
  277. # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
  278. # define CRYPTOPP_NOINLINE
  279. #endif
  280. // how to declare class constants
  281. #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
  282. # define CRYPTOPP_CONSTANT(x) enum {x};
  283. #else
  284. # define CRYPTOPP_CONSTANT(x) static const int x;
  285. #endif
  286. #if defined(_M_X64) || defined(__x86_64__)
  287. #define CRYPTOPP_BOOL_X64 1
  288. #else
  289. #define CRYPTOPP_BOOL_X64 0
  290. #endif
  291. // see http://predef.sourceforge.net/prearch.html
  292. // VALVE: Added !defined(_M_X64) because our build helpfully defines both _M_X64 and __i386__.
  293. #if ( defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) ) && !defined(_M_X64)
  294. #define CRYPTOPP_BOOL_X86 1
  295. #else
  296. #define CRYPTOPP_BOOL_X86 0
  297. #endif
  298. #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)
  299. #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
  300. #endif
  301. #define CRYPTOPP_VERSION 561
  302. // ***************** determine availability of OS features ********************
  303. #ifndef NO_OS_DEPENDENCE
  304. #if defined(_WIN32) || defined(__CYGWIN__)
  305. #define CRYPTOPP_WIN32_AVAILABLE
  306. #endif
  307. #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
  308. #define CRYPTOPP_UNIX_AVAILABLE
  309. #endif
  310. #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
  311. # define HIGHRES_TIMER_AVAILABLE
  312. #endif
  313. #ifdef CRYPTOPP_UNIX_AVAILABLE
  314. # define HAS_BERKELEY_STYLE_SOCKETS
  315. #endif
  316. #ifdef CRYPTOPP_WIN32_AVAILABLE
  317. # define HAS_WINDOWS_STYLE_SOCKETS
  318. #endif
  319. #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
  320. # define SOCKETS_AVAILABLE
  321. #endif
  322. #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
  323. # define USE_WINDOWS_STYLE_SOCKETS
  324. #else
  325. # define USE_BERKELEY_STYLE_SOCKETS
  326. #endif
  327. #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
  328. # define WINDOWS_PIPES_AVAILABLE
  329. #endif
  330. #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
  331. # define NONBLOCKING_RNG_AVAILABLE
  332. # define OS_RNG_AVAILABLE
  333. #endif
  334. #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
  335. # define NONBLOCKING_RNG_AVAILABLE
  336. # define BLOCKING_RNG_AVAILABLE
  337. # define OS_RNG_AVAILABLE
  338. # define HAS_PTHREADS
  339. # define THREADS_AVAILABLE
  340. #endif
  341. #ifdef CRYPTOPP_WIN32_AVAILABLE
  342. # define HAS_WINTHREADS
  343. # define THREADS_AVAILABLE
  344. #endif
  345. #endif // NO_OS_DEPENDENCE
  346. // ***************** DLL related ********************
  347. #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
  348. #ifdef CRYPTOPP_EXPORTS
  349. #define CRYPTOPP_IS_DLL
  350. #define CRYPTOPP_DLL __declspec(dllexport)
  351. #elif defined(CRYPTOPP_IMPORTS)
  352. #define CRYPTOPP_IS_DLL
  353. #define CRYPTOPP_DLL __declspec(dllimport)
  354. #else
  355. #define CRYPTOPP_DLL
  356. #endif
  357. #define CRYPTOPP_API __cdecl
  358. #else // CRYPTOPP_WIN32_AVAILABLE
  359. #define CRYPTOPP_DLL
  360. #define CRYPTOPP_API
  361. #endif // CRYPTOPP_WIN32_AVAILABLE
  362. #if defined(__MWERKS__)
  363. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
  364. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  365. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  366. #else
  367. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
  368. #endif
  369. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
  370. #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  371. #else
  372. #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
  373. #endif
  374. #if defined(__MWERKS__)
  375. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
  376. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  377. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
  378. #else
  379. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
  380. #endif
  381. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
  382. #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
  383. #else
  384. #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
  385. #endif
  386. #endif