|
||||
File indexing completed on 2025-01-18 09:54:55
0001 // config_int.h - written and placed in public domain by Jeffrey Walton 0002 // the bits that make up this source file are from the 0003 // library's monolithic config.h. 0004 0005 /// \file config_int.h 0006 /// \brief Library configuration file 0007 /// \details <tt>config_int.h</tt> provides defines and typedefs for fixed 0008 /// size integers. The library's choices for fixed size integers predates other 0009 /// standard-based integers by about 5 years. After fixed sizes were 0010 /// made standard, the library continued to use its own definitions for 0011 /// compatibility with previous versions of the library. 0012 /// \details <tt>config.h</tt> was split into components in May 2019 to better 0013 /// integrate with Autoconf and its feature tests. The splitting occurred so 0014 /// users could continue to include <tt>config.h</tt> while allowing Autoconf 0015 /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using 0016 /// its feature tests. 0017 /// \note You should include <tt>config.h</tt> rather than <tt>config_int.h</tt> 0018 /// directly. 0019 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835, 0020 /// Make config.h more autoconf friendly</A>, 0021 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A> 0022 /// on the Crypto++ wiki 0023 /// \since Crypto++ 8.3 0024 0025 #ifndef CRYPTOPP_CONFIG_INT_H 0026 #define CRYPTOPP_CONFIG_INT_H 0027 0028 #include "config_ns.h" 0029 #include "config_ver.h" 0030 #include "config_misc.h" 0031 0032 // C5264 new for VS2022/v17.4, MSC v17.3.4 0033 // https://github.com/weidai11/cryptopp/issues/1185 0034 #if (CRYPTOPP_MSC_VERSION) 0035 # pragma warning(push) 0036 # if (CRYPTOPP_MSC_VERSION >= 1933) 0037 # pragma warning(disable: 5264) 0038 # endif 0039 #endif 0040 0041 /// \brief Library byte guard 0042 /// \details CRYPTOPP_NO_GLOBAL_BYTE indicates <tt>byte</tt> is in the Crypto++ 0043 /// namespace. 0044 /// \details The Crypto++ <tt>byte</tt> was originally in global namespace to avoid 0045 /// ambiguity with other byte typedefs. <tt>byte</tt> was moved to CryptoPP namespace 0046 /// at Crypto++ 6.0 due to C++17, <tt>std::byte</tt> and potential compile problems. 0047 /// \sa <A HREF="http://github.com/weidai11/cryptopp/issues/442">Issue 442</A>, 0048 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">std::byte</A> on the 0049 /// Crypto++ wiki 0050 /// \since Crypto++ 6.0 0051 #define CRYPTOPP_NO_GLOBAL_BYTE 1 0052 0053 NAMESPACE_BEGIN(CryptoPP) 0054 0055 // Signed words added at Issue 609 for early versions of and Visual Studio and 0056 // the NaCl gear. Also see https://github.com/weidai11/cryptopp/issues/609. 0057 0058 /// \brief 8-bit unsigned datatype 0059 /// \details The Crypto++ <tt>byte</tt> was originally in global namespace to avoid 0060 /// ambiguity with other byte typedefs. <tt>byte</tt> was moved to CryptoPP namespace 0061 /// at Crypto++ 6.0 due to C++17, <tt>std::byte</tt> and potential compile problems. 0062 /// \sa CRYPTOPP_NO_GLOBAL_BYTE, <A HREF="http://github.com/weidai11/cryptopp/issues/442">Issue 442</A>, 0063 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">std::byte</A> on the 0064 /// Crypto++ wiki 0065 /// \since Crypto++ 1.0, CryptoPP namespace since Crypto++ 6.0 0066 typedef unsigned char byte; 0067 /// \brief 16-bit unsigned datatype 0068 /// \since Crypto++ 1.0 0069 typedef unsigned short word16; 0070 /// \brief 32-bit unsigned datatype 0071 /// \since Crypto++ 1.0 0072 typedef unsigned int word32; 0073 0074 /// \brief 8-bit signed datatype 0075 /// \details The 8-bit signed datatype was added to support constant time 0076 /// implementations for curve25519, X25519 key agreement and ed25519 0077 /// signatures. 0078 /// \since Crypto++ 8.0 0079 typedef signed char sbyte; 0080 /// \brief 16-bit signed datatype 0081 /// \details The 32-bit signed datatype was added to support constant time 0082 /// implementations for curve25519, X25519 key agreement and ed25519 0083 /// signatures. 0084 /// \since Crypto++ 8.0 0085 typedef signed short sword16; 0086 /// \brief 32-bit signed datatype 0087 /// \details The 32-bit signed datatype was added to support constant time 0088 /// implementations for curve25519, X25519 key agreement and ed25519 0089 /// signatures. 0090 /// \since Crypto++ 8.0 0091 typedef signed int sword32; 0092 0093 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) 0094 0095 /// \brief 64-bit unsigned datatype 0096 /// \details The typedef for <tt>word64</tt> varies depending on the platform. 0097 /// On Microsoft platforms it is <tt>unsigned __int64</tt>. On Unix & Linux 0098 /// with LP64 data model it is <tt>unsigned long</tt>. On Unix & Linux with ILP32 0099 /// data model it is <tt>unsigned long long</tt>. 0100 /// \since Crypto++ 1.0 0101 typedef unsigned long long word64; 0102 0103 /// \brief 64-bit signed datatype 0104 /// \details The typedef for <tt>sword64</tt> varies depending on the platform. 0105 /// On Microsoft platforms it is <tt>signed __int64</tt>. On Unix & Linux 0106 /// with LP64 data model it is <tt>signed long</tt>. On Unix & Linux with ILP32 0107 /// data model it is <tt>signed long long</tt>. 0108 /// \since Crypto++ 8.0 0109 typedef signed long long sword64; 0110 0111 /// \brief 128-bit unsigned datatype 0112 /// \details The typedef for <tt>word128</tt> varies depending on the platform. 0113 /// <tt>word128</tt> is only available on 64-bit machines when 0114 /// <tt>CRYPTOPP_WORD128_AVAILABLE</tt> is defined. 0115 /// On Unix & Linux with LP64 data model it is <tt>__uint128_t</tt>. 0116 /// Microsoft platforms do not provide a 128-bit integer type. 32-bit platforms 0117 /// do not provide a 128-bit integer type. 0118 /// \since Crypto++ 5.6 0119 typedef __uint128_t word128; 0120 0121 /// \brief Declare an unsigned word64 0122 /// \details W64LIT is used to portability declare or assign 64-bit literal values. 0123 /// W64LIT will append the proper suffix to ensure the compiler accepts the literal. 0124 /// \details Use the macro like shown below. 0125 /// <pre> 0126 /// word64 x = W64LIT(0xffffffffffffffff); 0127 /// </pre> 0128 /// \since Crypto++ 1.0 0129 #define W64LIT(x) ... 0130 0131 /// \brief Declare a signed word64 0132 /// \details SW64LIT is used to portability declare or assign 64-bit literal values. 0133 /// SW64LIT will append the proper suffix to ensure the compiler accepts the literal. 0134 /// \details Use the macro like shown below. 0135 /// <pre> 0136 /// sword64 x = SW64LIT(0xffffffffffffffff); 0137 /// </pre> 0138 /// \since Crypto++ 8.0 0139 #define SW64LIT(x) ... 0140 0141 /// \brief Declare ops on word64 are slow 0142 /// \details CRYPTOPP_BOOL_SLOW_WORD64 is typically defined to 1 on platforms 0143 /// that have a machine word smaller than 64-bits. That is, the define 0144 /// is present on 32-bit platforms. The define is also present on platforms 0145 /// where the cpu is slow even with a 64-bit cpu. 0146 #define CRYPTOPP_BOOL_SLOW_WORD64 ... 0147 0148 #elif defined(CRYPTOPP_MSC_VERSION) || defined(__BORLANDC__) 0149 typedef signed __int64 sword64; 0150 typedef unsigned __int64 word64; 0151 #define SW64LIT(x) x##i64 0152 #define W64LIT(x) x##ui64 0153 #elif (_LP64 || __LP64__) 0154 typedef signed long sword64; 0155 typedef unsigned long word64; 0156 #define SW64LIT(x) x##L 0157 #define W64LIT(x) x##UL 0158 #else 0159 typedef signed long long sword64; 0160 typedef unsigned long long word64; 0161 #define SW64LIT(x) x##LL 0162 #define W64LIT(x) x##ULL 0163 #endif 0164 0165 /// \brief Large word type 0166 /// \details lword is a typedef for large word types. It is used for file 0167 /// offsets and such. 0168 typedef word64 lword; 0169 0170 /// \brief Large word type max value 0171 /// \details LWORD_MAX is the maximum value for large word types. 0172 /// Since an <tt>lword</tt> is an unsigned type, the value is 0173 /// <tt>0xffffffffffffffff</tt>. W64LIT will append the proper suffix. 0174 CRYPTOPP_CONST_OR_CONSTEXPR lword LWORD_MAX = W64LIT(0xffffffffffffffff); 0175 0176 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) 0177 /// \brief Half word used for multiprecision integer arithmetic 0178 /// \details hword is used for multiprecision integer arithmetic. 0179 /// The typedef for <tt>hword</tt> varies depending on the platform. 0180 /// On 32-bit platforms it is usually <tt>word16</tt>. On 64-bit platforms 0181 /// it is usually <tt>word32</tt>. 0182 /// \details Library users typically use byte, word16, word32 and word64. 0183 /// \since Crypto++ 2.0 0184 typedef word32 hword; 0185 /// \brief Full word used for multiprecision integer arithmetic 0186 /// \details word is used for multiprecision integer arithmetic. 0187 /// The typedef for <tt>word</tt> varies depending on the platform. 0188 /// On 32-bit platforms it is usually <tt>word32</tt>. On 64-bit platforms 0189 /// it is usually <tt>word64</tt>. 0190 /// \details Library users typically use byte, word16, word32 and word64. 0191 /// \since Crypto++ 2.0 0192 typedef word64 word; 0193 /// \brief Double word used for multiprecision integer arithmetic 0194 /// \details dword is used for multiprecision integer arithmetic. 0195 /// The typedef for <tt>dword</tt> varies depending on the platform. 0196 /// On 32-bit platforms it is usually <tt>word64</tt>. On 64-bit Unix & 0197 /// Linux platforms it is usually <tt>word128</tt>. <tt>word128</tt> is 0198 /// not available on Microsoft platforms. <tt>word128</tt> is only available 0199 /// when <tt>CRYPTOPP_WORD128_AVAILABLE</tt> is defined. 0200 /// \details Library users typically use byte, word16, word32 and word64. 0201 /// \sa CRYPTOPP_WORD128_AVAILABLE 0202 /// \since Crypto++ 2.0 0203 typedef word128 dword; 0204 0205 /// \brief 128-bit word availability 0206 /// \details CRYPTOPP_WORD128_AVAILABLE indicates a 128-bit word is 0207 /// available from the platform. 128-bit words are usually available on 0208 /// 64-bit platforms, but not available 32-bit platforms. 0209 /// \details If CRYPTOPP_WORD128_AVAILABLE is not defined, then 128-bit 0210 /// words are not available. 0211 /// \details GCC and compatible compilers signal 128-bit word availability 0212 /// with the preporcessor macro <tt>__SIZEOF_INT128__ >= 16</tt>. 0213 /// \since Crypto++ 2.0 0214 #define CRYPTOPP_WORD128_AVAILABLE ... 0215 #else 0216 // define hword, word, and dword. these are used for multiprecision integer arithmetic 0217 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx 0218 #if (defined(CRYPTOPP_MSC_VERSION) && (!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__)) 0219 typedef word32 hword; 0220 typedef word64 word; 0221 #else 0222 #define CRYPTOPP_NATIVE_DWORD_AVAILABLE 1 0223 #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) || defined(__aarch64__) 0224 #if ((CRYPTOPP_GCC_VERSION >= 30400) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30000) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300)) && (__SIZEOF_INT128__ >= 16) 0225 // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3 0226 // GCC 4.8.3 and bad uint128_t ops on PPC64/POWER7 (Issue 421) 0227 // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4 0228 typedef word32 hword; 0229 typedef word64 word; 0230 typedef __uint128_t dword; 0231 typedef __uint128_t word128; 0232 #define CRYPTOPP_WORD128_AVAILABLE 1 0233 #else 0234 // 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 0235 typedef word16 hword; 0236 typedef word32 word; 0237 typedef word64 dword; 0238 #endif 0239 #else 0240 // being here means the native register size is probably 32 bits or less 0241 #define CRYPTOPP_BOOL_SLOW_WORD64 1 0242 typedef word16 hword; 0243 typedef word32 word; 0244 typedef word64 dword; 0245 #endif 0246 #endif 0247 #endif 0248 0249 #ifndef CRYPTOPP_BOOL_SLOW_WORD64 0250 # define CRYPTOPP_BOOL_SLOW_WORD64 0 0251 #endif 0252 0253 /// \brief Size of a platform word in bytes 0254 /// \details The size of a platform word, in bytes 0255 CRYPTOPP_CONST_OR_CONSTEXPR unsigned int WORD_SIZE = sizeof(word); 0256 0257 /// \brief Size of a platform word in bits 0258 /// \details The size of a platform word, in bits 0259 /// \sa https://github.com/weidai11/cryptopp/issues/1185 0260 CRYPTOPP_CONST_OR_CONSTEXPR unsigned int WORD_BITS = WORD_SIZE * 8; 0261 0262 NAMESPACE_END 0263 0264 #if (CRYPTOPP_MSC_VERSION) 0265 # pragma warning(pop) 0266 #endif 0267 0268 #endif // CRYPTOPP_CONFIG_INT_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |