comparison libtomcrypt/src/headers/tomcrypt_cfg.h @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2 *
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
5 *
6 * The library is free for all purposes without any express
7 * guarantee it works.
8 */
9
1 /* This is the build config file. 10 /* This is the build config file.
2 * 11 *
3 * With this you can setup what to inlcude/exclude automatically during any build. Just comment 12 * With this you can setup what to inlcude/exclude automatically during any build. Just comment
4 * out the line that #define's the word for the thing you want to remove. phew! 13 * out the line that #define's the word for the thing you want to remove. phew!
5 */ 14 */
6 15
7 #ifndef TOMCRYPT_CFG_H 16 #ifndef TOMCRYPT_CFG_H
8 #define TOMCRYPT_CFG_H 17 #define TOMCRYPT_CFG_H
9 18
10 #if defined(_WIN32) || defined(_MSC_VER) 19 #if defined(_WIN32) || defined(_MSC_VER)
11 #define LTC_CALL __cdecl 20 #define LTC_CALL __cdecl
12 #else 21 #elif !defined(LTC_CALL)
13 #ifndef LTC_CALL
14 #define LTC_CALL 22 #define LTC_CALL
15 #endif 23 #endif
16 #endif
17 24
18 #ifndef LTC_EXPORT 25 #ifndef LTC_EXPORT
19 #define LTC_EXPORT 26 #define LTC_EXPORT
20 #endif 27 #endif
21 28
22 /* certain platforms use macros for these, making the prototypes broken */ 29 /* certain platforms use macros for these, making the prototypes broken */
23 #ifndef LTC_NO_PROTOTYPES 30 #ifndef LTC_NO_PROTOTYPES
24 31
41 48
42 LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2); 49 LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
43 50
44 #endif 51 #endif
45 52
53 /* some compilers do not like "inline" (or maybe "static inline"), namely: HP cc, IBM xlc */
54 #if defined(__HP_cc) || defined(__xlc__)
55 #define LTC_INLINE
56 #elif defined(_MSC_VER)
57 #define LTC_INLINE __inline
58 #else
59 #define LTC_INLINE inline
60 #endif
61
46 /* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */ 62 /* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */
47 #ifndef ARGTYPE 63 #ifndef ARGTYPE
48 #define ARGTYPE 0 64 #define ARGTYPE 0
49 #endif 65 #endif
50 66
51 /* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code 67 #undef LTC_ENCRYPT
52 * 68 #define LTC_ENCRYPT 0
69 #undef LTC_DECRYPT
70 #define LTC_DECRYPT 1
71
72 /* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code
73 *
53 * Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes. 74 * Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes.
54 * The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST** 75 * The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST**
55 * use the portable [slower] macros. 76 * use the portable [slower] macros.
56 */ 77 */
57 78 /* detect x86/i386 32bit */
58 /* detect x86-32 machines somewhat */ 79 #if defined(__i386__) || defined(__i386) || defined(_M_IX86)
59 #if !defined(__STRICT_ANSI__) && (defined(INTEL_CC) || (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__))))
60 #define ENDIAN_LITTLE 80 #define ENDIAN_LITTLE
61 #define ENDIAN_32BITWORD 81 #define ENDIAN_32BITWORD
62 #define LTC_FAST 82 #define LTC_FAST
63 #define LTC_FAST_TYPE unsigned long 83 #endif
84
85 /* detect amd64/x64 */
86 #if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64)
87 #define ENDIAN_LITTLE
88 #define ENDIAN_64BITWORD
89 #define LTC_FAST
90 #endif
91
92 /* detect PPC32 */
93 #if defined(LTC_PPC32)
94 #define ENDIAN_BIG
95 #define ENDIAN_32BITWORD
96 #define LTC_FAST
64 #endif 97 #endif
65 98
66 /* detects MIPS R5900 processors (PS2) */ 99 /* detects MIPS R5900 processors (PS2) */
67 #if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips)) 100 #if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips))
68 #define ENDIAN_LITTLE
69 #define ENDIAN_64BITWORD 101 #define ENDIAN_64BITWORD
70 #endif 102 #if defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
71 103 #define ENDIAN_BIG
72 /* detect amd64 */ 104 #endif
73 #if !defined(__STRICT_ANSI__) && defined(__x86_64__) 105 #define ENDIAN_LITTLE
74 #define ENDIAN_LITTLE 106 #endif
107 #endif
108
109 /* detect AIX */
110 #if defined(_AIX) && defined(_BIG_ENDIAN)
111 #define ENDIAN_BIG
112 #if defined(__LP64__) || defined(_ARCH_PPC64)
113 #define ENDIAN_64BITWORD
114 #else
115 #define ENDIAN_32BITWORD
116 #endif
117 #endif
118
119 /* detect HP-UX */
120 #if defined(__hpux) || defined(__hpux__)
121 #define ENDIAN_BIG
122 #if defined(__ia64) || defined(__ia64__) || defined(__LP64__)
123 #define ENDIAN_64BITWORD
124 #else
125 #define ENDIAN_32BITWORD
126 #endif
127 #endif
128
129 /* detect Apple OS X */
130 #if defined(__APPLE__) && defined(__MACH__)
131 #if defined(__LITTLE_ENDIAN__) || defined(__x86_64__)
132 #define ENDIAN_LITTLE
133 #else
134 #define ENDIAN_BIG
135 #endif
136 #if defined(__LP64__) || defined(__x86_64__)
137 #define ENDIAN_64BITWORD
138 #else
139 #define ENDIAN_32BITWORD
140 #endif
141 #endif
142
143 /* detect SPARC and SPARC64 */
144 #if defined(__sparc__) || defined(__sparc)
145 #define ENDIAN_BIG
146 #if defined(__arch64__) || defined(__sparcv9) || defined(__sparc_v9__)
147 #define ENDIAN_64BITWORD
148 #else
149 #define ENDIAN_32BITWORD
150 #endif
151 #endif
152
153 /* detect IBM S390(x) */
154 #if defined(__s390x__) || defined(__s390__)
155 #define ENDIAN_BIG
156 #if defined(__s390x__)
157 #define ENDIAN_64BITWORD
158 #else
159 #define ENDIAN_32BITWORD
160 #endif
161 #endif
162
163 /* detect PPC64 */
164 #if defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)
75 #define ENDIAN_64BITWORD 165 #define ENDIAN_64BITWORD
76 #define LTC_FAST 166 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
77 #define LTC_FAST_TYPE unsigned long 167 #define ENDIAN_BIG
78 #endif 168 #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
79 169 #define ENDIAN_LITTLE
80 /* detect PPC32 */ 170 #endif
81 #if !defined(__STRICT_ANSI__) && defined(LTC_PPC32) 171 #define LTC_FAST
82 #define ENDIAN_BIG 172 #endif
83 #define ENDIAN_32BITWORD 173
84 #define LTC_FAST 174 /* endianness fallback */
85 #define LTC_FAST_TYPE unsigned long 175 #if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
86 #endif 176 #if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \
87 177 defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
88 /* detect sparc and sparc64 */ 178 defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || \
89 #if defined(__sparc__) 179 defined(__BIG_ENDIAN__) || \
90 #define ENDIAN_BIG 180 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
91 #if defined(__arch64__) 181 defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
92 #define ENDIAN_64BITWORD 182 #define ENDIAN_BIG
93 #else 183 #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN || \
94 #define ENDIAN_32BITWORD 184 defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \
95 #endif 185 defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || \
96 #endif 186 defined(__LITTLE_ENDIAN__) || \
97 187 defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
98 188 defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
99 #ifdef LTC_NO_FAST 189 #define ENDIAN_LITTLE
100 #ifdef LTC_FAST 190 #else
101 #undef LTC_FAST 191 #error Cannot detect endianness
102 #endif 192 #endif
193 #endif
194
195 /* ulong64: 64-bit data type */
196 #ifdef _MSC_VER
197 #define CONST64(n) n ## ui64
198 typedef unsigned __int64 ulong64;
199 #else
200 #define CONST64(n) n ## ULL
201 typedef unsigned long long ulong64;
202 #endif
203
204 /* ulong32: "32-bit at least" data type */
205 #if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \
206 defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
207 defined(__s390x__) || defined(__arch64__) || defined(__aarch64__) || \
208 defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
209 defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
210 defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
211 typedef unsigned ulong32;
212 #if !defined(ENDIAN_64BITWORD) && !defined(ENDIAN_32BITWORD)
213 #define ENDIAN_64BITWORD
214 #endif
215 #else
216 typedef unsigned long ulong32;
217 #if !defined(ENDIAN_64BITWORD) && !defined(ENDIAN_32BITWORD)
218 #define ENDIAN_32BITWORD
219 #endif
220 #endif
221
222 #if defined(ENDIAN_64BITWORD) && !defined(_MSC_VER)
223 typedef unsigned long long ltc_mp_digit;
224 #else
225 typedef unsigned long ltc_mp_digit;
103 #endif 226 #endif
104 227
105 /* No asm is a quick way to disable anything "not portable" */ 228 /* No asm is a quick way to disable anything "not portable" */
106 #ifdef LTC_NO_ASM 229 #ifdef LTC_NO_ASM
107 #undef ENDIAN_LITTLE 230 #define ENDIAN_NEUTRAL
108 #undef ENDIAN_BIG
109 #undef ENDIAN_32BITWORD 231 #undef ENDIAN_32BITWORD
110 #undef ENDIAN_64BITWORD 232 #undef ENDIAN_64BITWORD
111 #undef LTC_FAST 233 #undef LTC_FAST
112 #undef LTC_FAST_TYPE
113 #define LTC_NO_ROLC 234 #define LTC_NO_ROLC
114 #define LTC_NO_BSWAP 235 #define LTC_NO_BSWAP
115 #endif 236 #endif
116 237
117 /* #define ENDIAN_LITTLE */ 238 /* No LTC_FAST if: explicitly disabled OR non-gcc/non-clang compiler OR old gcc OR using -ansi -std=c99 */
118 /* #define ENDIAN_BIG */ 239 #if defined(LTC_NO_FAST) || (__GNUC__ < 4) || defined(__STRICT_ANSI__)
119 240 #undef LTC_FAST
120 /* #define ENDIAN_32BITWORD */ 241 #endif
121 /* #define ENDIAN_64BITWORD */ 242
122 243 #ifdef LTC_FAST
123 #if (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD)) 244 #define LTC_FAST_TYPE_PTR_CAST(x) ((LTC_FAST_TYPE*)(void*)(x))
124 #error You must specify a word size as well as endianess in tomcrypt_cfg.h 245 #ifdef ENDIAN_64BITWORD
246 typedef ulong64 __attribute__((__may_alias__)) LTC_FAST_TYPE;
247 #else
248 typedef ulong32 __attribute__((__may_alias__)) LTC_FAST_TYPE;
249 #endif
250 #endif
251
252 #if !defined(ENDIAN_NEUTRAL) && (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD))
253 #error You must specify a word size as well as endianess in tomcrypt_cfg.h
125 #endif 254 #endif
126 255
127 #if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) 256 #if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE))
128 #define ENDIAN_NEUTRAL 257 #define ENDIAN_NEUTRAL
129 #endif 258 #endif
130 259
131 #endif 260 #if (defined(ENDIAN_32BITWORD) && defined(ENDIAN_64BITWORD))
132 261 #error Cannot be 32 and 64 bit words...
133 262 #endif
134 /* $Source$ */ 263
135 /* $Revision$ */ 264 /* gcc 4.3 and up has a bswap builtin; detect it by gcc version.
136 /* $Date$ */ 265 * clang also supports the bswap builtin, and although clang pretends
266 * to be gcc (macro-wise, anyway), clang pretends to be a version
267 * prior to gcc 4.3, so we can't detect bswap that way. Instead,
268 * clang has a __has_builtin mechanism that can be used to check
269 * for builtins:
270 * http://clang.llvm.org/docs/LanguageExtensions.html#feature_check */
271 #ifndef __has_builtin
272 #define __has_builtin(x) 0
273 #endif
274 #if !defined(LTC_NO_BSWAP) && defined(__GNUC__) && \
275 ((__GNUC__ * 100 + __GNUC_MINOR__ >= 403) || \
276 (__has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)))
277 #define LTC_HAVE_BSWAP_BUILTIN
278 #endif
279
280
281 /* ref: $Format:%D$ */
282 /* git commit: $Format:%H$ */
283 /* commit time: $Format:%ai$ */