CyaSSL changed for NucleoF401RE board: implemented random and time functions for build. (Has trouble with wildcard domains like *.google.com, *.yahoo.com)

Fork of CyaSSL by wolf SSL

Committer:
Vanger
Date:
Wed Jan 14 22:07:14 2015 +0000
Revision:
4:e505054279ed
Parent:
0:1239e9b70ca2
Implemented some platform specific functions in the Cyassl library code: time functions, seed random functions, and also changed the settings.h file to define settings specific to the platform being used

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 0:1239e9b70ca2 1 /* types.h
wolfSSL 0:1239e9b70ca2 2 *
wolfSSL 0:1239e9b70ca2 3 * Copyright (C) 2006-2014 wolfSSL Inc.
wolfSSL 0:1239e9b70ca2 4 *
wolfSSL 0:1239e9b70ca2 5 * This file is part of CyaSSL.
wolfSSL 0:1239e9b70ca2 6 *
wolfSSL 0:1239e9b70ca2 7 * CyaSSL is free software; you can redistribute it and/or modify
wolfSSL 0:1239e9b70ca2 8 * it under the terms of the GNU General Public License as published by
wolfSSL 0:1239e9b70ca2 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 0:1239e9b70ca2 10 * (at your option) any later version.
wolfSSL 0:1239e9b70ca2 11 *
wolfSSL 0:1239e9b70ca2 12 * CyaSSL is distributed in the hope that it will be useful,
wolfSSL 0:1239e9b70ca2 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 0:1239e9b70ca2 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 0:1239e9b70ca2 15 * GNU General Public License for more details.
wolfSSL 0:1239e9b70ca2 16 *
wolfSSL 0:1239e9b70ca2 17 * You should have received a copy of the GNU General Public License
wolfSSL 0:1239e9b70ca2 18 * along with this program; if not, write to the Free Software
wolfSSL 0:1239e9b70ca2 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
wolfSSL 0:1239e9b70ca2 20 */
wolfSSL 0:1239e9b70ca2 21
wolfSSL 0:1239e9b70ca2 22
wolfSSL 0:1239e9b70ca2 23 #ifndef CTAO_CRYPT_TYPES_H
wolfSSL 0:1239e9b70ca2 24 #define CTAO_CRYPT_TYPES_H
wolfSSL 0:1239e9b70ca2 25
wolfSSL 0:1239e9b70ca2 26 #include <cyassl/ctaocrypt/settings.h>
wolfSSL 0:1239e9b70ca2 27 #include <cyassl/ctaocrypt/port.h>
wolfSSL 0:1239e9b70ca2 28
wolfSSL 0:1239e9b70ca2 29 #ifdef __cplusplus
wolfSSL 0:1239e9b70ca2 30 extern "C" {
wolfSSL 0:1239e9b70ca2 31 #endif
wolfSSL 0:1239e9b70ca2 32
wolfSSL 0:1239e9b70ca2 33
wolfSSL 0:1239e9b70ca2 34 #if defined(WORDS_BIGENDIAN)
wolfSSL 0:1239e9b70ca2 35 #define BIG_ENDIAN_ORDER
wolfSSL 0:1239e9b70ca2 36 #endif
wolfSSL 0:1239e9b70ca2 37
wolfSSL 0:1239e9b70ca2 38 #ifndef BIG_ENDIAN_ORDER
wolfSSL 0:1239e9b70ca2 39 #define LITTLE_ENDIAN_ORDER
wolfSSL 0:1239e9b70ca2 40 #endif
wolfSSL 0:1239e9b70ca2 41
wolfSSL 0:1239e9b70ca2 42 #ifndef CYASSL_TYPES
wolfSSL 0:1239e9b70ca2 43 #ifndef byte
wolfSSL 0:1239e9b70ca2 44 typedef unsigned char byte;
wolfSSL 0:1239e9b70ca2 45 #endif
wolfSSL 0:1239e9b70ca2 46 typedef unsigned short word16;
wolfSSL 0:1239e9b70ca2 47 typedef unsigned int word32;
wolfSSL 0:1239e9b70ca2 48 #endif
wolfSSL 0:1239e9b70ca2 49
wolfSSL 0:1239e9b70ca2 50
wolfSSL 0:1239e9b70ca2 51 /* try to set SIZEOF_LONG or LONG_LONG if user didn't */
wolfSSL 0:1239e9b70ca2 52 #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)
wolfSSL 0:1239e9b70ca2 53 #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
wolfSSL 0:1239e9b70ca2 54 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \
wolfSSL 0:1239e9b70ca2 55 || defined(__mips64) || defined(__x86_64__))
wolfSSL 0:1239e9b70ca2 56 /* long should be 64bit */
wolfSSL 0:1239e9b70ca2 57 #define SIZEOF_LONG 8
wolfSSL 0:1239e9b70ca2 58 #elif defined(__i386__) || defined(__CORTEX_M3__)
wolfSSL 0:1239e9b70ca2 59 /* long long should be 64bit */
wolfSSL 0:1239e9b70ca2 60 #define SIZEOF_LONG_LONG 8
wolfSSL 0:1239e9b70ca2 61 #endif
wolfSSL 0:1239e9b70ca2 62 #endif
wolfSSL 0:1239e9b70ca2 63 #endif
wolfSSL 0:1239e9b70ca2 64
wolfSSL 0:1239e9b70ca2 65
wolfSSL 0:1239e9b70ca2 66 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
wolfSSL 0:1239e9b70ca2 67 #define WORD64_AVAILABLE
wolfSSL 0:1239e9b70ca2 68 #define W64LIT(x) x##ui64
wolfSSL 0:1239e9b70ca2 69 typedef unsigned __int64 word64;
wolfSSL 0:1239e9b70ca2 70 #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
wolfSSL 0:1239e9b70ca2 71 #define WORD64_AVAILABLE
wolfSSL 0:1239e9b70ca2 72 #define W64LIT(x) x##LL
wolfSSL 0:1239e9b70ca2 73 typedef unsigned long word64;
wolfSSL 0:1239e9b70ca2 74 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
wolfSSL 0:1239e9b70ca2 75 #define WORD64_AVAILABLE
wolfSSL 0:1239e9b70ca2 76 #define W64LIT(x) x##LL
wolfSSL 0:1239e9b70ca2 77 typedef unsigned long long word64;
wolfSSL 0:1239e9b70ca2 78 #elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
wolfSSL 0:1239e9b70ca2 79 #define WORD64_AVAILABLE
wolfSSL 0:1239e9b70ca2 80 #define W64LIT(x) x##LL
wolfSSL 0:1239e9b70ca2 81 typedef unsigned long long word64;
wolfSSL 0:1239e9b70ca2 82 #else
wolfSSL 0:1239e9b70ca2 83 #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as
wolfSSL 0:1239e9b70ca2 84 mp_digit, no 64 bit type so make mp_digit 16 bit */
wolfSSL 0:1239e9b70ca2 85 #endif
wolfSSL 0:1239e9b70ca2 86
wolfSSL 0:1239e9b70ca2 87
wolfSSL 0:1239e9b70ca2 88 /* These platforms have 64-bit CPU registers. */
wolfSSL 0:1239e9b70ca2 89 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
wolfSSL 0:1239e9b70ca2 90 defined(__mips64) || defined(__x86_64__) || defined(_M_X64))
wolfSSL 0:1239e9b70ca2 91 typedef word64 word;
wolfSSL 0:1239e9b70ca2 92 #else
wolfSSL 0:1239e9b70ca2 93 typedef word32 word;
wolfSSL 0:1239e9b70ca2 94 #ifdef WORD64_AVAILABLE
wolfSSL 0:1239e9b70ca2 95 #define CTAOCRYPT_SLOW_WORD64
wolfSSL 0:1239e9b70ca2 96 #endif
wolfSSL 0:1239e9b70ca2 97 #endif
wolfSSL 0:1239e9b70ca2 98
wolfSSL 0:1239e9b70ca2 99
wolfSSL 0:1239e9b70ca2 100 enum {
wolfSSL 0:1239e9b70ca2 101 CYASSL_WORD_SIZE = sizeof(word),
wolfSSL 0:1239e9b70ca2 102 CYASSL_BIT_SIZE = 8,
wolfSSL 0:1239e9b70ca2 103 CYASSL_WORD_BITS = CYASSL_WORD_SIZE * CYASSL_BIT_SIZE
wolfSSL 0:1239e9b70ca2 104 };
wolfSSL 0:1239e9b70ca2 105
wolfSSL 0:1239e9b70ca2 106 #define CYASSL_MAX_16BIT 0xffffU
wolfSSL 0:1239e9b70ca2 107
wolfSSL 0:1239e9b70ca2 108 /* use inlining if compiler allows */
wolfSSL 0:1239e9b70ca2 109 #ifndef INLINE
wolfSSL 0:1239e9b70ca2 110 #ifndef NO_INLINE
wolfSSL 0:1239e9b70ca2 111 #ifdef _MSC_VER
wolfSSL 0:1239e9b70ca2 112 #define INLINE __inline
wolfSSL 0:1239e9b70ca2 113 #elif defined(__GNUC__)
wolfSSL 0:1239e9b70ca2 114 #define INLINE inline
wolfSSL 0:1239e9b70ca2 115 #elif defined(__IAR_SYSTEMS_ICC__)
wolfSSL 0:1239e9b70ca2 116 #define INLINE inline
wolfSSL 0:1239e9b70ca2 117 #elif defined(THREADX)
wolfSSL 0:1239e9b70ca2 118 #define INLINE _Inline
wolfSSL 0:1239e9b70ca2 119 #else
wolfSSL 0:1239e9b70ca2 120 #define INLINE
wolfSSL 0:1239e9b70ca2 121 #endif
wolfSSL 0:1239e9b70ca2 122 #else
wolfSSL 0:1239e9b70ca2 123 #define INLINE
wolfSSL 0:1239e9b70ca2 124 #endif
wolfSSL 0:1239e9b70ca2 125 #endif
wolfSSL 0:1239e9b70ca2 126
wolfSSL 0:1239e9b70ca2 127
wolfSSL 0:1239e9b70ca2 128 /* set up rotate style */
wolfSSL 0:1239e9b70ca2 129 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
wolfSSL 0:1239e9b70ca2 130 #define INTEL_INTRINSICS
wolfSSL 0:1239e9b70ca2 131 #define FAST_ROTATE
wolfSSL 0:1239e9b70ca2 132 #elif defined(__MWERKS__) && TARGET_CPU_PPC
wolfSSL 0:1239e9b70ca2 133 #define PPC_INTRINSICS
wolfSSL 0:1239e9b70ca2 134 #define FAST_ROTATE
wolfSSL 0:1239e9b70ca2 135 #elif defined(__GNUC__) && defined(__i386__)
wolfSSL 0:1239e9b70ca2 136 /* GCC does peephole optimizations which should result in using rotate
wolfSSL 0:1239e9b70ca2 137 instructions */
wolfSSL 0:1239e9b70ca2 138 #define FAST_ROTATE
wolfSSL 0:1239e9b70ca2 139 #endif
wolfSSL 0:1239e9b70ca2 140
wolfSSL 0:1239e9b70ca2 141
wolfSSL 0:1239e9b70ca2 142 /* set up thread local storage if available */
wolfSSL 0:1239e9b70ca2 143 #ifdef HAVE_THREAD_LS
wolfSSL 0:1239e9b70ca2 144 #if defined(_MSC_VER)
wolfSSL 0:1239e9b70ca2 145 #define THREAD_LS_T __declspec(thread)
wolfSSL 0:1239e9b70ca2 146 #else
wolfSSL 0:1239e9b70ca2 147 #define THREAD_LS_T __thread
wolfSSL 0:1239e9b70ca2 148 #endif
wolfSSL 0:1239e9b70ca2 149 #else
wolfSSL 0:1239e9b70ca2 150 #define THREAD_LS_T
wolfSSL 0:1239e9b70ca2 151 #endif
wolfSSL 0:1239e9b70ca2 152
wolfSSL 0:1239e9b70ca2 153
wolfSSL 0:1239e9b70ca2 154 /* Micrium will use Visual Studio for compilation but not the Win32 API */
wolfSSL 0:1239e9b70ca2 155 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
wolfSSL 0:1239e9b70ca2 156 && !defined(EBSNET)
wolfSSL 0:1239e9b70ca2 157 #define USE_WINDOWS_API
wolfSSL 0:1239e9b70ca2 158 #endif
wolfSSL 0:1239e9b70ca2 159
wolfSSL 0:1239e9b70ca2 160
wolfSSL 0:1239e9b70ca2 161 /* idea to add global alloc override by Moisés Guimarães */
wolfSSL 0:1239e9b70ca2 162 /* default to libc stuff */
wolfSSL 0:1239e9b70ca2 163 /* XREALLOC is used once in normal math lib, not in fast math lib */
wolfSSL 0:1239e9b70ca2 164 /* XFREE on some embeded systems doesn't like free(0) so test */
wolfSSL 0:1239e9b70ca2 165 #if defined(XMALLOC_USER)
wolfSSL 0:1239e9b70ca2 166 /* prototypes for user heap override functions */
wolfSSL 0:1239e9b70ca2 167 #include <stddef.h> /* for size_t */
wolfSSL 0:1239e9b70ca2 168 extern void *XMALLOC(size_t n, void* heap, int type);
wolfSSL 0:1239e9b70ca2 169 extern void *XREALLOC(void *p, size_t n, void* heap, int type);
wolfSSL 0:1239e9b70ca2 170 extern void XFREE(void *p, void* heap, int type);
wolfSSL 0:1239e9b70ca2 171 #elif defined(NO_CYASSL_MEMORY)
wolfSSL 0:1239e9b70ca2 172 /* just use plain C stdlib stuff if desired */
wolfSSL 0:1239e9b70ca2 173 #include <stdlib.h>
wolfSSL 0:1239e9b70ca2 174 #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
wolfSSL 0:1239e9b70ca2 175 #define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
wolfSSL 0:1239e9b70ca2 176 #define XREALLOC(p, n, h, t) realloc((p), (n))
wolfSSL 0:1239e9b70ca2 177 #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
wolfSSL 0:1239e9b70ca2 178 && !defined(CYASSL_SAFERTOS) && !defined(FREESCALE_MQX) \
wolfSSL 0:1239e9b70ca2 179 && !defined(CYASSL_LEANPSK)
wolfSSL 0:1239e9b70ca2 180 /* default C runtime, can install different routines at runtime via cbs */
wolfSSL 0:1239e9b70ca2 181 #include <cyassl/ctaocrypt/memory.h>
wolfSSL 0:1239e9b70ca2 182 #define XMALLOC(s, h, t) ((void)h, (void)t, CyaSSL_Malloc((s)))
wolfSSL 0:1239e9b70ca2 183 #define XFREE(p, h, t) {void* xp = (p); if((xp)) CyaSSL_Free((xp));}
wolfSSL 0:1239e9b70ca2 184 #define XREALLOC(p, n, h, t) CyaSSL_Realloc((p), (n))
wolfSSL 0:1239e9b70ca2 185 #endif
wolfSSL 0:1239e9b70ca2 186
wolfSSL 0:1239e9b70ca2 187 #ifndef STRING_USER
wolfSSL 0:1239e9b70ca2 188 #include <string.h>
wolfSSL 0:1239e9b70ca2 189 char* mystrnstr(const char* s1, const char* s2, unsigned int n);
wolfSSL 0:1239e9b70ca2 190
wolfSSL 0:1239e9b70ca2 191 #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
wolfSSL 0:1239e9b70ca2 192 #define XMEMSET(b,c,l) memset((b),(c),(l))
wolfSSL 0:1239e9b70ca2 193 #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 194 #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
wolfSSL 0:1239e9b70ca2 195
wolfSSL 0:1239e9b70ca2 196 #define XSTRLEN(s1) strlen((s1))
wolfSSL 0:1239e9b70ca2 197 #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 198 /* strstr, strncmp, and strncat only used by CyaSSL proper, not required for
wolfSSL 0:1239e9b70ca2 199 CTaoCrypt only */
wolfSSL 0:1239e9b70ca2 200 #define XSTRSTR(s1,s2) strstr((s1),(s2))
wolfSSL 0:1239e9b70ca2 201 #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 202 #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 203 #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 204 #ifndef USE_WINDOWS_API
wolfSSL 0:1239e9b70ca2 205 #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 206 #define XSNPRINTF snprintf
wolfSSL 0:1239e9b70ca2 207 #else
wolfSSL 0:1239e9b70ca2 208 #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
wolfSSL 0:1239e9b70ca2 209 #define XSNPRINTF _snprintf
wolfSSL 0:1239e9b70ca2 210 #endif
wolfSSL 0:1239e9b70ca2 211 #endif
wolfSSL 0:1239e9b70ca2 212
wolfSSL 0:1239e9b70ca2 213 #ifndef CTYPE_USER
wolfSSL 0:1239e9b70ca2 214 #include <ctype.h>
wolfSSL 0:1239e9b70ca2 215 #if defined(HAVE_ECC) || defined(HAVE_OCSP)
wolfSSL 0:1239e9b70ca2 216 #define XTOUPPER(c) toupper((c))
wolfSSL 0:1239e9b70ca2 217 #define XISALPHA(c) isalpha((c))
wolfSSL 0:1239e9b70ca2 218 #endif
wolfSSL 0:1239e9b70ca2 219 /* needed by CyaSSL_check_domain_name() */
wolfSSL 0:1239e9b70ca2 220 #ifdef __CYGWIN__
wolfSSL 0:1239e9b70ca2 221 /* Cygwin uses a macro version of tolower() by default, use the
wolfSSL 0:1239e9b70ca2 222 * function version. */
wolfSSL 0:1239e9b70ca2 223 #undef tolower
wolfSSL 0:1239e9b70ca2 224 #endif
wolfSSL 0:1239e9b70ca2 225 #define XTOLOWER(c) tolower((c))
wolfSSL 0:1239e9b70ca2 226 #endif
wolfSSL 0:1239e9b70ca2 227
wolfSSL 0:1239e9b70ca2 228
wolfSSL 0:1239e9b70ca2 229 /* memory allocation types for user hints */
wolfSSL 0:1239e9b70ca2 230 enum {
wolfSSL 0:1239e9b70ca2 231 DYNAMIC_TYPE_CA = 1,
wolfSSL 0:1239e9b70ca2 232 DYNAMIC_TYPE_CERT = 2,
wolfSSL 0:1239e9b70ca2 233 DYNAMIC_TYPE_KEY = 3,
wolfSSL 0:1239e9b70ca2 234 DYNAMIC_TYPE_FILE = 4,
wolfSSL 0:1239e9b70ca2 235 DYNAMIC_TYPE_SUBJECT_CN = 5,
wolfSSL 0:1239e9b70ca2 236 DYNAMIC_TYPE_PUBLIC_KEY = 6,
wolfSSL 0:1239e9b70ca2 237 DYNAMIC_TYPE_SIGNER = 7,
wolfSSL 0:1239e9b70ca2 238 DYNAMIC_TYPE_NONE = 8,
wolfSSL 0:1239e9b70ca2 239 DYNAMIC_TYPE_BIGINT = 9,
wolfSSL 0:1239e9b70ca2 240 DYNAMIC_TYPE_RSA = 10,
wolfSSL 0:1239e9b70ca2 241 DYNAMIC_TYPE_METHOD = 11,
wolfSSL 0:1239e9b70ca2 242 DYNAMIC_TYPE_OUT_BUFFER = 12,
wolfSSL 0:1239e9b70ca2 243 DYNAMIC_TYPE_IN_BUFFER = 13,
wolfSSL 0:1239e9b70ca2 244 DYNAMIC_TYPE_INFO = 14,
wolfSSL 0:1239e9b70ca2 245 DYNAMIC_TYPE_DH = 15,
wolfSSL 0:1239e9b70ca2 246 DYNAMIC_TYPE_DOMAIN = 16,
wolfSSL 0:1239e9b70ca2 247 DYNAMIC_TYPE_SSL = 17,
wolfSSL 0:1239e9b70ca2 248 DYNAMIC_TYPE_CTX = 18,
wolfSSL 0:1239e9b70ca2 249 DYNAMIC_TYPE_WRITEV = 19,
wolfSSL 0:1239e9b70ca2 250 DYNAMIC_TYPE_OPENSSL = 20,
wolfSSL 0:1239e9b70ca2 251 DYNAMIC_TYPE_DSA = 21,
wolfSSL 0:1239e9b70ca2 252 DYNAMIC_TYPE_CRL = 22,
wolfSSL 0:1239e9b70ca2 253 DYNAMIC_TYPE_REVOKED = 23,
wolfSSL 0:1239e9b70ca2 254 DYNAMIC_TYPE_CRL_ENTRY = 24,
wolfSSL 0:1239e9b70ca2 255 DYNAMIC_TYPE_CERT_MANAGER = 25,
wolfSSL 0:1239e9b70ca2 256 DYNAMIC_TYPE_CRL_MONITOR = 26,
wolfSSL 0:1239e9b70ca2 257 DYNAMIC_TYPE_OCSP_STATUS = 27,
wolfSSL 0:1239e9b70ca2 258 DYNAMIC_TYPE_OCSP_ENTRY = 28,
wolfSSL 0:1239e9b70ca2 259 DYNAMIC_TYPE_ALTNAME = 29,
wolfSSL 0:1239e9b70ca2 260 DYNAMIC_TYPE_SUITES = 30,
wolfSSL 0:1239e9b70ca2 261 DYNAMIC_TYPE_CIPHER = 31,
wolfSSL 0:1239e9b70ca2 262 DYNAMIC_TYPE_RNG = 32,
wolfSSL 0:1239e9b70ca2 263 DYNAMIC_TYPE_ARRAYS = 33,
wolfSSL 0:1239e9b70ca2 264 DYNAMIC_TYPE_DTLS_POOL = 34,
wolfSSL 0:1239e9b70ca2 265 DYNAMIC_TYPE_SOCKADDR = 35,
wolfSSL 0:1239e9b70ca2 266 DYNAMIC_TYPE_LIBZ = 36,
wolfSSL 0:1239e9b70ca2 267 DYNAMIC_TYPE_ECC = 37,
wolfSSL 0:1239e9b70ca2 268 DYNAMIC_TYPE_TMP_BUFFER = 38,
wolfSSL 0:1239e9b70ca2 269 DYNAMIC_TYPE_DTLS_MSG = 39,
wolfSSL 0:1239e9b70ca2 270 DYNAMIC_TYPE_CAVIUM_TMP = 40,
wolfSSL 0:1239e9b70ca2 271 DYNAMIC_TYPE_CAVIUM_RSA = 41,
wolfSSL 0:1239e9b70ca2 272 DYNAMIC_TYPE_X509 = 42,
wolfSSL 0:1239e9b70ca2 273 DYNAMIC_TYPE_TLSX = 43,
wolfSSL 0:1239e9b70ca2 274 DYNAMIC_TYPE_OCSP = 44,
wolfSSL 0:1239e9b70ca2 275 DYNAMIC_TYPE_SIGNATURE = 45
wolfSSL 0:1239e9b70ca2 276 };
wolfSSL 0:1239e9b70ca2 277
wolfSSL 0:1239e9b70ca2 278 /* max error buffer string size */
wolfSSL 0:1239e9b70ca2 279 enum {
wolfSSL 0:1239e9b70ca2 280 CYASSL_MAX_ERROR_SZ = 80
wolfSSL 0:1239e9b70ca2 281 };
wolfSSL 0:1239e9b70ca2 282
wolfSSL 0:1239e9b70ca2 283 /* stack protection */
wolfSSL 0:1239e9b70ca2 284 enum {
wolfSSL 0:1239e9b70ca2 285 MIN_STACK_BUFFER = 8
wolfSSL 0:1239e9b70ca2 286 };
wolfSSL 0:1239e9b70ca2 287
wolfSSL 0:1239e9b70ca2 288
wolfSSL 0:1239e9b70ca2 289
wolfSSL 0:1239e9b70ca2 290 /* settings detection for compile vs runtime math incombatibilities */
wolfSSL 0:1239e9b70ca2 291 enum {
wolfSSL 0:1239e9b70ca2 292 #if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
wolfSSL 0:1239e9b70ca2 293 CTC_SETTINGS = 0x0
wolfSSL 0:1239e9b70ca2 294 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
wolfSSL 0:1239e9b70ca2 295 CTC_SETTINGS = 0x1
wolfSSL 0:1239e9b70ca2 296 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
wolfSSL 0:1239e9b70ca2 297 CTC_SETTINGS = 0x2
wolfSSL 0:1239e9b70ca2 298 #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
wolfSSL 0:1239e9b70ca2 299 CTC_SETTINGS = 0x4
wolfSSL 0:1239e9b70ca2 300 #elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
wolfSSL 0:1239e9b70ca2 301 CTC_SETTINGS = 0x8
wolfSSL 0:1239e9b70ca2 302 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
wolfSSL 0:1239e9b70ca2 303 CTC_SETTINGS = 0x10
wolfSSL 0:1239e9b70ca2 304 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
wolfSSL 0:1239e9b70ca2 305 CTC_SETTINGS = 0x20
wolfSSL 0:1239e9b70ca2 306 #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
wolfSSL 0:1239e9b70ca2 307 CTC_SETTINGS = 0x40
wolfSSL 0:1239e9b70ca2 308 #else
wolfSSL 0:1239e9b70ca2 309 #error "bad math long / long long settings"
wolfSSL 0:1239e9b70ca2 310 #endif
wolfSSL 0:1239e9b70ca2 311 };
wolfSSL 0:1239e9b70ca2 312
wolfSSL 0:1239e9b70ca2 313
wolfSSL 0:1239e9b70ca2 314 CYASSL_API word32 CheckRunTimeSettings(void);
wolfSSL 0:1239e9b70ca2 315
wolfSSL 0:1239e9b70ca2 316 /* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
wolfSSL 0:1239e9b70ca2 317 types need to match at compile time and run time, CheckCtcSettings will
wolfSSL 0:1239e9b70ca2 318 return 1 if a match otherwise 0 */
wolfSSL 0:1239e9b70ca2 319 #define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
wolfSSL 0:1239e9b70ca2 320
wolfSSL 0:1239e9b70ca2 321
wolfSSL 0:1239e9b70ca2 322 #ifdef __cplusplus
wolfSSL 0:1239e9b70ca2 323 } /* extern "C" */
wolfSSL 0:1239e9b70ca2 324 #endif
wolfSSL 0:1239e9b70ca2 325
wolfSSL 0:1239e9b70ca2 326
wolfSSL 0:1239e9b70ca2 327 #endif /* CTAO_CRYPT_TYPES_H */
wolfSSL 0:1239e9b70ca2 328
wolfSSL 0:1239e9b70ca2 329