source: asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/types.h@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 21.3 KB
Line 
1/* types.h
2 *
3 * Copyright (C) 2006-2017 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22
23
24#ifndef WOLF_CRYPT_TYPES_H
25#define WOLF_CRYPT_TYPES_H
26
27 #include <wolfssl/wolfcrypt/settings.h>
28 #include <wolfssl/wolfcrypt/wc_port.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34
35 #if defined(WORDS_BIGENDIAN)
36 #define BIG_ENDIAN_ORDER
37 #endif
38
39 #ifndef BIG_ENDIAN_ORDER
40 #define LITTLE_ENDIAN_ORDER
41 #endif
42
43 #ifndef WOLFSSL_TYPES
44 #ifndef byte
45 typedef unsigned char byte;
46 #endif
47 typedef unsigned short word16;
48 typedef unsigned int word32;
49 typedef byte word24[3];
50 #endif
51
52
53 /* try to set SIZEOF_LONG or LONG_LONG if user didn't */
54 #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)
55 #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
56 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \
57 || defined(__mips64) || defined(__x86_64__) || \
58 ((defined(sun) || defined(__sun)) && \
59 (defined(LP64) || defined(_LP64))))
60 /* long should be 64bit */
61 #define SIZEOF_LONG 8
62 #elif defined(__i386__) || defined(__CORTEX_M3__)
63 /* long long should be 64bit */
64 #define SIZEOF_LONG_LONG 8
65 #endif
66 #endif
67 #endif
68
69
70 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
71 #define WORD64_AVAILABLE
72 #define W64LIT(x) x##ui64
73 typedef unsigned __int64 word64;
74 #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
75 #define WORD64_AVAILABLE
76 #define W64LIT(x) x##LL
77 typedef unsigned long word64;
78 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
79 #define WORD64_AVAILABLE
80 #define W64LIT(x) x##LL
81 typedef unsigned long long word64;
82 #elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
83 #define WORD64_AVAILABLE
84 #define W64LIT(x) x##LL
85 typedef unsigned long long word64;
86 #else
87 #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as
88 mp_digit, no 64 bit type so make mp_digit 16 bit */
89 #endif
90
91
92 /* These platforms have 64-bit CPU registers. */
93 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
94 defined(__mips64) || defined(__x86_64__) || defined(_M_X64)) || \
95 defined(__aarch64__) || defined(__sparc64__)
96 typedef word64 wolfssl_word;
97 #define WC_64BIT_CPU
98 #elif (defined(sun) || defined(__sun)) && \
99 (defined(LP64) || defined(_LP64))
100 /* LP64 with GNU GCC compiler is reserved for when long int is 64 bits
101 * and int uses 32 bits. When using Solaris Studio sparc and __sparc are
102 * avialable for 32 bit detection but __sparc64__ could be missed. This
103 * uses LP64 for checking 64 bit CPU arch. */
104 typedef word64 wolfssl_word;
105 #define WC_64BIT_CPU
106 #else
107 typedef word32 wolfssl_word;
108 #ifdef WORD64_AVAILABLE
109 #define WOLFCRYPT_SLOW_WORD64
110 #endif
111 #endif
112
113
114 enum {
115 WOLFSSL_WORD_SIZE = sizeof(wolfssl_word),
116 WOLFSSL_BIT_SIZE = 8,
117 WOLFSSL_WORD_BITS = WOLFSSL_WORD_SIZE * WOLFSSL_BIT_SIZE
118 };
119
120 #define WOLFSSL_MAX_16BIT 0xffffU
121
122 /* use inlining if compiler allows */
123 #ifndef INLINE
124 #ifndef NO_INLINE
125 #ifdef _MSC_VER
126 #define INLINE __inline
127 #elif defined(__GNUC__)
128 #ifdef WOLFSSL_VXWORKS
129 #define INLINE __inline__
130 #else
131 #define INLINE inline
132 #endif
133 #elif defined(__IAR_SYSTEMS_ICC__)
134 #define INLINE inline
135 #elif defined(THREADX)
136 #define INLINE _Inline
137 #else
138 #define INLINE
139 #endif
140 #else
141 #define INLINE
142 #endif
143 #endif
144
145
146 /* set up rotate style */
147 #if (defined(_MSC_VER) || defined(__BCPLUSPLUS__)) && \
148 !defined(WOLFSSL_SGX) && !defined(INTIME_RTOS)
149 #define INTEL_INTRINSICS
150 #define FAST_ROTATE
151 #elif defined(__MWERKS__) && TARGET_CPU_PPC
152 #define PPC_INTRINSICS
153 #define FAST_ROTATE
154 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
155 /* GCC does peephole optimizations which should result in using rotate
156 instructions */
157 #define FAST_ROTATE
158 #endif
159
160
161 /* set up thread local storage if available */
162 #ifdef HAVE_THREAD_LS
163 #if defined(_MSC_VER)
164 #define THREAD_LS_T __declspec(thread)
165 /* Thread local storage only in FreeRTOS v8.2.1 and higher */
166 #elif defined(FREERTOS)
167 #define THREAD_LS_T
168 #else
169 #define THREAD_LS_T __thread
170 #endif
171 #else
172 #define THREAD_LS_T
173 #endif
174
175 /* GCC 7 has new switch() fall-through detection */
176 #if defined(__GNUC__)
177 #if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1)))
178 #define FALL_THROUGH __attribute__ ((fallthrough));
179 #endif
180 #endif
181 #ifndef FALL_THROUGH
182 #define FALL_THROUGH
183 #endif
184
185 /* Micrium will use Visual Studio for compilation but not the Win32 API */
186 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
187 !defined(FREERTOS_TCP) && !defined(EBSNET) && \
188 !defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
189 #define USE_WINDOWS_API
190 #endif
191
192
193 /* idea to add global alloc override by Moises Guimaraes */
194 /* default to libc stuff */
195 /* XREALLOC is used once in normal math lib, not in fast math lib */
196 /* XFREE on some embeded systems doesn't like free(0) so test */
197 #if defined(HAVE_IO_POOL)
198 WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
199 WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
200 WOLFSSL_API void XFREE(void *p, void* heap, int type);
201 #elif defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)
202 #include <wolfssl/wolfcrypt/port/intel/quickassist_mem.h>
203 #undef USE_WOLFSSL_MEMORY
204 #ifdef WOLFSSL_DEBUG_MEMORY
205 #define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t), __func__, __LINE__)
206 #define XFREE(p, h, t) IntelQaFree((p), (h), (t), __func__, __LINE__)
207 #define XREALLOC(p, n, h, t) IntelQaRealloc((p), (n), (h), (t), __func__, __LINE__)
208 #else
209 #define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t))
210 #define XFREE(p, h, t) IntelQaFree((p), (h), (t))
211 #define XREALLOC(p, n, h, t) IntelQaRealloc((p), (n), (h), (t))
212 #endif /* WOLFSSL_DEBUG_MEMORY */
213 #elif defined(XMALLOC_USER)
214 /* prototypes for user heap override functions */
215 #include <stddef.h> /* for size_t */
216 extern void *XMALLOC(size_t n, void* heap, int type);
217 extern void *XREALLOC(void *p, size_t n, void* heap, int type);
218 extern void XFREE(void *p, void* heap, int type);
219 #elif defined(XMALLOC_OVERRIDE)
220 /* override the XMALLOC, XFREE and XREALLOC macros */
221 #elif defined(NO_WOLFSSL_MEMORY)
222 /* just use plain C stdlib stuff if desired */
223 #include <stdlib.h>
224 #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
225 #define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
226 #define XREALLOC(p, n, h, t) realloc((p), (n))
227 #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
228 && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \
229 && !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \
230 && !defined(WOLFSSL_LEANPSK) && !defined(FREERTOS) && !defined(FREERTOS_TCP)\
231 && !defined(WOLFSSL_uITRON4)
232 /* default C runtime, can install different routines at runtime via cbs */
233 #include <wolfssl/wolfcrypt/memory.h>
234 #ifdef WOLFSSL_STATIC_MEMORY
235 #ifdef WOLFSSL_DEBUG_MEMORY
236 #define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t), __func__, __LINE__)
237 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t), __func__, __LINE__);}
238 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t), __func__, __LINE__)
239 #else
240 #define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t))
241 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));}
242 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
243 #endif /* WOLFSSL_DEBUG_MEMORY */
244 #else
245 #ifdef WOLFSSL_DEBUG_MEMORY
246 #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__))
247 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);}
248 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), __func__, __LINE__)
249 #else
250 #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
251 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
252 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
253 #endif /* WOLFSSL_DEBUG_MEMORY */
254 #endif /* WOLFSSL_STATIC_MEMORY */
255 #endif
256
257 /* declare/free variable handling for async */
258 #ifdef WOLFSSL_ASYNC_CRYPT
259 #define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
260 VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT);
261 #define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
262 VAR_TYPE* VAR_NAME = ({ \
263 VAR_TYPE* ptr = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \
264 if (ptr && INIT_VALUE) { \
265 XMEMCPY(ptr, INIT_VALUE, sizeof(VAR_TYPE) * VAR_SIZE); \
266 } \
267 ptr; \
268 })
269 #define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
270 VAR_TYPE* VAR_NAME[VAR_ITEMS]; \
271 int idx##VAR_NAME; \
272 for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \
273 VAR_NAME[idx##VAR_NAME] = (VAR_TYPE*)XMALLOC(VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \
274 }
275 #define FREE_VAR(VAR_NAME, HEAP) \
276 XFREE(VAR_NAME, HEAP, DYNAMIC_TYPE_WOLF_BIGINT);
277 #define FREE_ARRAY(VAR_NAME, VAR_ITEMS, HEAP) \
278 for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \
279 XFREE(VAR_NAME[idx##VAR_NAME], HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \
280 }
281 #else
282 #define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
283 VAR_TYPE VAR_NAME[VAR_SIZE]
284 #define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
285 VAR_TYPE* VAR_NAME = (VAR_TYPE*)INIT_VALUE
286 #define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
287 VAR_TYPE VAR_NAME[VAR_ITEMS][VAR_SIZE]
288 #define FREE_VAR(VAR_NAME, HEAP) /* nothing to free, its stack */
289 #define FREE_ARRAY(VAR_NAME, VAR_ITEMS, HEAP) /* nothing to free, its stack */
290 #endif
291
292 #ifndef WOLFSSL_LEANPSK
293 char* mystrnstr(const char* s1, const char* s2, unsigned int n);
294 #endif
295
296 #ifndef STRING_USER
297 #include <string.h>
298 #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
299 #define XMEMSET(b,c,l) memset((b),(c),(l))
300 #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
301 #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
302
303 #define XSTRLEN(s1) strlen((s1))
304 #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
305 /* strstr, strncmp, and strncat only used by wolfSSL proper,
306 * not required for wolfCrypt only */
307 #define XSTRSTR(s1,s2) strstr((s1),(s2))
308 #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
309 #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
310 #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
311
312 #ifdef MICROCHIP_PIC32
313 /* XC32 does not support strncasecmp, so use case sensitive one */
314 #define XSTRNCASECMP(s1,s2,n) strncmp((s1),(s2),(n))
315 #elif defined(USE_WINDOWS_API)
316 #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
317 #else
318 #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
319 #endif
320
321 /* snprintf is used in asn.c for GetTimeString and PKCS7 test */
322 #ifndef USE_WINDOWS_API
323 #define XSNPRINTF snprintf
324 #else
325 #define XSNPRINTF _snprintf
326 #endif
327
328 #if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
329 /* use only Thread Safe version of strtok */
330 #if !defined(USE_WINDOWS_API) && !defined(INTIME_RTOS)
331 #define XSTRTOK strtok_r
332 #elif defined(__MINGW32__) || defined(WOLFSSL_TIRTOS) || \
333 defined(USE_WOLF_STRTOK)
334 #ifndef USE_WOLF_STRTOK
335 #define USE_WOLF_STRTOK
336 #endif
337 #define XSTRTOK wc_strtok
338 #else
339 #define XSTRTOK strtok_s
340 #endif
341 #endif
342 #endif
343
344 #ifndef CTYPE_USER
345 #include <ctype.h>
346 #if defined(HAVE_ECC) || defined(HAVE_OCSP) || defined(WOLFSSL_KEY_GEN)
347 #define XTOUPPER(c) toupper((c))
348 #define XISALPHA(c) isalpha((c))
349 #endif
350 /* needed by wolfSSL_check_domain_name() */
351 #define XTOLOWER(c) tolower((c))
352 #endif
353
354
355 /* memory allocation types for user hints */
356 enum {
357 DYNAMIC_TYPE_CA = 1,
358 DYNAMIC_TYPE_CERT = 2,
359 DYNAMIC_TYPE_KEY = 3,
360 DYNAMIC_TYPE_FILE = 4,
361 DYNAMIC_TYPE_SUBJECT_CN = 5,
362 DYNAMIC_TYPE_PUBLIC_KEY = 6,
363 DYNAMIC_TYPE_SIGNER = 7,
364 DYNAMIC_TYPE_NONE = 8,
365 DYNAMIC_TYPE_BIGINT = 9,
366 DYNAMIC_TYPE_RSA = 10,
367 DYNAMIC_TYPE_METHOD = 11,
368 DYNAMIC_TYPE_OUT_BUFFER = 12,
369 DYNAMIC_TYPE_IN_BUFFER = 13,
370 DYNAMIC_TYPE_INFO = 14,
371 DYNAMIC_TYPE_DH = 15,
372 DYNAMIC_TYPE_DOMAIN = 16,
373 DYNAMIC_TYPE_SSL = 17,
374 DYNAMIC_TYPE_CTX = 18,
375 DYNAMIC_TYPE_WRITEV = 19,
376 DYNAMIC_TYPE_OPENSSL = 20,
377 DYNAMIC_TYPE_DSA = 21,
378 DYNAMIC_TYPE_CRL = 22,
379 DYNAMIC_TYPE_REVOKED = 23,
380 DYNAMIC_TYPE_CRL_ENTRY = 24,
381 DYNAMIC_TYPE_CERT_MANAGER = 25,
382 DYNAMIC_TYPE_CRL_MONITOR = 26,
383 DYNAMIC_TYPE_OCSP_STATUS = 27,
384 DYNAMIC_TYPE_OCSP_ENTRY = 28,
385 DYNAMIC_TYPE_ALTNAME = 29,
386 DYNAMIC_TYPE_SUITES = 30,
387 DYNAMIC_TYPE_CIPHER = 31,
388 DYNAMIC_TYPE_RNG = 32,
389 DYNAMIC_TYPE_ARRAYS = 33,
390 DYNAMIC_TYPE_DTLS_POOL = 34,
391 DYNAMIC_TYPE_SOCKADDR = 35,
392 DYNAMIC_TYPE_LIBZ = 36,
393 DYNAMIC_TYPE_ECC = 37,
394 DYNAMIC_TYPE_TMP_BUFFER = 38,
395 DYNAMIC_TYPE_DTLS_MSG = 39,
396 DYNAMIC_TYPE_X509 = 40,
397 DYNAMIC_TYPE_TLSX = 41,
398 DYNAMIC_TYPE_OCSP = 42,
399 DYNAMIC_TYPE_SIGNATURE = 43,
400 DYNAMIC_TYPE_HASHES = 44,
401 DYNAMIC_TYPE_SRP = 45,
402 DYNAMIC_TYPE_COOKIE_PWD = 46,
403 DYNAMIC_TYPE_USER_CRYPTO = 47,
404 DYNAMIC_TYPE_OCSP_REQUEST = 48,
405 DYNAMIC_TYPE_X509_EXT = 49,
406 DYNAMIC_TYPE_X509_STORE = 50,
407 DYNAMIC_TYPE_X509_CTX = 51,
408 DYNAMIC_TYPE_URL = 52,
409 DYNAMIC_TYPE_DTLS_FRAG = 53,
410 DYNAMIC_TYPE_DTLS_BUFFER = 54,
411 DYNAMIC_TYPE_SESSION_TICK = 55,
412 DYNAMIC_TYPE_PKCS = 56,
413 DYNAMIC_TYPE_MUTEX = 57,
414 DYNAMIC_TYPE_PKCS7 = 58,
415 DYNAMIC_TYPE_AES_BUFFER = 59,
416 DYNAMIC_TYPE_WOLF_BIGINT = 60,
417 DYNAMIC_TYPE_ASN1 = 61,
418 DYNAMIC_TYPE_LOG = 62,
419 DYNAMIC_TYPE_WRITEDUP = 63,
420 DYNAMIC_TYPE_PRIVATE_KEY = 64,
421 DYNAMIC_TYPE_HMAC = 65,
422 DYNAMIC_TYPE_ASYNC = 66,
423 DYNAMIC_TYPE_ASYNC_NUMA = 67,
424 DYNAMIC_TYPE_ASYNC_NUMA64 = 68,
425 DYNAMIC_TYPE_CURVE25519 = 69,
426 DYNAMIC_TYPE_ED25519 = 70,
427 DYNAMIC_TYPE_SECRET = 71,
428 DYNAMIC_TYPE_DIGEST = 72,
429 DYNAMIC_TYPE_RSA_BUFFER = 73,
430 DYNAMIC_TYPE_DCERT = 74,
431 DYNAMIC_TYPE_STRING = 75,
432 DYNAMIC_TYPE_PEM = 76,
433 DYNAMIC_TYPE_DER = 77,
434 DYNAMIC_TYPE_CERT_EXT = 78,
435 DYNAMIC_TYPE_ALPN = 79,
436 DYNAMIC_TYPE_ENCRYPTEDINFO= 80,
437 DYNAMIC_TYPE_DIRCTX = 81,
438 DYNAMIC_TYPE_HASHCTX = 82,
439 DYNAMIC_TYPE_SEED = 83,
440 DYNAMIC_TYPE_SYMETRIC_KEY = 84,
441 DYNAMIC_TYPE_ECC_BUFFER = 85,
442 DYNAMIC_TYPE_QSH = 86,
443 DYNAMIC_TYPE_SALT = 87,
444 DYNAMIC_TYPE_HASH_TMP = 88,
445 };
446
447 /* max error buffer string size */
448 enum {
449 WOLFSSL_MAX_ERROR_SZ = 80
450 };
451
452 /* stack protection */
453 enum {
454 MIN_STACK_BUFFER = 8
455 };
456
457
458
459 /* settings detection for compile vs runtime math incompatibilities */
460 enum {
461 #if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
462 CTC_SETTINGS = 0x0
463 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
464 CTC_SETTINGS = 0x1
465 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
466 CTC_SETTINGS = 0x2
467 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
468 CTC_SETTINGS = 0x4
469 #elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
470 CTC_SETTINGS = 0x8
471 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
472 CTC_SETTINGS = 0x10
473 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
474 CTC_SETTINGS = 0x20
475 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
476 CTC_SETTINGS = 0x40
477 #else
478 #error "bad math long / long long settings"
479 #endif
480 };
481
482
483 WOLFSSL_API word32 CheckRunTimeSettings(void);
484
485 /* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
486 types need to match at compile time and run time, CheckCtcSettings will
487 return 1 if a match otherwise 0 */
488 #define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
489
490 /* invalid device id */
491 #define INVALID_DEVID -2
492
493
494 /* AESNI requires alignment and ARMASM gains some performance from it */
495 #if defined(WOLFSSL_AESNI) || defined(WOLFSSL_ARMASM) || defined(USE_INTEL_SPEEDUP)
496 #if !defined(ALIGN16)
497 #if defined(__GNUC__)
498 #define ALIGN16 __attribute__ ( (aligned (16)))
499 #elif defined(_MSC_VER)
500 /* disable align warning, we want alignment ! */
501 #pragma warning(disable: 4324)
502 #define ALIGN16 __declspec (align (16))
503 #else
504 #define ALIGN16
505 #endif
506 #endif /* !ALIGN16 */
507
508 #if !defined (ALIGN32)
509 #if defined (__GNUC__)
510 #define ALIGN32 __attribute__ ( (aligned (32)))
511 #elif defined(_MSC_VER)
512 /* disable align warning, we want alignment ! */
513 #pragma warning(disable: 4324)
514 #define ALIGN32 __declspec (align (32))
515 #else
516 #define ALIGN32
517 #endif
518 #endif
519
520 #if !defined(ALIGN32)
521 #if defined(__GNUC__)
522 #define ALIGN32 __attribute__ ( (aligned (32)))
523 #elif defined(_MSC_VER)
524 /* disable align warning, we want alignment ! */
525 #pragma warning(disable: 4324)
526 #define ALIGN32 __declspec (align (32))
527 #else
528 #define ALIGN32
529 #endif
530 #endif /* !ALIGN32 */
531
532 #if defined(__GNUC__)
533 #define ALIGN128 __attribute__ ( (aligned (128)))
534 #elif defined(_MSC_VER)
535 /* disable align warning, we want alignment ! */
536 #pragma warning(disable: 4324)
537 #define ALIGN128 __declspec (align (128))
538 #else
539 #define ALIGN128
540 #endif
541
542 #if defined(__GNUC__)
543 #define ALIGN256 __attribute__ ( (aligned (256)))
544 #elif defined(_MSC_VER)
545 /* disable align warning, we want alignment ! */
546 #pragma warning(disable: 4324)
547 #define ALIGN256 __declspec (align (256))
548 #else
549 #define ALIGN256
550 #endif
551
552 #else
553 #ifndef ALIGN16
554 #define ALIGN16
555 #endif
556 #ifndef ALIGN32
557 #define ALIGN32
558 #endif
559 #ifndef ALIGN128
560 #define ALIGN128
561 #endif
562 #ifndef ALIGN256
563 #define ALIGN256
564 #endif
565 #endif /* WOLFSSL_AESNI || WOLFSSL_ARMASM */
566
567
568 #ifndef TRUE
569 #define TRUE 1
570 #endif
571 #ifndef FALSE
572 #define FALSE 0
573 #endif
574
575
576 #ifdef WOLFSSL_RIOT_OS
577 #define EXIT_TEST(ret) exit(ret)
578 #elif defined(HAVE_STACK_SIZE)
579 #define EXIT_TEST(ret) return (void*)((size_t)(ret))
580 #else
581 #define EXIT_TEST(ret) return ret
582 #endif
583
584 #ifdef __cplusplus
585 } /* extern "C" */
586 #endif
587
588#endif /* WOLF_CRYPT_TYPES_H */
Note: See TracBrowser for help on using the repository browser.