2017-01-27 12:05:45 +00:00
|
|
|
// config.h - originally written and placed in the public domain by Wei Dai
|
2015-11-18 20:32:28 +00:00
|
|
|
|
2015-11-23 00:17:15 +00:00
|
|
|
//! \file config.h
|
2015-11-18 20:32:28 +00:00
|
|
|
//! \brief Library configuration file
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifndef CRYPTOPP_CONFIG_H
|
|
|
|
#define CRYPTOPP_CONFIG_H
|
|
|
|
|
|
|
|
// ***************** Important Settings ********************
|
|
|
|
|
|
|
|
// define this if running on a big-endian CPU
|
2016-04-06 05:47:45 +00:00
|
|
|
#if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || (defined(__m68k__) || defined(__MC68K__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
|
2015-11-05 06:59:46 +00:00
|
|
|
# define IS_BIG_ENDIAN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// define this if running on a little-endian CPU
|
|
|
|
// big endian will be assumed if IS_LITTLE_ENDIAN is not defined
|
|
|
|
#ifndef IS_BIG_ENDIAN
|
|
|
|
# define IS_LITTLE_ENDIAN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Sanity checks. Some processors have more than big-, little- and bi-endian modes. PDP mode, where order results in "4312", should
|
|
|
|
// raise red flags immediately. Additionally, mis-classified machines, like (previosuly) S/390, should raise red flags immediately.
|
|
|
|
#if defined(IS_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
|
|
|
|
# error "IS_BIG_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_BIG_ENDIAN__"
|
|
|
|
#endif
|
|
|
|
#if defined(IS_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
|
|
|
|
# error "IS_LITTLE_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_LITTLE_ENDIAN__"
|
|
|
|
#endif
|
|
|
|
|
2016-01-08 11:53:27 +00:00
|
|
|
// Define this if you want to disable all OS-dependent features,
|
2015-11-05 06:59:46 +00:00
|
|
|
// such as sockets and OS-provided random number generators
|
|
|
|
// #define NO_OS_DEPENDENCE
|
|
|
|
|
|
|
|
// Define this to use features provided by Microsoft's CryptoAPI.
|
2016-05-03 04:23:05 +00:00
|
|
|
// Currently the only feature used is Windows random number generation.
|
2015-11-05 06:59:46 +00:00
|
|
|
// This macro will be ignored if NO_OS_DEPENDENCE is defined.
|
2016-05-03 04:23:05 +00:00
|
|
|
// #define USE_MS_CRYPTOAPI
|
|
|
|
|
|
|
|
// Define this to use features provided by Microsoft's CryptoNG API.
|
|
|
|
// CryptoNG API is available in Vista and above and its cross platform,
|
|
|
|
// including desktop apps and store apps. Currently the only feature
|
|
|
|
// used is Windows random number generation.
|
|
|
|
// This macro will be ignored if NO_OS_DEPENDENCE is defined.
|
|
|
|
// #define USE_MS_CNGAPI
|
|
|
|
|
|
|
|
// If the user did not make a choice, then select CryptoNG if either
|
|
|
|
// Visual Studio 2015 is available, or Windows 10 or above is available.
|
|
|
|
#if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI)
|
|
|
|
# if (_MSC_VER >= 1900) || ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
|
|
|
|
# define USE_MS_CNGAPI
|
|
|
|
# else
|
|
|
|
# define USE_MS_CRYPTOAPI
|
|
|
|
# endif
|
|
|
|
#endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
// Define this to ensure C/C++ standard compliance and respect for GCC aliasing rules and other alignment fodder. If you
|
|
|
|
// experience a break with GCC at -O3, you should try this first. Guard it in case its set on the command line (and it differs).
|
|
|
|
#ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
|
2016-09-18 16:36:50 +00:00
|
|
|
# define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ***************** Less Important Settings ***************
|
|
|
|
|
2017-01-27 11:02:58 +00:00
|
|
|
// Library version macro. Since this macro is in a header, it reflects
|
|
|
|
// the version of the library the headers came from. It is not
|
|
|
|
// necessarily the version of the library built as a shared object if
|
|
|
|
// versions are inadvertently mixed and matched.
|
2017-02-21 17:59:20 +00:00
|
|
|
#define CRYPTOPP_VERSION 600
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2015-12-26 04:50:28 +00:00
|
|
|
// Define this if you want to set a prefix for TestData/ and TestVectors/
|
|
|
|
// Be mindful of the trailing slash since its simple concatenation.
|
|
|
|
// g++ ... -DCRYPTOPP_DATA_DIR='"/tmp/cryptopp_test/share/"'
|
|
|
|
#ifndef CRYPTOPP_DATA_DIR
|
|
|
|
# define CRYPTOPP_DATA_DIR ""
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Define this if you want or need the library's memcpy_s and memmove_s.
|
|
|
|
// See http://github.com/weidai11/cryptopp/issues/28.
|
|
|
|
// #if !defined(CRYPTOPP_WANT_SECURE_LIB)
|
|
|
|
// # define CRYPTOPP_WANT_SECURE_LIB
|
|
|
|
// #endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// File system code to write to GZIP archive.
|
2015-11-18 20:32:28 +00:00
|
|
|
#if !defined(GZIP_OS_CODE)
|
|
|
|
# define GZIP_OS_CODE 0
|
|
|
|
#endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
// Try this if your CPU has 256K internal cache or a slow multiply instruction
|
|
|
|
// and you want a (possibly) faster IDEA implementation using log tables
|
|
|
|
// #define IDEA_LARGECACHE
|
|
|
|
|
|
|
|
// Define this if, for the linear congruential RNG, you want to use
|
|
|
|
// the original constants as specified in S.K. Park and K.W. Miller's
|
|
|
|
// CACM paper.
|
|
|
|
// #define LCRNG_ORIGINAL_NUMBERS
|
|
|
|
|
2016-01-13 21:38:56 +00:00
|
|
|
// Define this if you want Integer's operator<< to honor std::showbase (and
|
|
|
|
// std::noshowbase). If defined, Integer will use a suffix of 'b', 'o', 'h'
|
|
|
|
// or '.' (the last for decimal) when std::showbase is in effect. If
|
|
|
|
// std::noshowbase is set, then the suffix is not added to the Integer. If
|
|
|
|
// not defined, existing behavior is preserved and Integer will use a suffix
|
|
|
|
// of 'b', 'o', 'h' or '.' (the last for decimal).
|
|
|
|
// #define CRYPTOPP_USE_STD_SHOWBASE
|
|
|
|
|
2017-03-25 20:38:42 +00:00
|
|
|
// Define this if you want to decouple AlgorithmParameters and Integer
|
|
|
|
// The decoupling should make it easier for the linker to remove Integer
|
|
|
|
// related code for those who do not need Integer, and avoid a potential
|
|
|
|
// race during AssignIntToInteger pointer initialization. Also
|
|
|
|
// see http://github.com/weidai11/cryptopp/issues/389.
|
|
|
|
// #define CRYPTOPP_NO_ASSIGN_TO_INTEGER
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// choose which style of sockets to wrap (mostly useful for MinGW which has both)
|
|
|
|
#if !defined(NO_BERKELEY_STYLE_SOCKETS) && !defined(PREFER_BERKELEY_STYLE_SOCKETS)
|
|
|
|
# define PREFER_BERKELEY_STYLE_SOCKETS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// #if !defined(NO_WINDOWS_STYLE_SOCKETS) && !defined(PREFER_WINDOWS_STYLE_SOCKETS)
|
|
|
|
// # define PREFER_WINDOWS_STYLE_SOCKETS
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
// set the name of Rijndael cipher, was "Rijndael" before version 5.3
|
|
|
|
#define CRYPTOPP_RIJNDAEL_NAME "AES"
|
|
|
|
|
2016-09-20 01:18:58 +00:00
|
|
|
// CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT
|
|
|
|
// raises a SIGTRAP (Unix) or calls DebugBreak() (Windows). CRYPTOPP_ASSERT
|
|
|
|
// is only in effect when CRYPTOPP_DEBUG, DEBUG or _DEBUG is defined. Unlike
|
|
|
|
// Posix assert, CRYPTOPP_ASSERT is not affected by NDEBUG (or failure to
|
|
|
|
// define it).
|
|
|
|
// Also see http://github.com/weidai11/cryptopp/issues/277, CVE-2016-7420
|
|
|
|
#if (defined(DEBUG) || defined(_DEBUG)) && !defined(CRYPTOPP_DEBUG)
|
|
|
|
# define CRYPTOPP_DEBUG 1
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// ***************** Important Settings Again ********************
|
|
|
|
// But the defaults should be ok.
|
|
|
|
|
|
|
|
// namespace support is now required
|
|
|
|
#ifdef NO_NAMESPACE
|
|
|
|
# error namespace support is now required
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Define this to workaround a Microsoft CryptoAPI bug where
|
|
|
|
// each call to CryptAcquireContext causes a 100 KB memory leak.
|
|
|
|
// Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
|
|
|
|
#define WORKAROUND_MS_BUG_Q258000
|
|
|
|
|
|
|
|
#ifdef CRYPTOPP_DOXYGEN_PROCESSING
|
|
|
|
// Document the namespce exists. Put it here before CryptoPP is undefined below.
|
|
|
|
//! \namespace CryptoPP
|
|
|
|
//! \brief Crypto++ library namespace
|
|
|
|
//! \details Nearly all classes are located in the CryptoPP namespace. Within
|
|
|
|
//! the namespace, there are two additional namespaces.
|
|
|
|
//! <ul>
|
2015-11-18 20:32:28 +00:00
|
|
|
//! <li>Name - namespace for names used with \p NameValuePairs and documented in argnames.h
|
|
|
|
//! <li>Weak - namespace for weak and wounded algorithms, like ARC4, MD5 and Pananma
|
2015-11-05 06:59:46 +00:00
|
|
|
//! </ul>
|
|
|
|
namespace CryptoPP { }
|
|
|
|
// Bring in the symbols fund in the weak namespace; and fold Weak1 into Weak
|
|
|
|
# define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
|
|
|
|
# define Weak1 Weak
|
|
|
|
// Avoid putting "CryptoPP::" in front of everything in Doxygen output
|
|
|
|
# define CryptoPP
|
|
|
|
# define NAMESPACE_BEGIN(x)
|
|
|
|
# define NAMESPACE_END
|
|
|
|
// Get Doxygen to generate better documentation for these typedefs
|
|
|
|
# define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
|
2015-11-18 20:32:28 +00:00
|
|
|
// Make "protected" "private" so the functions and members are not documented
|
|
|
|
# define protected private
|
2015-11-05 06:59:46 +00:00
|
|
|
#else
|
|
|
|
# define NAMESPACE_BEGIN(x) namespace x {
|
|
|
|
# define NAMESPACE_END }
|
|
|
|
# define DOCUMENTED_TYPEDEF(x, y) typedef x y;
|
|
|
|
#endif
|
|
|
|
#define ANONYMOUS_NAMESPACE_BEGIN namespace {
|
2015-11-18 20:32:28 +00:00
|
|
|
#define ANONYMOUS_NAMESPACE_END }
|
2015-11-05 06:59:46 +00:00
|
|
|
#define USING_NAMESPACE(x) using namespace x;
|
|
|
|
#define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
|
|
|
|
#define DOCUMENTED_NAMESPACE_END }
|
|
|
|
|
|
|
|
// What is the type of the third parameter to bind?
|
|
|
|
// For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
|
|
|
|
// Unfortunately there is no way to tell whether or not socklen_t is defined.
|
|
|
|
// To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
|
|
|
|
#ifndef TYPE_OF_SOCKLEN_T
|
|
|
|
# if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
# define TYPE_OF_SOCKLEN_T int
|
|
|
|
# else
|
|
|
|
# define TYPE_OF_SOCKLEN_T ::socklen_t
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
|
|
|
|
# define __USE_W32_SOCKETS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
|
|
|
|
|
|
|
|
NAMESPACE_BEGIN(CryptoPP)
|
|
|
|
|
|
|
|
typedef unsigned short word16;
|
|
|
|
typedef unsigned int word32;
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
|
|
|
typedef unsigned __int64 word64;
|
|
|
|
#define W64LIT(x) x##ui64
|
2016-09-20 06:26:04 +00:00
|
|
|
#elif (_LP64 || __LP64__)
|
2016-07-24 17:40:58 +00:00
|
|
|
typedef unsigned long word64;
|
|
|
|
#define W64LIT(x) x##UL
|
2015-11-05 06:59:46 +00:00
|
|
|
#else
|
|
|
|
typedef unsigned long long word64;
|
|
|
|
#define W64LIT(x) x##ULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// define large word type, used for file offsets and such
|
|
|
|
typedef word64 lword;
|
|
|
|
const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
|
|
|
|
|
2016-06-22 13:50:23 +00:00
|
|
|
// Clang pretends to be VC++, too.
|
|
|
|
// See http://github.com/weidai11/cryptopp/issues/147
|
|
|
|
#if defined(_MSC_VER) && defined(__clang__)
|
|
|
|
# error: "Unsupported configuration"
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
|
2017-01-15 05:22:14 +00:00
|
|
|
#if defined(__clang__ ) && defined(__apple_build_version__)
|
2015-11-18 20:32:28 +00:00
|
|
|
#define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
2016-07-06 18:39:18 +00:00
|
|
|
#define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
|
2017-01-15 05:22:14 +00:00
|
|
|
#elif defined(__clang__ )
|
|
|
|
#define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
|
|
|
#define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define CRYPTOPP_MSC_VERSION (_MSC_VER)
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
|
2016-07-06 18:39:18 +00:00
|
|
|
#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
|
|
|
|
// TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
|
2016-07-06 18:39:18 +00:00
|
|
|
#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
|
2015-11-18 20:32:28 +00:00
|
|
|
#define CRYPTOPP_DISABLE_INTEL_ASM 1
|
|
|
|
#endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
// define hword, word, and dword. these are used for multiprecision integer arithmetic
|
|
|
|
// Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
|
2016-01-08 11:53:27 +00:00
|
|
|
#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__))
|
2015-11-05 06:59:46 +00:00
|
|
|
typedef word32 hword;
|
|
|
|
typedef word64 word;
|
|
|
|
#else
|
2016-09-09 07:33:06 +00:00
|
|
|
#define CRYPTOPP_NATIVE_DWORD_AVAILABLE 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
|
2016-01-08 11:53:27 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
|
2015-11-05 06:59:46 +00:00
|
|
|
// GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
|
|
|
|
// mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
|
|
|
|
typedef word32 hword;
|
|
|
|
typedef word64 word;
|
|
|
|
typedef __uint128_t dword;
|
|
|
|
typedef __uint128_t word128;
|
2016-09-09 07:33:06 +00:00
|
|
|
#define CRYPTOPP_WORD128_AVAILABLE 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#else
|
|
|
|
// 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
|
|
|
|
typedef word16 hword;
|
|
|
|
typedef word32 word;
|
|
|
|
typedef word64 dword;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
// being here means the native register size is probably 32 bits or less
|
|
|
|
#define CRYPTOPP_BOOL_SLOW_WORD64 1
|
|
|
|
typedef word16 hword;
|
|
|
|
typedef word32 word;
|
|
|
|
typedef word64 dword;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef CRYPTOPP_BOOL_SLOW_WORD64
|
|
|
|
#define CRYPTOPP_BOOL_SLOW_WORD64 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const unsigned int WORD_SIZE = sizeof(word);
|
|
|
|
const unsigned int WORD_BITS = WORD_SIZE * 8;
|
|
|
|
|
|
|
|
NAMESPACE_END
|
|
|
|
|
|
|
|
#ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
|
|
|
|
// This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
|
|
|
|
// Also see http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size.
|
2016-05-20 20:38:42 +00:00
|
|
|
#if defined(_M_X64) || defined(__x86_64__) || (__arm64__) || (__aarch64__)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_L1_CACHE_LINE_SIZE 64
|
|
|
|
#else
|
|
|
|
// L1 cache line size is 32 on Pentium III and earlier
|
|
|
|
#define CRYPTOPP_L1_CACHE_LINE_SIZE 32
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CRYPTOPP_ALIGN_DATA
|
2016-12-03 10:05:56 +00:00
|
|
|
#if defined(_MSC_VER)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_ALIGN_DATA(x)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CRYPTOPP_SECTION_ALIGN16
|
|
|
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
|
|
|
// the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
|
|
|
|
#define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_SECTION_ALIGN16
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2016-07-13 03:38:30 +00:00
|
|
|
// The section attribute attempts to initialize CPU flags to avoid Valgrind findings above -O1
|
2016-10-28 04:33:43 +00:00
|
|
|
#if ((defined(__MACH__) && defined(__APPLE__)) && ((CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70100) || (CRYPTOPP_GCC_VERSION >= 40300)))
|
2016-07-13 03:05:00 +00:00
|
|
|
#define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data")))
|
2016-10-28 04:33:43 +00:00
|
|
|
#elif (defined(__ELF__) && (CRYPTOPP_GCC_VERSION >= 40300))
|
2016-07-13 03:05:00 +00:00
|
|
|
#define CRYPTOPP_SECTION_INIT __attribute__((section ("nocommon")))
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_SECTION_INIT
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__fastcall)
|
|
|
|
#define CRYPTOPP_FASTCALL __fastcall
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_FASTCALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define CRYPTOPP_NO_VTABLE __declspec(novtable)
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_NO_VTABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
// 4127: conditional expression is constant
|
|
|
|
// 4231: nonstandard extension used : 'extern' before template explicit instantiation
|
|
|
|
// 4250: dominance
|
|
|
|
// 4251: member needs to have dll-interface
|
|
|
|
// 4275: base needs to have dll-interface
|
|
|
|
// 4505: unreferenced local function
|
|
|
|
// 4512: assignment operator not generated
|
|
|
|
// 4660: explicitly instantiating a class that's already implicitly instantiated
|
|
|
|
// 4661: no suitable definition provided for explicit template instantiation request
|
2016-12-27 17:34:57 +00:00
|
|
|
// 4786: identifier was truncated in debug information
|
2015-11-05 06:59:46 +00:00
|
|
|
// 4355: 'this' : used in base member initializer list
|
|
|
|
// 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
|
|
|
|
# pragma warning(disable: 4127 4231 4250 4251 4275 4505 4512 4660 4661 4786 4355 4910)
|
|
|
|
// Security related, possible defects
|
|
|
|
// http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
|
|
|
|
# pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
// 8037: non-const function called for const object. needed to work around BCB2006 bug
|
|
|
|
# pragma warn -8037
|
|
|
|
#endif
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
|
|
|
|
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
|
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
|
|
|
# pragma GCC diagnostic ignored "-Wunused-function"
|
|
|
|
#endif
|
|
|
|
|
2016-07-18 00:20:36 +00:00
|
|
|
// You may need to force include a C++ header on Android when using STLPort to ensure
|
|
|
|
// _STLPORT_VERSION is defined: CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -include iosfwd"
|
2016-07-12 15:05:05 +00:00
|
|
|
// TODO: Figure out C++17 and lack of std::uncaught_exception
|
2015-12-09 09:09:30 +00:00
|
|
|
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)))
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
|
|
|
|
#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...)
|
|
|
|
#if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
|
|
|
|
# define CRYPTOPP_DISABLE_ASM
|
|
|
|
#endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2016-06-15 09:02:28 +00:00
|
|
|
// Sun Studio 12 provides GCC inline assembly, http://blogs.oracle.com/x86be/entry/gcc_style_asm_inlining_support
|
|
|
|
// We can enable SSE2 for Sun Studio in the makefile with -D__SSE2__, but users may not compile with it.
|
2016-07-11 00:40:45 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(__SSE2__) && defined(__x86_64__) && (__SUNPRO_CC >= 0x5100)
|
2016-09-19 01:06:41 +00:00
|
|
|
# define __SSE2__ 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
|
|
|
|
// C++Builder 2010 does not allow "call label" where label is defined within inline assembly
|
|
|
|
#define CRYPTOPP_X86_ASM_AVAILABLE
|
|
|
|
|
2016-12-03 10:05:56 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
|
|
|
|
#endif
|
|
|
|
|
2016-09-23 03:54:10 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_SSE3) && (_MSC_VER >= 1500 || (defined(__SSE3__) && defined(__SSSE3__)))
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
|
|
|
|
#define CRYPTOPP_X64_MASM_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
|
|
|
|
#define CRYPTOPP_X64_ASM_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
2016-12-03 10:05:56 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__)) && !defined(_M_ARM)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
|
|
|
|
#endif
|
|
|
|
|
2016-04-15 20:23:04 +00:00
|
|
|
// Intrinsics availible in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and
|
|
|
|
// MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx)
|
2016-09-19 01:06:41 +00:00
|
|
|
// SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4.
|
2016-09-21 06:02:55 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSE4) && !defined(_M_ARM) && ((_MSC_VER >= 1500) || (defined(__SSE4_1__) && defined(__SSE4_2__)))
|
2016-09-30 05:19:44 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 1
|
2016-04-15 20:23:04 +00:00
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 0
|
|
|
|
#endif
|
|
|
|
|
2016-09-19 01:06:41 +00:00
|
|
|
// Don't disgorge AES-NI from CLMUL. There will be two to four subtle breaks
|
2016-09-21 06:02:55 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_AESNI) && !defined(_M_ARM) && (_MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110 || (defined(__AES__) && defined(__PCLMUL__)))
|
2016-09-30 05:19:44 +00:00
|
|
|
#define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
|
|
|
|
#endif
|
|
|
|
|
2016-12-02 04:35:13 +00:00
|
|
|
#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SHA) && !defined(_M_ARM) && ((_MSC_VER >= 1900) || defined(__SHA__))
|
2016-12-01 05:49:59 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE 1
|
2016-09-20 04:35:27 +00:00
|
|
|
#else
|
2016-12-01 05:49:59 +00:00
|
|
|
#define CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE 0
|
2016-09-20 04:35:27 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-21 19:50:04 +00:00
|
|
|
// Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains.
|
2016-05-22 17:02:53 +00:00
|
|
|
#if !defined(CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
|
|
|
|
# if defined(__ARM_NEON__) || defined(__ARM_NEON) || defined(_M_ARM)
|
|
|
|
# define CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE 1
|
2016-05-21 19:50:04 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-14 04:57:11 +00:00
|
|
|
// Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
|
|
|
|
// LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
|
2016-05-21 19:50:04 +00:00
|
|
|
// Microsoft plans to support ARM-64, but its not clear how to detect it.
|
|
|
|
// TODO: Add MSC_VER and ARM-64 platform define when available
|
2016-05-22 17:02:53 +00:00
|
|
|
#if !defined(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
|
2017-01-14 04:57:11 +00:00
|
|
|
# if defined(__ARM_FEATURE_CRC32)
|
2016-05-22 17:02:53 +00:00
|
|
|
# define CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE 1
|
2016-05-21 19:50:04 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-16 10:35:53 +00:00
|
|
|
// Requires ARMv8, ACLE 2.0 and Aarch64. GCC requires 4.8 and above.
|
2017-01-15 05:22:14 +00:00
|
|
|
// LLVM Clang requires 3.5. Apple Clang does not support it at the moment.
|
|
|
|
// Microsoft plans to support ARM-64, but its not clear how to detect it.
|
|
|
|
// TODO: Add MSC_VER and ARM-64 platform define when available
|
2017-01-19 07:38:00 +00:00
|
|
|
#if !defined(CRYPTOPP_BOOL_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
|
2017-01-15 05:22:14 +00:00
|
|
|
# if defined(__ARM_FEATURE_CRYPTO) && !defined(__apple_build_version__)
|
2017-01-16 10:35:53 +00:00
|
|
|
# if defined(__arm64__) || defined(__aarch64__)
|
2017-01-19 07:38:00 +00:00
|
|
|
# define CRYPTOPP_BOOL_ARM_PMULL_AVAILABLE 1
|
2017-01-16 10:35:53 +00:00
|
|
|
# endif
|
2017-01-15 05:22:14 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-14 04:57:11 +00:00
|
|
|
// Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
|
|
|
|
// LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
|
2016-05-21 19:50:04 +00:00
|
|
|
// Microsoft plans to support ARM-64, but its not clear how to detect it.
|
|
|
|
// TODO: Add MSC_VER and ARM-64 platform define when available
|
2016-05-22 17:02:53 +00:00
|
|
|
#if !defined(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
|
2017-01-14 04:57:11 +00:00
|
|
|
# if defined(__ARM_FEATURE_CRYPTO)
|
2016-05-22 17:02:53 +00:00
|
|
|
# define CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE 1
|
2016-05-21 19:50:04 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BOOL_ALIGN16 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_ALIGN16 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// how to allocate 16-byte aligned memory (for SSE2)
|
2016-12-03 10:05:56 +00:00
|
|
|
#if defined(_MSC_VER)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_MM_MALLOC_AVAILABLE
|
2015-11-18 20:32:28 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#define CRYPTOPP_APPLE_MALLOC_AVAILABLE
|
2017-02-19 07:04:38 +00:00
|
|
|
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
|
|
|
|
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
|
|
|
|
#define CRYPTOPP_MEMALIGN_AVAILABLE
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_NO_ALIGNED_ALLOC
|
|
|
|
#endif
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Apple always provides 16-byte aligned, and tells us to use calloc
|
|
|
|
// http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
// how to disable inlining
|
2016-12-03 10:05:56 +00:00
|
|
|
#if defined(_MSC_VER)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define CRYPTOPP_NOINLINE_DOTDOTDOT
|
|
|
|
# define CRYPTOPP_NOINLINE __declspec(noinline)
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
# define CRYPTOPP_NOINLINE_DOTDOTDOT
|
|
|
|
# define CRYPTOPP_NOINLINE __attribute__((noinline))
|
|
|
|
#else
|
|
|
|
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
|
2016-05-15 06:30:08 +00:00
|
|
|
# define CRYPTOPP_NOINLINE
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
2016-09-06 08:04:03 +00:00
|
|
|
// How to declare class constants
|
2016-12-04 21:07:10 +00:00
|
|
|
#if (_MSC_VER == 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define CRYPTOPP_CONSTANT(x) enum {x};
|
|
|
|
#else
|
|
|
|
# define CRYPTOPP_CONSTANT(x) static const int x;
|
|
|
|
#endif
|
2016-01-08 11:53:27 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
|
2015-12-02 20:54:35 +00:00
|
|
|
// Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
|
2016-10-27 18:20:51 +00:00
|
|
|
// the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang.
|
|
|
|
#if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BOOL_X32 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_X32 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// see http://predef.sourceforge.net/prearch.html
|
|
|
|
#if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
|
|
|
|
#define CRYPTOPP_BOOL_X86 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_X86 0
|
|
|
|
#endif
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
|
|
|
|
#define CRYPTOPP_BOOL_X64 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_X64 0
|
|
|
|
#endif
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// Undo the ASM and Intrinsic related defines due to X32.
|
|
|
|
#if CRYPTOPP_BOOL_X32
|
|
|
|
# undef CRYPTOPP_BOOL_X64
|
|
|
|
# undef CRYPTOPP_X64_ASM_AVAILABLE
|
|
|
|
# undef CRYPTOPP_X64_MASM_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
2016-05-15 06:30:08 +00:00
|
|
|
#if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM)
|
|
|
|
#define CRYPTOPP_BOOL_ARM32 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_ARM32 0
|
|
|
|
#endif
|
|
|
|
|
2016-05-22 17:02:53 +00:00
|
|
|
// Microsoft plans to support ARM-64, but its not clear how to detect it.
|
|
|
|
// TODO: Add MSC_VER and ARM-64 platform define when available
|
2016-05-15 09:37:39 +00:00
|
|
|
#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
|
2016-05-15 06:30:08 +00:00
|
|
|
#define CRYPTOPP_BOOL_ARM64 1
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_BOOL_ARM64 0
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
|
|
|
|
#if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1))
|
|
|
|
#define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-03-20 12:51:10 +00:00
|
|
|
// ***************** Initialization and Constructor priorities ********************
|
|
|
|
|
|
|
|
// CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
|
|
|
|
// Under GCC, the library uses init_priority attribute in the range
|
|
|
|
// [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
|
|
|
|
// CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". The platforms
|
|
|
|
// with gaps are Apple and Sun because they require linker scripts. Apple and
|
|
|
|
// Sun will use the library's Singletons to initialize and acquire resources.
|
|
|
|
// Also see http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco
|
|
|
|
#ifndef CRYPTOPP_INIT_PRIORITY
|
|
|
|
# define CRYPTOPP_INIT_PRIORITY 250
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
|
|
|
|
// and managing C++ static object creation. It is guaranteed not to conflict with
|
|
|
|
// values used by (or would be used by) the Crypto++ library.
|
|
|
|
#if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0)
|
|
|
|
# define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101)
|
|
|
|
#else
|
|
|
|
# define CRYPTOPP_USER_PRIORITY 350
|
|
|
|
#endif
|
|
|
|
|
2017-03-27 10:06:12 +00:00
|
|
|
// Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.
|
|
|
|
#if (CRYPTOPP_INIT_PRIORITY > 0) && !(defined(NO_OS_DEPENDENCE) || defined(__APPLE__) || defined(__sun__))
|
2017-03-20 12:51:10 +00:00
|
|
|
# if (CRYPTOPP_GCC_VERSION >= 30000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 800)
|
|
|
|
# define HAVE_GCC_INIT_PRIORITY 1
|
|
|
|
# elif (CRYPTOPP_MSC_VERSION >= 1310)
|
|
|
|
# define HAVE_MSC_INIT_PRIORITY 1
|
|
|
|
# endif
|
2017-03-27 10:06:12 +00:00
|
|
|
#endif // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun
|
2017-03-20 12:51:10 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// ***************** determine availability of OS features ********************
|
|
|
|
|
|
|
|
#ifndef NO_OS_DEPENDENCE
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
#define CRYPTOPP_WIN32_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
|
|
|
|
#define CRYPTOPP_UNIX_AVAILABLE
|
|
|
|
#endif
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2017-02-19 07:04:38 +00:00
|
|
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
2015-11-05 06:59:46 +00:00
|
|
|
#define CRYPTOPP_BSD_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
|
|
|
|
# define HIGHRES_TIMER_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
2016-05-03 04:23:05 +00:00
|
|
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
|
|
|
# if !defined(WINAPI_FAMILY)
|
|
|
|
# define THREAD_TIMER_AVAILABLE
|
2016-05-15 06:30:08 +00:00
|
|
|
# elif defined(WINAPI_FAMILY)
|
2016-05-03 04:23:05 +00:00
|
|
|
# if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
|
|
|
|
# define THREAD_TIMER_AVAILABLE
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifdef CRYPTOPP_UNIX_AVAILABLE
|
|
|
|
# define HAS_BERKELEY_STYLE_SOCKETS
|
2016-05-03 04:23:05 +00:00
|
|
|
# define SOCKETS_AVAILABLE
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-03 04:23:05 +00:00
|
|
|
// Sockets are only available under Windows Runtime desktop partition apps (despite the MSDN literature)
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
2016-05-03 04:23:05 +00:00
|
|
|
# define HAS_WINDOWS_STYLE_SOCKETS
|
|
|
|
# if !defined(WINAPI_FAMILY)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define SOCKETS_AVAILABLE
|
2016-05-15 06:30:08 +00:00
|
|
|
# elif defined(WINAPI_FAMILY)
|
2016-05-03 04:23:05 +00:00
|
|
|
# if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
|
|
|
|
# define SOCKETS_AVAILABLE
|
|
|
|
# endif
|
|
|
|
# endif
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
|
|
|
|
# define USE_WINDOWS_STYLE_SOCKETS
|
|
|
|
#else
|
|
|
|
# define USE_BERKELEY_STYLE_SOCKETS
|
|
|
|
#endif
|
|
|
|
|
2016-05-03 04:23:05 +00:00
|
|
|
#if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(SOCKETS_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define WINDOWS_PIPES_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
|
|
|
# define NONBLOCKING_RNG_AVAILABLE
|
|
|
|
# define BLOCKING_RNG_AVAILABLE
|
|
|
|
# define OS_RNG_AVAILABLE
|
|
|
|
# define HAS_PTHREADS
|
|
|
|
# define THREADS_AVAILABLE
|
|
|
|
#endif
|
|
|
|
|
2017-03-10 06:53:51 +00:00
|
|
|
// Cygwin/Newlib requires _XOPEN_SOURCE=700
|
|
|
|
#if defined(CRYPTOPP_UNIX_AVAILABLE)
|
2016-10-02 02:12:08 +00:00
|
|
|
# define UNIX_SIGNALS_AVAILABLE 1
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
2016-05-03 04:23:05 +00:00
|
|
|
# if !defined(WINAPI_FAMILY)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define HAS_WINTHREADS
|
|
|
|
# define THREADS_AVAILABLE
|
2016-05-03 04:23:05 +00:00
|
|
|
# define NONBLOCKING_RNG_AVAILABLE
|
|
|
|
# define OS_RNG_AVAILABLE
|
2016-05-15 06:30:08 +00:00
|
|
|
# elif defined(WINAPI_FAMILY)
|
2016-05-03 04:23:05 +00:00
|
|
|
# if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
|
|
|
|
# define HAS_WINTHREADS
|
|
|
|
# define THREADS_AVAILABLE
|
|
|
|
# define NONBLOCKING_RNG_AVAILABLE
|
|
|
|
# define OS_RNG_AVAILABLE
|
|
|
|
# elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
|
|
|
|
# if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
|
|
|
|
# define NONBLOCKING_RNG_AVAILABLE
|
|
|
|
# define OS_RNG_AVAILABLE
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // NO_OS_DEPENDENCE
|
|
|
|
|
|
|
|
// ***************** DLL related ********************
|
|
|
|
|
|
|
|
#if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
|
|
|
|
|
|
|
#ifdef CRYPTOPP_EXPORTS
|
|
|
|
#define CRYPTOPP_IS_DLL
|
|
|
|
#define CRYPTOPP_DLL __declspec(dllexport)
|
|
|
|
#elif defined(CRYPTOPP_IMPORTS)
|
|
|
|
#define CRYPTOPP_IS_DLL
|
|
|
|
#define CRYPTOPP_DLL __declspec(dllimport)
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_DLL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CRYPTOPP_API __cdecl
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
#else // not CRYPTOPP_WIN32_AVAILABLE
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
#define CRYPTOPP_DLL
|
|
|
|
#define CRYPTOPP_API
|
|
|
|
|
|
|
|
#endif // CRYPTOPP_WIN32_AVAILABLE
|
|
|
|
|
|
|
|
#if defined(__MWERKS__)
|
|
|
|
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
|
|
|
|
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
|
|
|
|
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
|
|
|
|
#define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__MWERKS__)
|
|
|
|
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
|
|
|
|
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
|
|
|
|
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
|
|
|
|
#define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
|
|
|
|
#else
|
|
|
|
#define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ************** Unused variable ***************
|
2015-11-18 20:32:28 +00:00
|
|
|
|
|
|
|
// Portable way to suppress warnings.
|
|
|
|
// Moved from misc.h due to circular depenedencies.
|
2016-09-19 21:55:36 +00:00
|
|
|
#define CRYPTOPP_UNUSED(x) ((void)(x))
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2016-04-23 20:45:35 +00:00
|
|
|
// ************** Deprecated ***************
|
|
|
|
|
2016-07-06 18:39:18 +00:00
|
|
|
#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
|
2016-04-23 20:45:35 +00:00
|
|
|
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg)));
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION)
|
|
|
|
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated));
|
|
|
|
#else
|
|
|
|
# define CRYPTOPP_DEPRECATED(msg)
|
|
|
|
#endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// ***************** C++11 related ********************
|
|
|
|
|
2015-11-18 20:32:28 +00:00
|
|
|
// Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx.
|
2015-11-05 06:59:46 +00:00
|
|
|
// Intel and C++11 language features, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
|
|
|
|
// GCC and C++11 language features, http://gcc.gnu.org/projects/cxx0x.html
|
|
|
|
// Clang and C++11 language features, http://clang.llvm.org/cxx_status.html
|
2016-07-18 00:20:36 +00:00
|
|
|
#if ((_MSC_VER >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define CRYPTOPP_CXX11 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't
|
|
|
|
// test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same
|
|
|
|
// way. However, modern standard libraries have <forward_list>, so we test for it instead.
|
|
|
|
// Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions.
|
|
|
|
// TODO: test under Xcode 3, where g++ is really g++.
|
2015-11-18 20:32:28 +00:00
|
|
|
#if defined(__APPLE__) && defined(__clang__)
|
|
|
|
# if !(defined(__has_include) && __has_include(<forward_list>))
|
2015-11-05 06:59:46 +00:00
|
|
|
# undef CRYPTOPP_CXX11
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// C++11 or C++14 is available
|
2016-05-15 06:30:08 +00:00
|
|
|
#if defined(CRYPTOPP_CXX11)
|
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// Compatibility with non-clang compilers.
|
|
|
|
#ifndef __has_feature
|
|
|
|
# define __has_feature(x) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// atomics: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.1/3.2; Intel 13.0; SunCC 5.14.
|
2016-05-15 06:30:08 +00:00
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1700)
|
|
|
|
# define CRYPTOPP_CXX11_ATOMICS 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_atomic)
|
|
|
|
# define CRYPTOPP_CXX11_ATOMICS 1
|
2016-07-19 04:09:29 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1300)
|
2016-05-15 06:30:08 +00:00
|
|
|
# define CRYPTOPP_CXX11_ATOMICS 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40400)
|
|
|
|
# define CRYPTOPP_CXX11_ATOMICS 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#elif (__SUNPRO_CC >= 0x5140)
|
|
|
|
# define CRYPTOPP_CXX11_ATOMICS 1
|
2016-05-15 06:30:08 +00:00
|
|
|
#endif // atomics
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 5.13.
|
2016-06-07 02:08:04 +00:00
|
|
|
// TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang
|
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1700)
|
|
|
|
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
|
2016-07-06 18:39:18 +00:00
|
|
|
#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
|
2016-06-07 02:08:04 +00:00
|
|
|
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1200)
|
|
|
|
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
|
2016-06-07 02:08:04 +00:00
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40400)
|
|
|
|
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
|
2016-06-07 02:08:04 +00:00
|
|
|
#endif // synchronization
|
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// Dynamic Initialization and Destruction with Concurrency ("Magic Statics")
|
|
|
|
// MS at VS2015 (19.00); GCC at 4.3; LLVM Clang at 2.9; Apple Clang at 4.0; Intel 11.1; SunCC 5.13.
|
|
|
|
// Microsoft's implementation only works for Vista and above, so its further
|
|
|
|
// limited. http://connect.microsoft.com/VisualStudio/feedback/details/1789709
|
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600 /*_WIN32_WINNT_VISTA*/) || (_WIN32_WINNT >= 0x0600 /*_WIN32_WINNT_VISTA*/))
|
|
|
|
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1
|
|
|
|
#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000)
|
|
|
|
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1
|
|
|
|
#elif (__INTEL_COMPILER >= 1110)
|
|
|
|
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40300)
|
|
|
|
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1
|
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1
|
|
|
|
#endif // Dynamic Initialization compilers
|
|
|
|
|
|
|
|
// alignof/alignas: MS at VS2015 (19.00); GCC at 4.8; Clang at 3.0; Intel 15.0; SunCC 5.13.
|
2015-11-18 20:32:28 +00:00
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1900)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNAS 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_alignas)
|
2015-11-18 20:32:28 +00:00
|
|
|
# define CRYPTOPP_CXX11_ALIGNAS 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1500)
|
2015-11-18 20:32:28 +00:00
|
|
|
# define CRYPTOPP_CXX11_ALIGNAS 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40800)
|
2015-11-18 20:32:28 +00:00
|
|
|
# define CRYPTOPP_CXX11_ALIGNAS 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNAS 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#endif // alignas
|
|
|
|
|
|
|
|
// alignof: MS at VS2015 (19.00); GCC at 4.5; Clang at 2.9; Intel 15.0; SunCC 5.13.
|
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1900)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNOF 1
|
|
|
|
#elif __has_feature(cxx_alignof)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNOF 1
|
|
|
|
#elif (__INTEL_COMPILER >= 1500)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNOF 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40500)
|
|
|
|
# define CRYPTOPP_CXX11_ALIGNOF 1
|
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
2016-06-15 09:02:28 +00:00
|
|
|
# define CRYPTOPP_CXX11_ALIGNOF 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#endif // alignof
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 14.0; SunCC 5.13.
|
2015-11-05 06:59:46 +00:00
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1900)
|
|
|
|
# define CRYPTOPP_CXX11_NOEXCEPT 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_noexcept)
|
|
|
|
# define CRYPTOPP_CXX11_NOEXCEPT 1
|
2016-07-19 04:09:29 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1400)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define CRYPTOPP_CXX11_NOEXCEPT 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40600)
|
|
|
|
# define CRYPTOPP_CXX11_NOEXCEPT 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_NOEXCEPT 1
|
2015-11-05 06:59:46 +00:00
|
|
|
#endif // noexcept compilers
|
2016-05-03 04:23:05 +00:00
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.
|
2015-11-05 06:59:46 +00:00
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1800)
|
|
|
|
# define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_variadic_templates)
|
|
|
|
# define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
|
2016-07-19 04:09:29 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1210)
|
2015-11-05 06:59:46 +00:00
|
|
|
# define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40300)
|
|
|
|
# define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
|
2016-06-15 09:02:28 +00:00
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
|
2015-11-18 20:32:28 +00:00
|
|
|
#endif // variadic templates
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// constexpr: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.1; Intel 16.0; SunCC 5.13.
|
2016-09-02 02:45:44 +00:00
|
|
|
// Intel has mis-supported the feature since at least ICPC 13.00
|
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1900)
|
|
|
|
# define CRYPTOPP_CXX11_CONSTEXPR 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_constexpr)
|
|
|
|
# define CRYPTOPP_CXX11_CONSTEXPR 1
|
2016-09-02 02:45:44 +00:00
|
|
|
#elif (__INTEL_COMPILER >= 1600)
|
|
|
|
# define CRYPTOPP_CXX11_CONSTEXPR 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40600)
|
|
|
|
# define CRYPTOPP_CXX11_CONSTEXPR 1
|
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_CONSTEXPR 1
|
|
|
|
#endif // constexpr compilers
|
|
|
|
|
2017-03-15 10:20:45 +00:00
|
|
|
// nullptr_t: MS at VS2010 (16.00); GCC at 4.6; Clang at 3.3; Intel 10.0; SunCC 5.13.
|
2017-03-01 11:10:06 +00:00
|
|
|
#if (CRYPTOPP_MSC_VERSION >= 1600)
|
|
|
|
# define CRYPTOPP_CXX11_NULLPTR 1
|
2017-03-15 10:20:45 +00:00
|
|
|
#elif __has_feature(cxx_nullptr)
|
|
|
|
# define CRYPTOPP_CXX11_NULLPTR 1
|
|
|
|
#elif (__INTEL_COMPILER >= 1000)
|
2017-03-01 11:10:06 +00:00
|
|
|
# define CRYPTOPP_CXX11_NULLPTR 1
|
|
|
|
#elif (CRYPTOPP_GCC_VERSION >= 40600)
|
|
|
|
# define CRYPTOPP_CXX11_NULLPTR 1
|
|
|
|
#elif (__SUNPRO_CC >= 0x5130)
|
|
|
|
# define CRYPTOPP_CXX11_NULLPTR 1
|
|
|
|
#endif // nullptr_t compilers
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// TODO: Emplacement, R-values and Move semantics
|
|
|
|
// Needed because we are catching warnings with GCC and MSC
|
|
|
|
|
|
|
|
#endif // CRYPTOPP_CXX11
|
2016-05-15 06:30:08 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#if defined(CRYPTOPP_CXX11_NOEXCEPT)
|
|
|
|
# define CRYPTOPP_THROW noexcept(false)
|
|
|
|
# define CRYPTOPP_NO_THROW noexcept(true)
|
|
|
|
#else
|
|
|
|
# define CRYPTOPP_THROW
|
|
|
|
# define CRYPTOPP_NO_THROW
|
|
|
|
#endif // CRYPTOPP_CXX11_NOEXCEPT
|
|
|
|
|
2016-11-12 14:34:34 +00:00
|
|
|
// http://stackoverflow.com/a/13867690/608639
|
2016-09-02 02:45:44 +00:00
|
|
|
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
2016-12-01 14:37:04 +00:00
|
|
|
# define CRYPTOPP_STATIC_CONSTEXPR static constexpr
|
2016-09-02 02:45:44 +00:00
|
|
|
# define CRYPTOPP_CONSTEXPR constexpr
|
|
|
|
#else
|
2016-12-01 14:37:04 +00:00
|
|
|
# define CRYPTOPP_STATIC_CONSTEXPR static
|
2016-09-02 02:45:44 +00:00
|
|
|
# define CRYPTOPP_CONSTEXPR
|
|
|
|
#endif // CRYPTOPP_CXX11_CONSTEXPR
|
|
|
|
|
2016-06-14 23:14:09 +00:00
|
|
|
// Hack... CRYPTOPP_ALIGN_DATA is defined earlier, before C++11 alignas availability is determined
|
|
|
|
#if defined(CRYPTOPP_CXX11_ALIGNAS)
|
|
|
|
# undef CRYPTOPP_ALIGN_DATA
|
|
|
|
# define CRYPTOPP_ALIGN_DATA(x) alignas(x)
|
|
|
|
#endif // CRYPTOPP_CXX11_ALIGNAS
|
|
|
|
|
2016-09-06 12:53:55 +00:00
|
|
|
// Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined
|
2016-11-13 16:50:34 +00:00
|
|
|
// http://stackoverflow.com/q/35213098/608639
|
2016-09-06 12:53:55 +00:00
|
|
|
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
|
|
|
# undef CRYPTOPP_CONSTANT
|
|
|
|
# define CRYPTOPP_CONSTANT(x) constexpr static int x;
|
|
|
|
#endif
|
|
|
|
|
2017-03-01 11:10:06 +00:00
|
|
|
// Hack... C++11 nullptr_t type safety and analysis
|
|
|
|
#if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)
|
|
|
|
# define NULLPTR nullptr
|
|
|
|
#elif !defined(NULLPTR)
|
|
|
|
# define NULLPTR NULL
|
|
|
|
#endif // CRYPTOPP_CXX11_NULLPTR
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
// OK to comment the following out, but please report it so we can fix it.
|
2016-07-12 15:05:05 +00:00
|
|
|
// C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf.
|
|
|
|
#if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
|
2015-11-05 06:59:46 +00:00
|
|
|
# error "std::uncaught_exception is not available. This is likely a configuration error."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|