wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue May 02 08:44:47 2017 +0000
Revision:
7:481bce714567
wolfSSL3.10.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 7:481bce714567 1 /* types.h
wolfSSL 7:481bce714567 2 *
wolfSSL 7:481bce714567 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 7:481bce714567 4 *
wolfSSL 7:481bce714567 5 * This file is part of wolfSSL.
wolfSSL 7:481bce714567 6 *
wolfSSL 7:481bce714567 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 7:481bce714567 8 * it under the terms of the GNU General Public License as published by
wolfSSL 7:481bce714567 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 7:481bce714567 10 * (at your option) any later version.
wolfSSL 7:481bce714567 11 *
wolfSSL 7:481bce714567 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 7:481bce714567 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 7:481bce714567 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 7:481bce714567 15 * GNU General Public License for more details.
wolfSSL 7:481bce714567 16 *
wolfSSL 7:481bce714567 17 * You should have received a copy of the GNU General Public License
wolfSSL 7:481bce714567 18 * along with this program; if not, write to the Free Software
wolfSSL 7:481bce714567 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 7:481bce714567 20 */
wolfSSL 7:481bce714567 21
wolfSSL 7:481bce714567 22
wolfSSL 7:481bce714567 23
wolfSSL 7:481bce714567 24 #ifndef WOLF_CRYPT_TYPES_H
wolfSSL 7:481bce714567 25 #define WOLF_CRYPT_TYPES_H
wolfSSL 7:481bce714567 26
wolfSSL 7:481bce714567 27 #include <wolfssl/wolfcrypt/settings.h>
wolfSSL 7:481bce714567 28 #include <wolfssl/wolfcrypt/wc_port.h>
wolfSSL 7:481bce714567 29
wolfSSL 7:481bce714567 30 #ifdef __cplusplus
wolfSSL 7:481bce714567 31 extern "C" {
wolfSSL 7:481bce714567 32 #endif
wolfSSL 7:481bce714567 33
wolfSSL 7:481bce714567 34
wolfSSL 7:481bce714567 35 #if defined(WORDS_BIGENDIAN)
wolfSSL 7:481bce714567 36 #define BIG_ENDIAN_ORDER
wolfSSL 7:481bce714567 37 #endif
wolfSSL 7:481bce714567 38
wolfSSL 7:481bce714567 39 #ifndef BIG_ENDIAN_ORDER
wolfSSL 7:481bce714567 40 #define LITTLE_ENDIAN_ORDER
wolfSSL 7:481bce714567 41 #endif
wolfSSL 7:481bce714567 42
wolfSSL 7:481bce714567 43 #ifndef WOLFSSL_TYPES
wolfSSL 7:481bce714567 44 #ifndef byte
wolfSSL 7:481bce714567 45 typedef unsigned char byte;
wolfSSL 7:481bce714567 46 #endif
wolfSSL 7:481bce714567 47 typedef unsigned short word16;
wolfSSL 7:481bce714567 48 typedef unsigned int word32;
wolfSSL 7:481bce714567 49 #endif
wolfSSL 7:481bce714567 50
wolfSSL 7:481bce714567 51
wolfSSL 7:481bce714567 52 /* try to set SIZEOF_LONG or LONG_LONG if user didn't */
wolfSSL 7:481bce714567 53 #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)
wolfSSL 7:481bce714567 54 #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
wolfSSL 7:481bce714567 55 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \
wolfSSL 7:481bce714567 56 || defined(__mips64) || defined(__x86_64__))
wolfSSL 7:481bce714567 57 /* long should be 64bit */
wolfSSL 7:481bce714567 58 #define SIZEOF_LONG 8
wolfSSL 7:481bce714567 59 #elif defined(__i386__) || defined(__CORTEX_M3__)
wolfSSL 7:481bce714567 60 /* long long should be 64bit */
wolfSSL 7:481bce714567 61 #define SIZEOF_LONG_LONG 8
wolfSSL 7:481bce714567 62 #endif
wolfSSL 7:481bce714567 63 #endif
wolfSSL 7:481bce714567 64 #endif
wolfSSL 7:481bce714567 65
wolfSSL 7:481bce714567 66
wolfSSL 7:481bce714567 67 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
wolfSSL 7:481bce714567 68 #define WORD64_AVAILABLE
wolfSSL 7:481bce714567 69 #define W64LIT(x) x##ui64
wolfSSL 7:481bce714567 70 typedef unsigned __int64 word64;
wolfSSL 7:481bce714567 71 #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
wolfSSL 7:481bce714567 72 #define WORD64_AVAILABLE
wolfSSL 7:481bce714567 73 #define W64LIT(x) x##LL
wolfSSL 7:481bce714567 74 typedef unsigned long word64;
wolfSSL 7:481bce714567 75 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
wolfSSL 7:481bce714567 76 #define WORD64_AVAILABLE
wolfSSL 7:481bce714567 77 #define W64LIT(x) x##LL
wolfSSL 7:481bce714567 78 typedef unsigned long long word64;
wolfSSL 7:481bce714567 79 #elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
wolfSSL 7:481bce714567 80 #define WORD64_AVAILABLE
wolfSSL 7:481bce714567 81 #define W64LIT(x) x##LL
wolfSSL 7:481bce714567 82 typedef unsigned long long word64;
wolfSSL 7:481bce714567 83 #else
wolfSSL 7:481bce714567 84 #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as
wolfSSL 7:481bce714567 85 mp_digit, no 64 bit type so make mp_digit 16 bit */
wolfSSL 7:481bce714567 86 #endif
wolfSSL 7:481bce714567 87
wolfSSL 7:481bce714567 88
wolfSSL 7:481bce714567 89 /* These platforms have 64-bit CPU registers. */
wolfSSL 7:481bce714567 90 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
wolfSSL 7:481bce714567 91 defined(__mips64) || defined(__x86_64__) || defined(_M_X64)) || \
wolfSSL 7:481bce714567 92 defined(__aarch64__)
wolfSSL 7:481bce714567 93 typedef word64 wolfssl_word;
wolfSSL 7:481bce714567 94 #define WC_64BIT_CPU
wolfSSL 7:481bce714567 95 #else
wolfSSL 7:481bce714567 96 typedef word32 wolfssl_word;
wolfSSL 7:481bce714567 97 #ifdef WORD64_AVAILABLE
wolfSSL 7:481bce714567 98 #define WOLFCRYPT_SLOW_WORD64
wolfSSL 7:481bce714567 99 #endif
wolfSSL 7:481bce714567 100 #endif
wolfSSL 7:481bce714567 101
wolfSSL 7:481bce714567 102
wolfSSL 7:481bce714567 103 enum {
wolfSSL 7:481bce714567 104 WOLFSSL_WORD_SIZE = sizeof(wolfssl_word),
wolfSSL 7:481bce714567 105 WOLFSSL_BIT_SIZE = 8,
wolfSSL 7:481bce714567 106 WOLFSSL_WORD_BITS = WOLFSSL_WORD_SIZE * WOLFSSL_BIT_SIZE
wolfSSL 7:481bce714567 107 };
wolfSSL 7:481bce714567 108
wolfSSL 7:481bce714567 109 #define WOLFSSL_MAX_16BIT 0xffffU
wolfSSL 7:481bce714567 110
wolfSSL 7:481bce714567 111 /* use inlining if compiler allows */
wolfSSL 7:481bce714567 112 #ifndef INLINE
wolfSSL 7:481bce714567 113 #ifndef NO_INLINE
wolfSSL 7:481bce714567 114 #ifdef _MSC_VER
wolfSSL 7:481bce714567 115 #define INLINE __inline
wolfSSL 7:481bce714567 116 #elif defined(__GNUC__)
wolfSSL 7:481bce714567 117 #ifdef WOLFSSL_VXWORKS
wolfSSL 7:481bce714567 118 #define INLINE __inline__
wolfSSL 7:481bce714567 119 #else
wolfSSL 7:481bce714567 120 #define INLINE inline
wolfSSL 7:481bce714567 121 #endif
wolfSSL 7:481bce714567 122 #elif defined(__IAR_SYSTEMS_ICC__)
wolfSSL 7:481bce714567 123 #define INLINE inline
wolfSSL 7:481bce714567 124 #elif defined(THREADX)
wolfSSL 7:481bce714567 125 #define INLINE _Inline
wolfSSL 7:481bce714567 126 #else
wolfSSL 7:481bce714567 127 #define INLINE
wolfSSL 7:481bce714567 128 #endif
wolfSSL 7:481bce714567 129 #else
wolfSSL 7:481bce714567 130 #define INLINE
wolfSSL 7:481bce714567 131 #endif
wolfSSL 7:481bce714567 132 #endif
wolfSSL 7:481bce714567 133
wolfSSL 7:481bce714567 134
wolfSSL 7:481bce714567 135 /* set up rotate style */
wolfSSL 7:481bce714567 136 #if (defined(_MSC_VER) || defined(__BCPLUSPLUS__)) && !defined(WOLFSSL_SGX)
wolfSSL 7:481bce714567 137 #define INTEL_INTRINSICS
wolfSSL 7:481bce714567 138 #define FAST_ROTATE
wolfSSL 7:481bce714567 139 #elif defined(__MWERKS__) && TARGET_CPU_PPC
wolfSSL 7:481bce714567 140 #define PPC_INTRINSICS
wolfSSL 7:481bce714567 141 #define FAST_ROTATE
wolfSSL 7:481bce714567 142 #elif defined(__GNUC__) && defined(__i386__)
wolfSSL 7:481bce714567 143 /* GCC does peephole optimizations which should result in using rotate
wolfSSL 7:481bce714567 144 instructions */
wolfSSL 7:481bce714567 145 #define FAST_ROTATE
wolfSSL 7:481bce714567 146 #endif
wolfSSL 7:481bce714567 147
wolfSSL 7:481bce714567 148
wolfSSL 7:481bce714567 149 /* set up thread local storage if available */
wolfSSL 7:481bce714567 150 #ifdef HAVE_THREAD_LS
wolfSSL 7:481bce714567 151 #if defined(_MSC_VER)
wolfSSL 7:481bce714567 152 #define THREAD_LS_T __declspec(thread)
wolfSSL 7:481bce714567 153 /* Thread local storage only in FreeRTOS v8.2.1 and higher */
wolfSSL 7:481bce714567 154 #elif defined(FREERTOS)
wolfSSL 7:481bce714567 155 #define THREAD_LS_T
wolfSSL 7:481bce714567 156 #else
wolfSSL 7:481bce714567 157 #define THREAD_LS_T __thread
wolfSSL 7:481bce714567 158 #endif
wolfSSL 7:481bce714567 159 #else
wolfSSL 7:481bce714567 160 #define THREAD_LS_T
wolfSSL 7:481bce714567 161 #endif
wolfSSL 7:481bce714567 162
wolfSSL 7:481bce714567 163
wolfSSL 7:481bce714567 164 /* Micrium will use Visual Studio for compilation but not the Win32 API */
wolfSSL 7:481bce714567 165 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
wolfSSL 7:481bce714567 166 !defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_UTASKER)
wolfSSL 7:481bce714567 167 #define USE_WINDOWS_API
wolfSSL 7:481bce714567 168 #endif
wolfSSL 7:481bce714567 169
wolfSSL 7:481bce714567 170
wolfSSL 7:481bce714567 171 /* idea to add global alloc override by Moises Guimaraes */
wolfSSL 7:481bce714567 172 /* default to libc stuff */
wolfSSL 7:481bce714567 173 /* XREALLOC is used once in normal math lib, not in fast math lib */
wolfSSL 7:481bce714567 174 /* XFREE on some embeded systems doesn't like free(0) so test */
wolfSSL 7:481bce714567 175 #if defined(HAVE_IO_POOL)
wolfSSL 7:481bce714567 176 WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
wolfSSL 7:481bce714567 177 WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
wolfSSL 7:481bce714567 178 WOLFSSL_API void XFREE(void *p, void* heap, int type);
wolfSSL 7:481bce714567 179 #elif defined(XMALLOC_USER)
wolfSSL 7:481bce714567 180 /* prototypes for user heap override functions */
wolfSSL 7:481bce714567 181 #include <stddef.h> /* for size_t */
wolfSSL 7:481bce714567 182 extern void *XMALLOC(size_t n, void* heap, int type);
wolfSSL 7:481bce714567 183 extern void *XREALLOC(void *p, size_t n, void* heap, int type);
wolfSSL 7:481bce714567 184 extern void XFREE(void *p, void* heap, int type);
wolfSSL 7:481bce714567 185 #elif defined(NO_WOLFSSL_MEMORY)
wolfSSL 7:481bce714567 186 /* just use plain C stdlib stuff if desired */
wolfSSL 7:481bce714567 187 #include <stdlib.h>
wolfSSL 7:481bce714567 188 #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
wolfSSL 7:481bce714567 189 #define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
wolfSSL 7:481bce714567 190 #define XREALLOC(p, n, h, t) realloc((p), (n))
wolfSSL 7:481bce714567 191 #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
wolfSSL 7:481bce714567 192 && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \
wolfSSL 7:481bce714567 193 && !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \
wolfSSL 7:481bce714567 194 && !defined(WOLFSSL_LEANPSK) && !defined(FREERTOS) && !defined(FREERTOS_TCP)\
wolfSSL 7:481bce714567 195 && !defined(WOLFSSL_uITRON4) && !defined(WOLFSSL_uTKERNEL2)
wolfSSL 7:481bce714567 196 /* default C runtime, can install different routines at runtime via cbs */
wolfSSL 7:481bce714567 197 #include <wolfssl/wolfcrypt/memory.h>
wolfSSL 7:481bce714567 198 #ifdef WOLFSSL_STATIC_MEMORY
wolfSSL 7:481bce714567 199 #ifdef WOLFSSL_DEBUG_MEMORY
wolfSSL 7:481bce714567 200 #define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t), __func__, __LINE__)
wolfSSL 7:481bce714567 201 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t), __func__, __LINE__);}
wolfSSL 7:481bce714567 202 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t), __func__, __LINE__)
wolfSSL 7:481bce714567 203 #else
wolfSSL 7:481bce714567 204 #define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t))
wolfSSL 7:481bce714567 205 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));}
wolfSSL 7:481bce714567 206 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
wolfSSL 7:481bce714567 207 #endif /* WOLFSSL_DEBUG_MEMORY */
wolfSSL 7:481bce714567 208 #else
wolfSSL 7:481bce714567 209 #ifdef WOLFSSL_DEBUG_MEMORY
wolfSSL 7:481bce714567 210 #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__))
wolfSSL 7:481bce714567 211 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);}
wolfSSL 7:481bce714567 212 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), __func__, __LINE__)
wolfSSL 7:481bce714567 213 #else
wolfSSL 7:481bce714567 214 #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
wolfSSL 7:481bce714567 215 #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
wolfSSL 7:481bce714567 216 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
wolfSSL 7:481bce714567 217 #endif /* WOLFSSL_DEBUG_MEMORY */
wolfSSL 7:481bce714567 218 #endif /* WOLFSSL_STATIC_MEMORY */
wolfSSL 7:481bce714567 219 #endif
wolfSSL 7:481bce714567 220
wolfSSL 7:481bce714567 221
wolfSSL 7:481bce714567 222 #ifndef STRING_USER
wolfSSL 7:481bce714567 223 #include <string.h>
wolfSSL 7:481bce714567 224 char* mystrnstr(const char* s1, const char* s2, unsigned int n);
wolfSSL 7:481bce714567 225
wolfSSL 7:481bce714567 226 #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
wolfSSL 7:481bce714567 227 #define XMEMSET(b,c,l) memset((b),(c),(l))
wolfSSL 7:481bce714567 228 #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
wolfSSL 7:481bce714567 229 #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
wolfSSL 7:481bce714567 230
wolfSSL 7:481bce714567 231 #define XSTRLEN(s1) strlen((s1))
wolfSSL 7:481bce714567 232 #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
wolfSSL 7:481bce714567 233 /* strstr, strncmp, and strncat only used by wolfSSL proper,
wolfSSL 7:481bce714567 234 * not required for wolfCrypt only */
wolfSSL 7:481bce714567 235 #define XSTRSTR(s1,s2) strstr((s1),(s2))
wolfSSL 7:481bce714567 236 #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
wolfSSL 7:481bce714567 237 #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
wolfSSL 7:481bce714567 238 #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
wolfSSL 7:481bce714567 239 #ifndef USE_WINDOWS_API
wolfSSL 7:481bce714567 240 #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
wolfSSL 7:481bce714567 241 #else
wolfSSL 7:481bce714567 242 #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
wolfSSL 7:481bce714567 243 #endif
wolfSSL 7:481bce714567 244
wolfSSL 7:481bce714567 245 #if defined(WOLFSSL_MYSQL_COMPATIBLE)
wolfSSL 7:481bce714567 246 #ifndef USE_WINDOWS_API
wolfSSL 7:481bce714567 247 #define XSNPRINTF snprintf
wolfSSL 7:481bce714567 248 #else
wolfSSL 7:481bce714567 249 #define XSNPRINTF _snprintf
wolfSSL 7:481bce714567 250 #endif
wolfSSL 7:481bce714567 251 #endif /* WOLFSSL_MYSQL_COMPATIBLE */
wolfSSL 7:481bce714567 252
wolfSSL 7:481bce714567 253 #if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
wolfSSL 7:481bce714567 254 /* use only Thread Safe version of strtok */
wolfSSL 7:481bce714567 255 #ifndef USE_WINDOWS_API
wolfSSL 7:481bce714567 256 #define XSTRTOK strtok_r
wolfSSL 7:481bce714567 257 #else
wolfSSL 7:481bce714567 258 #define XSTRTOK strtok_s
wolfSSL 7:481bce714567 259
wolfSSL 7:481bce714567 260 #ifdef __MINGW32__
wolfSSL 7:481bce714567 261 #pragma GCC diagnostic push
wolfSSL 7:481bce714567 262 #pragma GCC diagnostic warning "-Wcpp"
wolfSSL 7:481bce714567 263 #warning "MinGW may be missing strtok_s. You can find a public domain implementation here: https://github.com/fletcher/MultiMarkdown-4/blob/master/strtok.c"
wolfSSL 7:481bce714567 264 #pragma GCC diagnostic pop
wolfSSL 7:481bce714567 265 #endif
wolfSSL 7:481bce714567 266 #endif
wolfSSL 7:481bce714567 267 #endif
wolfSSL 7:481bce714567 268 #endif
wolfSSL 7:481bce714567 269
wolfSSL 7:481bce714567 270 #ifndef CTYPE_USER
wolfSSL 7:481bce714567 271 #include <ctype.h>
wolfSSL 7:481bce714567 272 #if defined(HAVE_ECC) || defined(HAVE_OCSP) || defined(WOLFSSL_KEY_GEN)
wolfSSL 7:481bce714567 273 #define XTOUPPER(c) toupper((c))
wolfSSL 7:481bce714567 274 #define XISALPHA(c) isalpha((c))
wolfSSL 7:481bce714567 275 #endif
wolfSSL 7:481bce714567 276 /* needed by wolfSSL_check_domain_name() */
wolfSSL 7:481bce714567 277 #define XTOLOWER(c) tolower((c))
wolfSSL 7:481bce714567 278 #endif
wolfSSL 7:481bce714567 279
wolfSSL 7:481bce714567 280
wolfSSL 7:481bce714567 281 /* memory allocation types for user hints */
wolfSSL 7:481bce714567 282 enum {
wolfSSL 7:481bce714567 283 DYNAMIC_TYPE_CA = 1,
wolfSSL 7:481bce714567 284 DYNAMIC_TYPE_CERT = 2,
wolfSSL 7:481bce714567 285 DYNAMIC_TYPE_KEY = 3,
wolfSSL 7:481bce714567 286 DYNAMIC_TYPE_FILE = 4,
wolfSSL 7:481bce714567 287 DYNAMIC_TYPE_SUBJECT_CN = 5,
wolfSSL 7:481bce714567 288 DYNAMIC_TYPE_PUBLIC_KEY = 6,
wolfSSL 7:481bce714567 289 DYNAMIC_TYPE_SIGNER = 7,
wolfSSL 7:481bce714567 290 DYNAMIC_TYPE_NONE = 8,
wolfSSL 7:481bce714567 291 DYNAMIC_TYPE_BIGINT = 9,
wolfSSL 7:481bce714567 292 DYNAMIC_TYPE_RSA = 10,
wolfSSL 7:481bce714567 293 DYNAMIC_TYPE_METHOD = 11,
wolfSSL 7:481bce714567 294 DYNAMIC_TYPE_OUT_BUFFER = 12,
wolfSSL 7:481bce714567 295 DYNAMIC_TYPE_IN_BUFFER = 13,
wolfSSL 7:481bce714567 296 DYNAMIC_TYPE_INFO = 14,
wolfSSL 7:481bce714567 297 DYNAMIC_TYPE_DH = 15,
wolfSSL 7:481bce714567 298 DYNAMIC_TYPE_DOMAIN = 16,
wolfSSL 7:481bce714567 299 DYNAMIC_TYPE_SSL = 17,
wolfSSL 7:481bce714567 300 DYNAMIC_TYPE_CTX = 18,
wolfSSL 7:481bce714567 301 DYNAMIC_TYPE_WRITEV = 19,
wolfSSL 7:481bce714567 302 DYNAMIC_TYPE_OPENSSL = 20,
wolfSSL 7:481bce714567 303 DYNAMIC_TYPE_DSA = 21,
wolfSSL 7:481bce714567 304 DYNAMIC_TYPE_CRL = 22,
wolfSSL 7:481bce714567 305 DYNAMIC_TYPE_REVOKED = 23,
wolfSSL 7:481bce714567 306 DYNAMIC_TYPE_CRL_ENTRY = 24,
wolfSSL 7:481bce714567 307 DYNAMIC_TYPE_CERT_MANAGER = 25,
wolfSSL 7:481bce714567 308 DYNAMIC_TYPE_CRL_MONITOR = 26,
wolfSSL 7:481bce714567 309 DYNAMIC_TYPE_OCSP_STATUS = 27,
wolfSSL 7:481bce714567 310 DYNAMIC_TYPE_OCSP_ENTRY = 28,
wolfSSL 7:481bce714567 311 DYNAMIC_TYPE_ALTNAME = 29,
wolfSSL 7:481bce714567 312 DYNAMIC_TYPE_SUITES = 30,
wolfSSL 7:481bce714567 313 DYNAMIC_TYPE_CIPHER = 31,
wolfSSL 7:481bce714567 314 DYNAMIC_TYPE_RNG = 32,
wolfSSL 7:481bce714567 315 DYNAMIC_TYPE_ARRAYS = 33,
wolfSSL 7:481bce714567 316 DYNAMIC_TYPE_DTLS_POOL = 34,
wolfSSL 7:481bce714567 317 DYNAMIC_TYPE_SOCKADDR = 35,
wolfSSL 7:481bce714567 318 DYNAMIC_TYPE_LIBZ = 36,
wolfSSL 7:481bce714567 319 DYNAMIC_TYPE_ECC = 37,
wolfSSL 7:481bce714567 320 DYNAMIC_TYPE_TMP_BUFFER = 38,
wolfSSL 7:481bce714567 321 DYNAMIC_TYPE_DTLS_MSG = 39,
wolfSSL 7:481bce714567 322 DYNAMIC_TYPE_ASYNC_TMP = 40,
wolfSSL 7:481bce714567 323 DYNAMIC_TYPE_ASYNC_RSA = 41,
wolfSSL 7:481bce714567 324 DYNAMIC_TYPE_X509 = 42,
wolfSSL 7:481bce714567 325 DYNAMIC_TYPE_TLSX = 43,
wolfSSL 7:481bce714567 326 DYNAMIC_TYPE_OCSP = 44,
wolfSSL 7:481bce714567 327 DYNAMIC_TYPE_SIGNATURE = 45,
wolfSSL 7:481bce714567 328 DYNAMIC_TYPE_HASHES = 46,
wolfSSL 7:481bce714567 329 DYNAMIC_TYPE_SRP = 47,
wolfSSL 7:481bce714567 330 DYNAMIC_TYPE_COOKIE_PWD = 48,
wolfSSL 7:481bce714567 331 DYNAMIC_TYPE_USER_CRYPTO = 49,
wolfSSL 7:481bce714567 332 DYNAMIC_TYPE_OCSP_REQUEST = 50,
wolfSSL 7:481bce714567 333 DYNAMIC_TYPE_X509_EXT = 51,
wolfSSL 7:481bce714567 334 DYNAMIC_TYPE_X509_STORE = 52,
wolfSSL 7:481bce714567 335 DYNAMIC_TYPE_X509_CTX = 53,
wolfSSL 7:481bce714567 336 DYNAMIC_TYPE_URL = 54,
wolfSSL 7:481bce714567 337 DYNAMIC_TYPE_DTLS_FRAG = 55,
wolfSSL 7:481bce714567 338 DYNAMIC_TYPE_DTLS_BUFFER = 56,
wolfSSL 7:481bce714567 339 DYNAMIC_TYPE_SESSION_TICK = 57,
wolfSSL 7:481bce714567 340 DYNAMIC_TYPE_PKCS = 58,
wolfSSL 7:481bce714567 341 DYNAMIC_TYPE_MUTEX = 59,
wolfSSL 7:481bce714567 342 DYNAMIC_TYPE_PKCS7 = 60,
wolfSSL 7:481bce714567 343 DYNAMIC_TYPE_ASN1 = 61,
wolfSSL 7:481bce714567 344 DYNAMIC_TYPE_LOG = 62
wolfSSL 7:481bce714567 345 };
wolfSSL 7:481bce714567 346
wolfSSL 7:481bce714567 347 /* max error buffer string size */
wolfSSL 7:481bce714567 348 enum {
wolfSSL 7:481bce714567 349 WOLFSSL_MAX_ERROR_SZ = 80
wolfSSL 7:481bce714567 350 };
wolfSSL 7:481bce714567 351
wolfSSL 7:481bce714567 352 /* stack protection */
wolfSSL 7:481bce714567 353 enum {
wolfSSL 7:481bce714567 354 MIN_STACK_BUFFER = 8
wolfSSL 7:481bce714567 355 };
wolfSSL 7:481bce714567 356
wolfSSL 7:481bce714567 357
wolfSSL 7:481bce714567 358
wolfSSL 7:481bce714567 359 /* settings detection for compile vs runtime math incompatibilities */
wolfSSL 7:481bce714567 360 enum {
wolfSSL 7:481bce714567 361 #if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
wolfSSL 7:481bce714567 362 CTC_SETTINGS = 0x0
wolfSSL 7:481bce714567 363 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
wolfSSL 7:481bce714567 364 CTC_SETTINGS = 0x1
wolfSSL 7:481bce714567 365 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
wolfSSL 7:481bce714567 366 CTC_SETTINGS = 0x2
wolfSSL 7:481bce714567 367 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
wolfSSL 7:481bce714567 368 CTC_SETTINGS = 0x4
wolfSSL 7:481bce714567 369 #elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
wolfSSL 7:481bce714567 370 CTC_SETTINGS = 0x8
wolfSSL 7:481bce714567 371 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
wolfSSL 7:481bce714567 372 CTC_SETTINGS = 0x10
wolfSSL 7:481bce714567 373 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
wolfSSL 7:481bce714567 374 CTC_SETTINGS = 0x20
wolfSSL 7:481bce714567 375 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
wolfSSL 7:481bce714567 376 CTC_SETTINGS = 0x40
wolfSSL 7:481bce714567 377 #else
wolfSSL 7:481bce714567 378 #error "bad math long / long long settings"
wolfSSL 7:481bce714567 379 #endif
wolfSSL 7:481bce714567 380 };
wolfSSL 7:481bce714567 381
wolfSSL 7:481bce714567 382
wolfSSL 7:481bce714567 383 WOLFSSL_API word32 CheckRunTimeSettings(void);
wolfSSL 7:481bce714567 384
wolfSSL 7:481bce714567 385 /* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
wolfSSL 7:481bce714567 386 types need to match at compile time and run time, CheckCtcSettings will
wolfSSL 7:481bce714567 387 return 1 if a match otherwise 0 */
wolfSSL 7:481bce714567 388 #define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
wolfSSL 7:481bce714567 389
wolfSSL 7:481bce714567 390 /* invalid device id */
wolfSSL 7:481bce714567 391 #define INVALID_DEVID -2
wolfSSL 7:481bce714567 392
wolfSSL 7:481bce714567 393
wolfSSL 7:481bce714567 394 /* AESNI requires alignment and ARMASM gains some performance from it */
wolfSSL 7:481bce714567 395 #if defined(WOLFSSL_AESNI) || defined(WOLFSSL_ARMASM)
wolfSSL 7:481bce714567 396 #if !defined(ALIGN16)
wolfSSL 7:481bce714567 397 #if defined(__GNUC__)
wolfSSL 7:481bce714567 398 #define ALIGN16 __attribute__ ( (aligned (16)))
wolfSSL 7:481bce714567 399 #elif defined(_MSC_VER)
wolfSSL 7:481bce714567 400 /* disable align warning, we want alignment ! */
wolfSSL 7:481bce714567 401 #pragma warning(disable: 4324)
wolfSSL 7:481bce714567 402 #define ALIGN16 __declspec (align (16))
wolfSSL 7:481bce714567 403 #else
wolfSSL 7:481bce714567 404 #define ALIGN16
wolfSSL 7:481bce714567 405 #endif
wolfSSL 7:481bce714567 406 #endif /* !ALIGN16 */
wolfSSL 7:481bce714567 407
wolfSSL 7:481bce714567 408 #if !defined(ALIGN32)
wolfSSL 7:481bce714567 409 #if defined(__GNUC__)
wolfSSL 7:481bce714567 410 #define ALIGN32 __attribute__ ( (aligned (32)))
wolfSSL 7:481bce714567 411 #elif defined(_MSC_VER)
wolfSSL 7:481bce714567 412 /* disable align warning, we want alignment ! */
wolfSSL 7:481bce714567 413 #pragma warning(disable: 4324)
wolfSSL 7:481bce714567 414 #define ALIGN32 __declspec (align (32))
wolfSSL 7:481bce714567 415 #else
wolfSSL 7:481bce714567 416 #define ALIGN32
wolfSSL 7:481bce714567 417 #endif
wolfSSL 7:481bce714567 418 #endif /* !ALIGN32 */
wolfSSL 7:481bce714567 419 #else
wolfSSL 7:481bce714567 420 #ifndef ALIGN16
wolfSSL 7:481bce714567 421 #define ALIGN16
wolfSSL 7:481bce714567 422 #endif
wolfSSL 7:481bce714567 423 #ifndef ALIGN32
wolfSSL 7:481bce714567 424 #define ALIGN32
wolfSSL 7:481bce714567 425 #endif
wolfSSL 7:481bce714567 426 #endif /* WOLFSSL_AESNI || WOLFSSL_ARMASM */
wolfSSL 7:481bce714567 427
wolfSSL 7:481bce714567 428
wolfSSL 7:481bce714567 429 #ifndef TRUE
wolfSSL 7:481bce714567 430 #define TRUE 1
wolfSSL 7:481bce714567 431 #endif
wolfSSL 7:481bce714567 432 #ifndef FALSE
wolfSSL 7:481bce714567 433 #define FALSE 0
wolfSSL 7:481bce714567 434 #endif
wolfSSL 7:481bce714567 435
wolfSSL 7:481bce714567 436
wolfSSL 7:481bce714567 437 #ifdef WOLFSSL_RIOT_OS
wolfSSL 7:481bce714567 438 #define EXIT_TEST(ret) exit(ret)
wolfSSL 7:481bce714567 439 #else
wolfSSL 7:481bce714567 440 #define EXIT_TEST(ret) return ret
wolfSSL 7:481bce714567 441 #endif
wolfSSL 7:481bce714567 442
wolfSSL 7:481bce714567 443 #ifdef __cplusplus
wolfSSL 7:481bce714567 444 } /* extern "C" */
wolfSSL 7:481bce714567 445 #endif
wolfSSL 7:481bce714567 446
wolfSSL 7:481bce714567 447 #endif /* WOLF_CRYPT_TYPES_H */
wolfSSL 7:481bce714567 448