[352] | 1 | /* settings.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 | /* Place OS specific preprocessor flags, defines, includes here, will be
|
---|
| 24 | included into every file because types.h includes it */
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #ifndef WOLF_CRYPT_SETTINGS_H
|
---|
| 28 | #define WOLF_CRYPT_SETTINGS_H
|
---|
| 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | /* Uncomment next line if using IPHONE */
|
---|
| 35 | /* #define IPHONE */
|
---|
| 36 |
|
---|
| 37 | /* Uncomment next line if using ThreadX */
|
---|
| 38 | /* #define THREADX */
|
---|
| 39 |
|
---|
| 40 | /* Uncomment next line if using Micrium uC/OS-III */
|
---|
| 41 | /* #define MICRIUM */
|
---|
| 42 |
|
---|
| 43 | /* Uncomment next line if using Mbed */
|
---|
| 44 | /* #define MBED */
|
---|
| 45 |
|
---|
| 46 | /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
|
---|
| 47 | /* #define MICROCHIP_PIC32 */
|
---|
| 48 |
|
---|
| 49 | /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
|
---|
| 50 | /* #define MICROCHIP_TCPIP_V5 */
|
---|
| 51 |
|
---|
| 52 | /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
|
---|
| 53 | /* #define MICROCHIP_TCPIP */
|
---|
| 54 |
|
---|
| 55 | /* Uncomment next line if using PIC32MZ Crypto Engine */
|
---|
| 56 | /* #define WOLFSSL_MICROCHIP_PIC32MZ */
|
---|
| 57 |
|
---|
| 58 | /* Uncomment next line if using FreeRTOS */
|
---|
| 59 | /* #define FREERTOS */
|
---|
| 60 |
|
---|
| 61 | /* Uncomment next line if using FreeRTOS+ TCP */
|
---|
| 62 | /* #define FREERTOS_TCP */
|
---|
| 63 |
|
---|
| 64 | /* Uncomment next line if using FreeRTOS Windows Simulator */
|
---|
| 65 | /* #define FREERTOS_WINSIM */
|
---|
| 66 |
|
---|
| 67 | /* Uncomment next line if using RTIP */
|
---|
| 68 | /* #define EBSNET */
|
---|
| 69 |
|
---|
| 70 | /* Uncomment next line if using lwip */
|
---|
| 71 | /* #define WOLFSSL_LWIP */
|
---|
| 72 |
|
---|
| 73 | /* Uncomment next line if building wolfSSL for a game console */
|
---|
| 74 | /* #define WOLFSSL_GAME_BUILD */
|
---|
| 75 |
|
---|
| 76 | /* Uncomment next line if building wolfSSL for LSR */
|
---|
| 77 | /* #define WOLFSSL_LSR */
|
---|
| 78 |
|
---|
| 79 | /* Uncomment next line if building for Freescale Classic MQX/RTCS/MFS */
|
---|
| 80 | /* #define FREESCALE_MQX */
|
---|
| 81 |
|
---|
| 82 | /* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
|
---|
| 83 | /* #define FREESCALE_KSDK_MQX */
|
---|
| 84 |
|
---|
| 85 | /* Uncomment next line if building for Freescale KSDK Bare Metal */
|
---|
| 86 | /* #define FREESCALE_KSDK_BM */
|
---|
| 87 |
|
---|
| 88 | /* Uncomment next line if building for Freescale KSDK FreeRTOS (old name FREESCALE_FREE_RTOS) */
|
---|
| 89 | /* #define FREESCALE_KSDK_FREERTOS */
|
---|
| 90 |
|
---|
| 91 | /* Uncomment next line if using STM32F2 */
|
---|
| 92 | /* #define WOLFSSL_STM32F2 */
|
---|
| 93 |
|
---|
| 94 | /* Uncomment next line if using STM32F4 */
|
---|
| 95 | /* #define WOLFSSL_STM32F4 */
|
---|
| 96 |
|
---|
| 97 | /* Uncomment next line if using STM32F7 */
|
---|
| 98 | /* #define WOLFSSL_STM32F7 */
|
---|
| 99 |
|
---|
| 100 | /* Uncomment next line if using QL SEP settings */
|
---|
| 101 | /* #define WOLFSSL_QL */
|
---|
| 102 |
|
---|
| 103 | /* Uncomment next line if building for EROAD */
|
---|
| 104 | /* #define WOLFSSL_EROAD */
|
---|
| 105 |
|
---|
| 106 | /* Uncomment next line if building for IAR EWARM */
|
---|
| 107 | /* #define WOLFSSL_IAR_ARM */
|
---|
| 108 |
|
---|
| 109 | /* Uncomment next line if building for Rowley CrossWorks ARM */
|
---|
| 110 | /* #define WOLFSSL_ROWLEY_ARM */
|
---|
| 111 |
|
---|
| 112 | /* Uncomment next line if using TI-RTOS settings */
|
---|
| 113 | /* #define WOLFSSL_TIRTOS */
|
---|
| 114 |
|
---|
| 115 | /* Uncomment next line if building with PicoTCP */
|
---|
| 116 | /* #define WOLFSSL_PICOTCP */
|
---|
| 117 |
|
---|
| 118 | /* Uncomment next line if building for PicoTCP demo bundle */
|
---|
| 119 | /* #define WOLFSSL_PICOTCP_DEMO */
|
---|
| 120 |
|
---|
| 121 | /* Uncomment next line if building for uITRON4 */
|
---|
| 122 | /* #define WOLFSSL_uITRON4 */
|
---|
| 123 |
|
---|
| 124 | /* Uncomment next line if building for uT-Kernel */
|
---|
| 125 | /* #define WOLFSSL_uTKERNEL2 */
|
---|
| 126 |
|
---|
| 127 | /* Uncomment next line if using Max Strength build */
|
---|
| 128 | /* #define WOLFSSL_MAX_STRENGTH */
|
---|
| 129 |
|
---|
| 130 | /* Uncomment next line if building for VxWorks */
|
---|
| 131 | /* #define WOLFSSL_VXWORKS */
|
---|
| 132 |
|
---|
| 133 | /* Uncomment next line if building for Nordic nRF5x platofrm */
|
---|
| 134 | /* #define WOLFSSL_NRF5x */
|
---|
| 135 |
|
---|
| 136 | /* Uncomment next line to enable deprecated less secure static DH suites */
|
---|
| 137 | /* #define WOLFSSL_STATIC_DH */
|
---|
| 138 |
|
---|
| 139 | /* Uncomment next line to enable deprecated less secure static RSA suites */
|
---|
| 140 | /* #define WOLFSSL_STATIC_RSA */
|
---|
| 141 |
|
---|
| 142 | /* Uncomment next line if building for ARDUINO */
|
---|
| 143 | /* Uncomment both lines if building for ARDUINO on INTEL_GALILEO */
|
---|
| 144 | /* #define WOLFSSL_ARDUINO */
|
---|
| 145 | /* #define INTEL_GALILEO */
|
---|
| 146 |
|
---|
| 147 | /* Uncomment next line to enable asynchronous crypto WC_PENDING_E */
|
---|
| 148 | /* #define WOLFSSL_ASYNC_CRYPT */
|
---|
| 149 |
|
---|
| 150 | /* Uncomment next line if building for uTasker */
|
---|
| 151 | /* #define WOLFSSL_UTASKER */
|
---|
| 152 |
|
---|
| 153 | /* Uncomment next line if building for embOS */
|
---|
| 154 | /* #define WOLFSSL_EMBOS */
|
---|
| 155 |
|
---|
| 156 | /* Uncomment next line if building for RIOT-OS */
|
---|
| 157 | /* #define WOLFSSL_RIOT_OS */
|
---|
| 158 |
|
---|
| 159 | /* Uncomment next line if building for using XILINX hardened crypto */
|
---|
| 160 | /* #define WOLFSSL_XILINX_CRYPT */
|
---|
| 161 |
|
---|
| 162 | /* Uncomment next line if building for using XILINX */
|
---|
| 163 | /* #define WOLFSSL_XILINX */
|
---|
| 164 |
|
---|
| 165 | #include <wolfssl/wolfcrypt/visibility.h>
|
---|
| 166 |
|
---|
| 167 | #ifdef WOLFSSL_USER_SETTINGS
|
---|
| 168 | #include "user_settings.h"
|
---|
| 169 | #endif
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 | /* make sure old RNG name is used with CTaoCrypt FIPS */
|
---|
| 173 | #ifdef HAVE_FIPS
|
---|
| 174 | #define WC_RNG RNG
|
---|
| 175 | /* blinding adds API not available yet in FIPS mode */
|
---|
| 176 | #undef WC_RSA_BLINDING
|
---|
| 177 | #endif
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | #if defined(_WIN32) && !defined(_M_X64) && \
|
---|
| 181 | defined(HAVE_AESGCM) && defined(WOLFSSL_AESNI)
|
---|
| 182 |
|
---|
| 183 | /* The _M_X64 macro is what's used in the headers for MSC to tell if it
|
---|
| 184 | * has the 64-bit versions of the 128-bit integers available. If one is
|
---|
| 185 | * building on 32-bit Windows with AES-NI, turn off the AES-GCMloop
|
---|
| 186 | * unrolling. */
|
---|
| 187 |
|
---|
| 188 | #define AES_GCM_AESNI_NO_UNROLL
|
---|
| 189 | #endif
|
---|
| 190 |
|
---|
| 191 | #ifdef IPHONE
|
---|
| 192 | #define SIZEOF_LONG_LONG 8
|
---|
| 193 | #endif
|
---|
| 194 |
|
---|
| 195 | #ifdef THREADX
|
---|
| 196 | #define SIZEOF_LONG_LONG 8
|
---|
| 197 | #endif
|
---|
| 198 |
|
---|
| 199 | #ifdef HAVE_NETX
|
---|
| 200 | #ifdef NEED_THREADX_TYPES
|
---|
| 201 | #include <types.h>
|
---|
| 202 | #endif
|
---|
| 203 | #include <nx_api.h>
|
---|
| 204 | #endif
|
---|
| 205 |
|
---|
| 206 | #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
|
---|
| 207 | #define WOLFSSL_LWIP
|
---|
| 208 | #define NO_WRITEV
|
---|
| 209 | #define SINGLE_THREADED
|
---|
| 210 | #define WOLFSSL_USER_IO
|
---|
| 211 | #define NO_FILESYSTEM
|
---|
| 212 | #endif
|
---|
| 213 |
|
---|
| 214 | #if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
|
---|
| 215 | #define NO_MAIN_DRIVER
|
---|
| 216 | #define SINGLE_THREADED
|
---|
| 217 | #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
|
---|
| 218 | #define USE_CERT_BUFFERS_1024
|
---|
| 219 | #endif
|
---|
| 220 | #define BENCH_EMBEDDED
|
---|
| 221 | #define NO_FILESYSTEM
|
---|
| 222 | #define NO_WRITEV
|
---|
| 223 | #define WOLFSSL_USER_IO
|
---|
| 224 | #define BENCH_EMBEDDED
|
---|
| 225 | #endif
|
---|
| 226 |
|
---|
| 227 | #ifdef MICROCHIP_PIC32
|
---|
| 228 | /* #define WOLFSSL_MICROCHIP_PIC32MZ */
|
---|
| 229 | #define SIZEOF_LONG_LONG 8
|
---|
| 230 | #define SINGLE_THREADED
|
---|
| 231 | #define WOLFSSL_USER_IO
|
---|
| 232 | #define NO_WRITEV
|
---|
| 233 | #define NO_DEV_RANDOM
|
---|
| 234 | #define NO_FILESYSTEM
|
---|
| 235 | #define USE_FAST_MATH
|
---|
| 236 | #define TFM_TIMING_RESISTANT
|
---|
| 237 | #define WOLFSSL_HAVE_MIN
|
---|
| 238 | #define WOLFSSL_HAVE_MAX
|
---|
| 239 | #define NO_BIG_INT
|
---|
| 240 | #endif
|
---|
| 241 |
|
---|
| 242 | #ifdef WOLFSSL_MICROCHIP_PIC32MZ
|
---|
| 243 | #define WOLFSSL_PIC32MZ_CRYPT
|
---|
| 244 | #define WOLFSSL_PIC32MZ_RNG
|
---|
| 245 | #define WOLFSSL_PIC32MZ_HASH
|
---|
| 246 | #endif
|
---|
| 247 |
|
---|
| 248 | #ifdef MICROCHIP_TCPIP_V5
|
---|
| 249 | /* include timer functions */
|
---|
| 250 | #include "TCPIP Stack/TCPIP.h"
|
---|
| 251 | #endif
|
---|
| 252 |
|
---|
| 253 | #ifdef MICROCHIP_TCPIP
|
---|
| 254 | /* include timer, NTP functions */
|
---|
| 255 | #ifdef MICROCHIP_MPLAB_HARMONY
|
---|
| 256 | #include "tcpip/tcpip.h"
|
---|
| 257 | #else
|
---|
| 258 | #include "system/system_services.h"
|
---|
| 259 | #include "tcpip/sntp.h"
|
---|
| 260 | #endif
|
---|
| 261 | #endif
|
---|
| 262 |
|
---|
| 263 | #ifdef MBED
|
---|
| 264 | #define WOLFSSL_USER_IO
|
---|
| 265 | #define NO_FILESYSTEM
|
---|
| 266 | #define NO_CERT
|
---|
| 267 | #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
|
---|
| 268 | #define USE_CERT_BUFFERS_1024
|
---|
| 269 | #endif
|
---|
| 270 | #define NO_WRITEV
|
---|
| 271 | #define NO_DEV_RANDOM
|
---|
| 272 | #define NO_SHA512
|
---|
| 273 | #define NO_DH
|
---|
| 274 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 275 | /* WOLFSSL_DH_CONST */
|
---|
| 276 | #define NO_DSA
|
---|
| 277 | #define NO_HC128
|
---|
| 278 | #define HAVE_ECC
|
---|
| 279 | #define NO_SESSION_CACHE
|
---|
| 280 | #define WOLFSSL_CMSIS_RTOS
|
---|
| 281 | #endif
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 | #ifdef WOLFSSL_EROAD
|
---|
| 285 | #define FREESCALE_MQX
|
---|
| 286 | #define FREESCALE_MMCAU
|
---|
| 287 | #define SINGLE_THREADED
|
---|
| 288 | #define NO_STDIO_FILESYSTEM
|
---|
| 289 | #define WOLFSSL_LEANPSK
|
---|
| 290 | #define HAVE_NULL_CIPHER
|
---|
| 291 | #define NO_OLD_TLS
|
---|
| 292 | #define NO_ASN
|
---|
| 293 | #define NO_BIG_INT
|
---|
| 294 | #define NO_RSA
|
---|
| 295 | #define NO_DSA
|
---|
| 296 | #define NO_DH
|
---|
| 297 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 298 | /* WOLFSSL_DH_CONST */
|
---|
| 299 | #define NO_CERTS
|
---|
| 300 | #define NO_PWDBASED
|
---|
| 301 | #define NO_DES3
|
---|
| 302 | #define NO_MD4
|
---|
| 303 | #define NO_RC4
|
---|
| 304 | #define NO_MD5
|
---|
| 305 | #define NO_SESSION_CACHE
|
---|
| 306 | #define NO_MAIN_DRIVER
|
---|
| 307 | #endif
|
---|
| 308 |
|
---|
| 309 | #ifdef WOLFSSL_PICOTCP
|
---|
| 310 | #ifndef errno
|
---|
| 311 | #define errno pico_err
|
---|
| 312 | #endif
|
---|
| 313 | #include "pico_defines.h"
|
---|
| 314 | #include "pico_stack.h"
|
---|
| 315 | #include "pico_constants.h"
|
---|
| 316 | #include "pico_protocol.h"
|
---|
| 317 | #define CUSTOM_RAND_GENERATE pico_rand
|
---|
| 318 | #endif
|
---|
| 319 |
|
---|
| 320 | #ifdef WOLFSSL_PICOTCP_DEMO
|
---|
| 321 | #define WOLFSSL_STM32
|
---|
| 322 | #define USE_FAST_MATH
|
---|
| 323 | #define TFM_TIMING_RESISTANT
|
---|
| 324 | #define XMALLOC(s, h, type) PICO_ZALLOC((s))
|
---|
| 325 | #define XFREE(p, h, type) PICO_FREE((p))
|
---|
| 326 | #define SINGLE_THREADED
|
---|
| 327 | #define NO_WRITEV
|
---|
| 328 | #define WOLFSSL_USER_IO
|
---|
| 329 | #define NO_DEV_RANDOM
|
---|
| 330 | #define NO_FILESYSTEM
|
---|
| 331 | #endif
|
---|
| 332 |
|
---|
| 333 | #ifdef FREERTOS_WINSIM
|
---|
| 334 | #define FREERTOS
|
---|
| 335 | #define USE_WINDOWS_API
|
---|
| 336 | #endif
|
---|
| 337 |
|
---|
| 338 |
|
---|
| 339 | #ifdef WOLFSSL_VXWORKS
|
---|
| 340 | /* VxWorks simulator incorrectly detects building for i386 */
|
---|
| 341 | #ifdef VXWORKS_SIM
|
---|
| 342 | #define TFM_NO_ASM
|
---|
| 343 | #endif
|
---|
| 344 | #define WOLFSSL_PTHREADS
|
---|
| 345 | #define WOLFSSL_HAVE_MIN
|
---|
| 346 | #define WOLFSSL_HAVE_MAX
|
---|
| 347 | #define USE_FAST_MATH
|
---|
| 348 | #define TFM_TIMING_RESISTANT
|
---|
| 349 | #define NO_MAIN_DRIVER
|
---|
| 350 | #define NO_DEV_RANDOM
|
---|
| 351 | #define NO_WRITEV
|
---|
| 352 | #endif
|
---|
| 353 |
|
---|
| 354 |
|
---|
| 355 | #ifdef WOLFSSL_ARDUINO
|
---|
| 356 | #define NO_WRITEV
|
---|
| 357 | #define NO_WOLFSSL_DIR
|
---|
| 358 | #define SINGLE_THREADED
|
---|
| 359 | #define NO_DEV_RANDOM
|
---|
| 360 | #ifndef INTEL_GALILEO /* Galileo has time.h compatibility */
|
---|
| 361 | #define TIME_OVERRIDES /* must define XTIME and XGMTIME externally */
|
---|
| 362 | #endif
|
---|
| 363 | #define WOLFSSL_USER_IO
|
---|
| 364 | #define HAVE_ECC
|
---|
| 365 | #define NO_DH
|
---|
| 366 | #define NO_SESSION_CACHE
|
---|
| 367 | #define USE_SLOW_SHA
|
---|
| 368 | #define NO_WOLFSSL_SERVER
|
---|
| 369 | #define NO_ERROR_STRINGS
|
---|
| 370 | #endif
|
---|
| 371 |
|
---|
| 372 |
|
---|
| 373 | #ifdef WOLFSSL_UTASKER
|
---|
| 374 | /* uTasker configuration - used for fnRandom() */
|
---|
| 375 | #include "config.h"
|
---|
| 376 |
|
---|
| 377 | #define SINGLE_THREADED
|
---|
| 378 | #define NO_WOLFSSL_DIR
|
---|
| 379 | #define WOLFSSL_HAVE_MIN
|
---|
| 380 | #define NO_WRITEV
|
---|
| 381 |
|
---|
| 382 | #define HAVE_ECC
|
---|
| 383 | #define ALT_ECC_SIZE
|
---|
| 384 | #define USE_FAST_MATH
|
---|
| 385 | #define TFM_TIMING_RESISTANT
|
---|
| 386 | #define ECC_TIMING_RESISTANT
|
---|
| 387 |
|
---|
| 388 | /* used in wolfCrypt test */
|
---|
| 389 | #define NO_MAIN_DRIVER
|
---|
| 390 | #define USE_CERT_BUFFERS_2048
|
---|
| 391 |
|
---|
| 392 | /* uTasker port uses RAW sockets, use I/O callbacks
|
---|
| 393 | * See wolfSSL uTasker example for sample callbacks */
|
---|
| 394 | #define WOLFSSL_USER_IO
|
---|
| 395 |
|
---|
| 396 | /* uTasker filesystem not ported */
|
---|
| 397 | #define NO_FILESYSTEM
|
---|
| 398 |
|
---|
| 399 | /* uTasker RNG is abstracted, calls HW RNG when available */
|
---|
| 400 | #define CUSTOM_RAND_GENERATE fnRandom
|
---|
| 401 | #define CUSTOM_RAND_TYPE unsigned short
|
---|
| 402 |
|
---|
| 403 | /* user needs to define XTIME to function that provides
|
---|
| 404 | * seconds since Unix epoch */
|
---|
| 405 | #ifndef XTIME
|
---|
| 406 | #error XTIME must be defined in wolfSSL settings.h
|
---|
| 407 | /* #define XTIME fnSecondsSinceEpoch */
|
---|
| 408 | #endif
|
---|
| 409 |
|
---|
| 410 | /* use uTasker std library replacements where available */
|
---|
| 411 | #define STRING_USER
|
---|
| 412 | #define XMEMCPY(d,s,l) uMemcpy((d),(s),(l))
|
---|
| 413 | #define XMEMSET(b,c,l) uMemset((b),(c),(l))
|
---|
| 414 | #define XMEMCMP(s1,s2,n) uMemcmp((s1),(s2),(n))
|
---|
| 415 | #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
|
---|
| 416 |
|
---|
| 417 | #define XSTRLEN(s1) uStrlen((s1))
|
---|
| 418 | #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
---|
| 419 | #define XSTRSTR(s1,s2) strstr((s1),(s2))
|
---|
| 420 | #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
|
---|
| 421 | #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
---|
| 422 | #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
|
---|
| 423 | #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
|
---|
| 424 | #if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
|
---|
| 425 | #define XSTRTOK strtok_r
|
---|
| 426 | #endif
|
---|
| 427 | #endif
|
---|
| 428 |
|
---|
| 429 | #ifdef WOLFSSL_EMBOS
|
---|
| 430 | #define NO_FILESYSTEM /* Not ported at this time */
|
---|
| 431 | #define USE_CERT_BUFFERS_2048 /* use when NO_FILESYSTEM */
|
---|
| 432 | #define NO_MAIN_DRIVER
|
---|
| 433 | #define NO_RC4
|
---|
| 434 | #define SINGLE_THREADED /* Not ported at this time */
|
---|
| 435 | #endif
|
---|
| 436 |
|
---|
| 437 | #ifdef WOLFSSL_RIOT_OS
|
---|
| 438 | #define NO_WRITEV
|
---|
| 439 | #define TFM_NO_ASM
|
---|
| 440 | #define USE_FAST_MATH
|
---|
| 441 | #define NO_FILESYSTEM
|
---|
| 442 | #define USE_CERT_BUFFERS_2048
|
---|
| 443 | #endif
|
---|
| 444 |
|
---|
| 445 | #ifdef WOLFSSL_NRF5x
|
---|
| 446 | #define SIZEOF_LONG 4
|
---|
| 447 | #define SIZEOF_LONG_LONG 8
|
---|
| 448 | #define NO_ASN_TIME
|
---|
| 449 | #define NO_DEV_RANDOM
|
---|
| 450 | #define NO_FILESYSTEM
|
---|
| 451 | #define NO_MAIN_DRIVER
|
---|
| 452 | #define NO_WRITEV
|
---|
| 453 | #define SINGLE_THREADED
|
---|
| 454 | #define USE_FAST_MATH
|
---|
| 455 | #define TFM_TIMING_RESISTANT
|
---|
| 456 | #define USE_WOLFSSL_MEMORY
|
---|
| 457 | #define WOLFSSL_NRF51
|
---|
| 458 | #define WOLFSSL_USER_IO
|
---|
| 459 | #define NO_SESSION_CACHE
|
---|
| 460 | #endif
|
---|
| 461 |
|
---|
| 462 | /* Micrium will use Visual Studio for compilation but not the Win32 API */
|
---|
| 463 | #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
|
---|
| 464 | !defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
|
---|
| 465 | !defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
|
---|
| 466 | #define USE_WINDOWS_API
|
---|
| 467 | #endif
|
---|
| 468 |
|
---|
| 469 | #if defined(WOLFSSL_uITRON4)
|
---|
| 470 |
|
---|
| 471 | #define XMALLOC_USER
|
---|
| 472 | #include <stddef.h>
|
---|
| 473 | #define ITRON_POOL_SIZE 1024*20
|
---|
| 474 | extern int uITRON4_minit(size_t poolsz) ;
|
---|
| 475 | extern void *uITRON4_malloc(size_t sz) ;
|
---|
| 476 | extern void *uITRON4_realloc(void *p, size_t sz) ;
|
---|
| 477 | extern void uITRON4_free(void *p) ;
|
---|
| 478 |
|
---|
| 479 | #define XMALLOC(sz, heap, type) uITRON4_malloc(sz)
|
---|
| 480 | #define XREALLOC(p, sz, heap, type) uITRON4_realloc(p, sz)
|
---|
| 481 | #define XFREE(p, heap, type) uITRON4_free(p)
|
---|
| 482 | #endif
|
---|
| 483 |
|
---|
| 484 | #if defined(WOLFSSL_uTKERNEL2)
|
---|
| 485 | #ifndef NO_TKERNEL_MEM_POOL
|
---|
| 486 | #define XMALLOC_OVERRIDE
|
---|
| 487 | int uTKernel_init_mpool(unsigned int sz); /* initializing malloc pool */
|
---|
| 488 | void* uTKernel_malloc(unsigned int sz);
|
---|
| 489 | void* uTKernel_realloc(void *p, unsigned int sz);
|
---|
| 490 | void uTKernel_free(void *p);
|
---|
| 491 | #define XMALLOC(s, h, type) uTKernel_malloc((s))
|
---|
| 492 | #define XREALLOC(p, n, h, t) uTKernel_realloc((p), (n))
|
---|
| 493 | #define XFREE(p, h, type) uTKernel_free((p))
|
---|
| 494 | #endif
|
---|
| 495 |
|
---|
| 496 | #ifndef NO_STDIO_FGETS_REMAP
|
---|
| 497 | #include <stdio.h>
|
---|
| 498 | #include "tm/tmonitor.h"
|
---|
| 499 |
|
---|
| 500 | /* static char* gets(char *buff); */
|
---|
| 501 | static char* fgets(char *buff, int sz, FILE *fp) {
|
---|
| 502 | char * p = buff;
|
---|
| 503 | *p = '\0';
|
---|
| 504 | while (1) {
|
---|
| 505 | *p = tm_getchar(-1);
|
---|
| 506 | tm_putchar(*p);
|
---|
| 507 | if (*p == '\r') {
|
---|
| 508 | tm_putchar('\n');
|
---|
| 509 | *p = '\0';
|
---|
| 510 | break;
|
---|
| 511 | }
|
---|
| 512 | p++;
|
---|
| 513 | }
|
---|
| 514 | return buff;
|
---|
| 515 | }
|
---|
| 516 | #endif /* !NO_STDIO_FGETS_REMAP */
|
---|
| 517 | #endif
|
---|
| 518 |
|
---|
| 519 |
|
---|
| 520 | #if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER)
|
---|
| 521 | #include <stdlib.h>
|
---|
| 522 | #define XMALLOC(s, h, type) malloc((s))
|
---|
| 523 | #define XFREE(p, h, type) free((p))
|
---|
| 524 | #define XREALLOC(p, n, h, t) realloc((p), (n))
|
---|
| 525 | #endif
|
---|
| 526 |
|
---|
| 527 | #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
|
---|
| 528 | #undef XMALLOC
|
---|
| 529 | #define XMALLOC yaXMALLOC
|
---|
| 530 | #undef XFREE
|
---|
| 531 | #define XFREE yaXFREE
|
---|
| 532 | #undef XREALLOC
|
---|
| 533 | #define XREALLOC yaXREALLOC
|
---|
| 534 | #endif
|
---|
| 535 |
|
---|
| 536 |
|
---|
| 537 | #ifdef FREERTOS
|
---|
| 538 | #include "FreeRTOS.h"
|
---|
| 539 |
|
---|
| 540 | /* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */
|
---|
| 541 | #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
|
---|
| 542 | #define XMALLOC(s, h, type) pvPortMalloc((s))
|
---|
| 543 | #define XFREE(p, h, type) vPortFree((p))
|
---|
| 544 | #endif
|
---|
| 545 |
|
---|
| 546 | #ifndef NO_WRITEV
|
---|
| 547 | #define NO_WRITEV
|
---|
| 548 | #endif
|
---|
| 549 | #ifndef HAVE_SHA512
|
---|
| 550 | #ifndef NO_SHA512
|
---|
| 551 | #define NO_SHA512
|
---|
| 552 | #endif
|
---|
| 553 | #endif
|
---|
| 554 | #ifndef HAVE_DH
|
---|
| 555 | #ifndef NO_DH
|
---|
| 556 | #define NO_DH
|
---|
| 557 | #endif
|
---|
| 558 | #endif
|
---|
| 559 | #ifndef NO_DSA
|
---|
| 560 | #define NO_DSA
|
---|
| 561 | #endif
|
---|
| 562 | #ifndef NO_HC128
|
---|
| 563 | #define NO_HC128
|
---|
| 564 | #endif
|
---|
| 565 |
|
---|
| 566 | #ifndef SINGLE_THREADED
|
---|
| 567 | #include "semphr.h"
|
---|
| 568 | #endif
|
---|
| 569 | #endif
|
---|
| 570 |
|
---|
| 571 | #ifdef FREERTOS_TCP
|
---|
| 572 |
|
---|
| 573 | #if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER)
|
---|
| 574 | #define XMALLOC(s, h, type) pvPortMalloc((s))
|
---|
| 575 | #define XFREE(p, h, type) vPortFree((p))
|
---|
| 576 | #endif
|
---|
| 577 |
|
---|
| 578 | #define WOLFSSL_GENSEED_FORTEST
|
---|
| 579 |
|
---|
| 580 | #define NO_WOLFSSL_DIR
|
---|
| 581 | #define NO_WRITEV
|
---|
| 582 | #define USE_FAST_MATH
|
---|
| 583 | #define TFM_TIMING_RESISTANT
|
---|
| 584 | #define NO_MAIN_DRIVER
|
---|
| 585 |
|
---|
| 586 | #endif
|
---|
| 587 |
|
---|
| 588 | #ifdef WOLFSSL_TIRTOS
|
---|
| 589 | #define SIZEOF_LONG_LONG 8
|
---|
| 590 | #define NO_WRITEV
|
---|
| 591 | #define NO_WOLFSSL_DIR
|
---|
| 592 | #define USE_FAST_MATH
|
---|
| 593 | #define TFM_TIMING_RESISTANT
|
---|
| 594 | #define NO_DEV_RANDOM
|
---|
| 595 | #define NO_FILESYSTEM
|
---|
| 596 | #define USE_CERT_BUFFERS_2048
|
---|
| 597 | #define NO_ERROR_STRINGS
|
---|
| 598 | #define USER_TIME
|
---|
| 599 | #define HAVE_ECC
|
---|
| 600 | #define HAVE_ALPN
|
---|
| 601 | #define HAVE_TLS_EXTENSIONS
|
---|
| 602 | #define HAVE_AESGCM
|
---|
| 603 | #define HAVE_SUPPORTED_CURVES
|
---|
| 604 | #define ALT_ECC_SIZE
|
---|
| 605 |
|
---|
| 606 | #ifdef __IAR_SYSTEMS_ICC__
|
---|
| 607 | #pragma diag_suppress=Pa089
|
---|
| 608 | #elif !defined(__GNUC__)
|
---|
| 609 | /* Suppress the sslpro warning */
|
---|
| 610 | #pragma diag_suppress=11
|
---|
| 611 | #endif
|
---|
| 612 |
|
---|
| 613 | #include <ti/sysbios/hal/Seconds.h>
|
---|
| 614 | #endif
|
---|
| 615 |
|
---|
| 616 | #ifdef EBSNET
|
---|
| 617 | #include "rtip.h"
|
---|
| 618 |
|
---|
| 619 | /* #define DEBUG_WOLFSSL */
|
---|
| 620 | #define NO_WOLFSSL_DIR /* tbd */
|
---|
| 621 |
|
---|
| 622 | #if (POLLOS)
|
---|
| 623 | #define SINGLE_THREADED
|
---|
| 624 | #endif
|
---|
| 625 |
|
---|
| 626 | #if (RTPLATFORM)
|
---|
| 627 | #if (!RTP_LITTLE_ENDIAN)
|
---|
| 628 | #define BIG_ENDIAN_ORDER
|
---|
| 629 | #endif
|
---|
| 630 | #else
|
---|
| 631 | #if (!KS_LITTLE_ENDIAN)
|
---|
| 632 | #define BIG_ENDIAN_ORDER
|
---|
| 633 | #endif
|
---|
| 634 | #endif
|
---|
| 635 |
|
---|
| 636 | #if (WINMSP3)
|
---|
| 637 | #undef SIZEOF_LONG
|
---|
| 638 | #define SIZEOF_LONG_LONG 8
|
---|
| 639 | #else
|
---|
| 640 | #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
|
---|
| 641 | #endif
|
---|
| 642 |
|
---|
| 643 | #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
|
---|
| 644 | #define XFREE(p, h, type) (rtp_free(p))
|
---|
| 645 | #define XREALLOC(p, n, h, t) realloc((p), (n))
|
---|
| 646 |
|
---|
| 647 | #endif /* EBSNET */
|
---|
| 648 |
|
---|
| 649 | #ifdef WOLFSSL_GAME_BUILD
|
---|
| 650 | #define SIZEOF_LONG_LONG 8
|
---|
| 651 | #if defined(__PPU) || defined(__XENON)
|
---|
| 652 | #define BIG_ENDIAN_ORDER
|
---|
| 653 | #endif
|
---|
| 654 | #endif
|
---|
| 655 |
|
---|
| 656 | #ifdef WOLFSSL_LSR
|
---|
| 657 | #define HAVE_WEBSERVER
|
---|
| 658 | #define SIZEOF_LONG_LONG 8
|
---|
| 659 | #define WOLFSSL_LOW_MEMORY
|
---|
| 660 | #define NO_WRITEV
|
---|
| 661 | #define NO_SHA512
|
---|
| 662 | #define NO_DH
|
---|
| 663 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 664 | /* WOLFSSL_DH_CONST */
|
---|
| 665 | #define NO_DSA
|
---|
| 666 | #define NO_HC128
|
---|
| 667 | #define NO_DEV_RANDOM
|
---|
| 668 | #define NO_WOLFSSL_DIR
|
---|
| 669 | #define NO_RABBIT
|
---|
| 670 | #ifndef NO_FILESYSTEM
|
---|
| 671 | #define LSR_FS
|
---|
| 672 | #include "inc/hw_types.h"
|
---|
| 673 | #include "fs.h"
|
---|
| 674 | #endif
|
---|
| 675 | #define WOLFSSL_LWIP
|
---|
| 676 | #include <errno.h> /* for tcp errno */
|
---|
| 677 | #define WOLFSSL_SAFERTOS
|
---|
| 678 | #if defined(__IAR_SYSTEMS_ICC__)
|
---|
| 679 | /* enum uses enum */
|
---|
| 680 | #pragma diag_suppress=Pa089
|
---|
| 681 | #endif
|
---|
| 682 | #endif
|
---|
| 683 |
|
---|
| 684 | #ifdef WOLFSSL_SAFERTOS
|
---|
| 685 | #ifndef SINGLE_THREADED
|
---|
| 686 | #include "SafeRTOS/semphr.h"
|
---|
| 687 | #endif
|
---|
| 688 |
|
---|
| 689 | #include "SafeRTOS/heap.h"
|
---|
| 690 | #define XMALLOC(s, h, type) pvPortMalloc((s))
|
---|
| 691 | #define XFREE(p, h, type) vPortFree((p))
|
---|
| 692 | #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
|
---|
| 693 | #endif
|
---|
| 694 |
|
---|
| 695 | #ifdef WOLFSSL_LOW_MEMORY
|
---|
| 696 | #undef RSA_LOW_MEM
|
---|
| 697 | #define RSA_LOW_MEM
|
---|
| 698 | #undef WOLFSSL_SMALL_STACK
|
---|
| 699 | #define WOLFSSL_SMALL_STACK
|
---|
| 700 | #undef TFM_TIMING_RESISTANT
|
---|
| 701 | #define TFM_TIMING_RESISTANT
|
---|
| 702 | #endif
|
---|
| 703 |
|
---|
| 704 | #ifdef FREESCALE_MQX
|
---|
| 705 | #define FREESCALE_COMMON
|
---|
| 706 | #include "mqx.h"
|
---|
| 707 | #ifndef NO_FILESYSTEM
|
---|
| 708 | #include "mfs.h"
|
---|
| 709 | #if MQX_USE_IO_OLD
|
---|
| 710 | #include "fio.h"
|
---|
| 711 | #define NO_STDIO_FILESYSTEM
|
---|
| 712 | #else
|
---|
| 713 | #include "nio.h"
|
---|
| 714 | #endif
|
---|
| 715 | #endif
|
---|
| 716 | #ifndef SINGLE_THREADED
|
---|
| 717 | #include "mutex.h"
|
---|
| 718 | #endif
|
---|
| 719 |
|
---|
| 720 | #define XMALLOC_OVERRIDE
|
---|
| 721 | #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
|
---|
| 722 | #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
|
---|
| 723 | /* Note: MQX has no realloc, using fastmath above */
|
---|
| 724 | #endif
|
---|
| 725 |
|
---|
| 726 | #ifdef FREESCALE_KSDK_MQX
|
---|
| 727 | #define FREESCALE_COMMON
|
---|
| 728 | #include <mqx.h>
|
---|
| 729 | #ifndef NO_FILESYSTEM
|
---|
| 730 | #if MQX_USE_IO_OLD
|
---|
| 731 | #include <fio.h>
|
---|
| 732 | #else
|
---|
| 733 | #include <stdio.h>
|
---|
| 734 | #include <nio.h>
|
---|
| 735 | #endif
|
---|
| 736 | #endif
|
---|
| 737 | #ifndef SINGLE_THREADED
|
---|
| 738 | #include <mutex.h>
|
---|
| 739 | #endif
|
---|
| 740 |
|
---|
| 741 | #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
|
---|
| 742 | #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
|
---|
| 743 | #define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
|
---|
| 744 |
|
---|
| 745 | #define MQX_FILE_PTR FILE *
|
---|
| 746 | #define IO_SEEK_SET SEEK_SET
|
---|
| 747 | #define IO_SEEK_END SEEK_END
|
---|
| 748 | #endif /* FREESCALE_KSDK_MQX */
|
---|
| 749 |
|
---|
| 750 | #if defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
---|
| 751 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 752 | /* WOLFSSL_DH_CONST */
|
---|
| 753 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 754 | /* WOLFSSL_DH_CONST */
|
---|
| 755 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 756 | /* WOLFSSL_DH_CONST */
|
---|
| 757 | #define NO_FILESYSTEM
|
---|
| 758 | #define WOLFSSL_CRYPT_HW_MUTEX 1
|
---|
| 759 |
|
---|
| 760 | #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
|
---|
| 761 | #define XMALLOC(s, h, type) pvPortMalloc((s))
|
---|
| 762 | #define XFREE(p, h, type) vPortFree((p))
|
---|
| 763 | #endif
|
---|
| 764 |
|
---|
| 765 | //#define USER_TICKS
|
---|
| 766 | /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
---|
| 767 | /* WOLFSSL_DH_CONST */
|
---|
| 768 | #define WOLFSSL_LWIP
|
---|
| 769 | #define FREERTOS_TCP
|
---|
| 770 |
|
---|
| 771 | #define FREESCALE_FREE_RTOS
|
---|
| 772 | #define FREERTOS_SOCKET_ERROR ( -1 )
|
---|
| 773 | #define FREERTOS_EWOULDBLOCK ( -2 )
|
---|
| 774 | #define FREERTOS_EINVAL ( -4 )
|
---|
| 775 | #define FREERTOS_EADDRNOTAVAIL ( -5 )
|
---|
| 776 | #define FREERTOS_EADDRINUSE ( -6 )
|
---|
| 777 | #define FREERTOS_ENOBUFS ( -7 )
|
---|
| 778 | #define FREERTOS_ENOPROTOOPT ( -8 )
|
---|
| 779 | #endif /* FREESCALE_FREE_RTOS || FREESCALE_KSDK_FREERTOS */
|
---|
| 780 |
|
---|
| 781 | #ifdef FREESCALE_KSDK_BM
|
---|
| 782 | #define FREESCALE_COMMON
|
---|
| 783 | #define WOLFSSL_USER_IO
|
---|
| 784 | #define SINGLE_THREADED
|
---|
| 785 | #define NO_FILESYSTEM
|
---|
| 786 | #ifndef TIME_OVERRIDES
|
---|
| 787 | #define USER_TICKS
|
---|
| 788 | #endif
|
---|
| 789 | #endif /* FREESCALE_KSDK_BM */
|
---|
| 790 |
|
---|
| 791 | #ifdef FREESCALE_COMMON
|
---|
| 792 | #define SIZEOF_LONG_LONG 8
|
---|
| 793 |
|
---|
| 794 | /* disable features */
|
---|
| 795 | #undef NO_WRITEV
|
---|
| 796 | #define NO_WRITEV
|
---|
| 797 | #undef NO_DEV_RANDOM
|
---|
| 798 | #define NO_DEV_RANDOM
|
---|
| 799 | #undef NO_RABBIT
|
---|
| 800 | #define NO_RABBIT
|
---|
| 801 | #undef NO_WOLFSSL_DIR
|
---|
| 802 | #define NO_WOLFSSL_DIR
|
---|
| 803 | #undef NO_RC4
|
---|
| 804 | #define NO_RC4
|
---|
| 805 |
|
---|
| 806 | /* enable features */
|
---|
| 807 | #undef USE_FAST_MATH
|
---|
| 808 | #define USE_FAST_MATH
|
---|
| 809 |
|
---|
| 810 | #define USE_CERT_BUFFERS_2048
|
---|
| 811 | #define BENCH_EMBEDDED
|
---|
| 812 |
|
---|
| 813 | #define TFM_TIMING_RESISTANT
|
---|
| 814 | #define ECC_TIMING_RESISTANT
|
---|
| 815 |
|
---|
| 816 | #undef HAVE_ECC
|
---|
| 817 | #define HAVE_ECC
|
---|
| 818 | #ifndef NO_AES
|
---|
| 819 | #undef HAVE_AESCCM
|
---|
| 820 | #define HAVE_AESCCM
|
---|
| 821 | #undef HAVE_AESGCM
|
---|
| 822 | #define HAVE_AESGCM
|
---|
| 823 | #undef WOLFSSL_AES_COUNTER
|
---|
| 824 | #define WOLFSSL_AES_COUNTER
|
---|
| 825 | #undef WOLFSSL_AES_DIRECT
|
---|
| 826 | #define WOLFSSL_AES_DIRECT
|
---|
| 827 | #endif
|
---|
| 828 |
|
---|
| 829 | #ifdef FREESCALE_KSDK_1_3
|
---|
| 830 | #include "fsl_device_registers.h"
|
---|
| 831 | #elif !defined(FREESCALE_MQX)
|
---|
| 832 | /* Classic MQX does not have fsl_common.h */
|
---|
| 833 | #include "fsl_common.h"
|
---|
| 834 | #endif
|
---|
| 835 |
|
---|
| 836 | /* random seed */
|
---|
| 837 | #define NO_OLD_RNGNAME
|
---|
| 838 | #if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0)
|
---|
| 839 | #define FREESCALE_KSDK_2_0_TRNG
|
---|
| 840 | #elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0)
|
---|
| 841 | #ifdef FREESCALE_KSDK_1_3
|
---|
| 842 | #include "fsl_rnga_driver.h"
|
---|
| 843 | #define FREESCALE_RNGA
|
---|
| 844 | #define RNGA_INSTANCE (0)
|
---|
| 845 | #else
|
---|
| 846 | #define FREESCALE_KSDK_2_0_RNGA
|
---|
| 847 | #endif
|
---|
| 848 | #elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) && !defined(FREESCALE_KSDK_FREERTOS)
|
---|
| 849 | #define FREESCALE_RNGA
|
---|
| 850 | #define RNGA_INSTANCE (0)
|
---|
| 851 | /* defaulting to K70 RNGA, user should change if different */
|
---|
| 852 | /* #define FREESCALE_K53_RNGB */
|
---|
| 853 | #define FREESCALE_K70_RNGA
|
---|
| 854 | #endif
|
---|
| 855 |
|
---|
| 856 | /* HW crypto */
|
---|
| 857 | /* automatic enable based on Kinetis feature */
|
---|
| 858 | /* if case manual selection is required, for example for benchmarking purposes,
|
---|
| 859 | * just define FREESCALE_USE_MMCAU or FREESCALE_USE_LTC or none of these two macros (for software only)
|
---|
| 860 | * both can be enabled simultaneously as LTC has priority over MMCAU in source code.
|
---|
| 861 | */
|
---|
| 862 | /* #define FSL_HW_CRYPTO_MANUAL_SELECTION */
|
---|
| 863 | #ifndef FSL_HW_CRYPTO_MANUAL_SELECTION
|
---|
| 864 | #if defined(FSL_FEATURE_SOC_MMCAU_COUNT) && FSL_FEATURE_SOC_MMCAU_COUNT
|
---|
| 865 | #define FREESCALE_USE_MMCAU
|
---|
| 866 | #endif
|
---|
| 867 |
|
---|
| 868 | #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
|
---|
| 869 | #define FREESCALE_USE_LTC
|
---|
| 870 | #endif
|
---|
| 871 | #else
|
---|
| 872 | /* #define FREESCALE_USE_MMCAU */
|
---|
| 873 | /* #define FREESCALE_USE_LTC */
|
---|
| 874 | #endif
|
---|
| 875 | #endif /* FREESCALE_COMMON */
|
---|
| 876 |
|
---|
| 877 | /* Classic pre-KSDK mmCAU library */
|
---|
| 878 | #ifdef FREESCALE_USE_MMCAU_CLASSIC
|
---|
| 879 | #define FREESCALE_USE_MMCAU
|
---|
| 880 | #define FREESCALE_MMCAU_CLASSIC
|
---|
| 881 | #define FREESCALE_MMCAU_CLASSIC_SHA
|
---|
| 882 | #endif
|
---|
| 883 |
|
---|
| 884 | /* KSDK mmCAU library */
|
---|
| 885 | #ifdef FREESCALE_USE_MMCAU
|
---|
| 886 | /* AES and DES */
|
---|
| 887 | #define FREESCALE_MMCAU
|
---|
| 888 | /* MD5, SHA-1 and SHA-256 */
|
---|
| 889 | #define FREESCALE_MMCAU_SHA
|
---|
| 890 | #endif /* FREESCALE_USE_MMCAU */
|
---|
| 891 |
|
---|
| 892 | #ifdef FREESCALE_USE_LTC
|
---|
| 893 | #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
|
---|
| 894 | #define FREESCALE_LTC
|
---|
| 895 | #define LTC_BASE LTC0
|
---|
| 896 |
|
---|
| 897 | #if defined(FSL_FEATURE_LTC_HAS_DES) && FSL_FEATURE_LTC_HAS_DES
|
---|
| 898 | #define FREESCALE_LTC_DES
|
---|
| 899 | #endif
|
---|
| 900 |
|
---|
| 901 | #if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM
|
---|
| 902 | #define FREESCALE_LTC_AES_GCM
|
---|
| 903 | #endif
|
---|
| 904 |
|
---|
| 905 | #if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA
|
---|
| 906 | #define FREESCALE_LTC_SHA
|
---|
| 907 | #endif
|
---|
| 908 |
|
---|
| 909 | #if defined(FSL_FEATURE_LTC_HAS_PKHA) && FSL_FEATURE_LTC_HAS_PKHA
|
---|
| 910 | #define FREESCALE_LTC_ECC
|
---|
| 911 | #define FREESCALE_LTC_TFM
|
---|
| 912 |
|
---|
| 913 | /* the LTC PKHA hardware limit is 2048 bits (256 bytes) for integer arithmetic.
|
---|
| 914 | the LTC_MAX_INT_BYTES defines the size of local variables that hold big integers. */
|
---|
| 915 | #ifndef LTC_MAX_INT_BYTES
|
---|
| 916 | #define LTC_MAX_INT_BYTES (256)
|
---|
| 917 | #endif
|
---|
| 918 |
|
---|
| 919 | /* This FREESCALE_LTC_TFM_RSA_4096_ENABLE macro can be defined.
|
---|
| 920 | * In such a case both software and hardware algorithm
|
---|
| 921 | * for TFM is linked in. The decision for which algorithm is used is determined at runtime
|
---|
| 922 | * from size of inputs. If inputs and result can fit into LTC (see LTC_MAX_INT_BYTES)
|
---|
| 923 | * then we call hardware algorithm, otherwise we call software algorithm.
|
---|
| 924 | *
|
---|
| 925 | * Chinese reminder theorem is used to break RSA 4096 exponentiations (both public and private key)
|
---|
| 926 | * into several computations with 2048-bit modulus and exponents.
|
---|
| 927 | */
|
---|
| 928 | /* #define FREESCALE_LTC_TFM_RSA_4096_ENABLE */
|
---|
| 929 |
|
---|
| 930 | /* ECC-384, ECC-256, ECC-224 and ECC-192 have been enabled with LTC PKHA acceleration */
|
---|
| 931 | #ifdef HAVE_ECC
|
---|
| 932 | #undef ECC_TIMING_RESISTANT
|
---|
| 933 | #define ECC_TIMING_RESISTANT
|
---|
| 934 |
|
---|
| 935 | /* the LTC PKHA hardware limit is 512 bits (64 bytes) for ECC.
|
---|
| 936 | the LTC_MAX_ECC_BITS defines the size of local variables that hold ECC parameters
|
---|
| 937 | and point coordinates */
|
---|
| 938 | #ifndef LTC_MAX_ECC_BITS
|
---|
| 939 | #define LTC_MAX_ECC_BITS (384)
|
---|
| 940 | #endif
|
---|
| 941 |
|
---|
| 942 | /* Enable curves up to 384 bits */
|
---|
| 943 | #if !defined(ECC_USER_CURVES) && !defined(HAVE_ALL_CURVES)
|
---|
| 944 | #define ECC_USER_CURVES
|
---|
| 945 | #define HAVE_ECC192
|
---|
| 946 | #define HAVE_ECC224
|
---|
| 947 | #undef NO_ECC256
|
---|
| 948 | #define HAVE_ECC384
|
---|
| 949 | #endif
|
---|
| 950 |
|
---|
| 951 | /* enable features */
|
---|
| 952 | #undef HAVE_CURVE25519
|
---|
| 953 | #define HAVE_CURVE25519
|
---|
| 954 | #undef HAVE_ED25519
|
---|
| 955 | #define HAVE_ED25519
|
---|
| 956 | #undef WOLFSSL_SHA512
|
---|
| 957 | #define WOLFSSL_SHA512
|
---|
| 958 | #endif
|
---|
| 959 | #endif
|
---|
| 960 | #endif
|
---|
| 961 | #endif /* FREESCALE_USE_LTC */
|
---|
| 962 |
|
---|
| 963 | #ifdef FREESCALE_LTC_TFM_RSA_4096_ENABLE
|
---|
| 964 | #undef USE_CERT_BUFFERS_4096
|
---|
| 965 | #define USE_CERT_BUFFERS_4096
|
---|
| 966 | #undef FP_MAX_BITS
|
---|
| 967 | #define FP_MAX_BITS (8192)
|
---|
| 968 |
|
---|
| 969 | #undef NO_DH
|
---|
| 970 | #define NO_DH
|
---|
| 971 | #undef NO_DSA
|
---|
| 972 | #define NO_DSA
|
---|
| 973 | #endif /* FREESCALE_LTC_TFM_RSA_4096_ENABLE */
|
---|
| 974 |
|
---|
| 975 | /* if LTC has AES engine but doesn't have GCM, use software with LTC AES ECB mode */
|
---|
| 976 | #if defined(FREESCALE_USE_LTC) && !defined(FREESCALE_LTC_AES_GCM)
|
---|
| 977 | #define GCM_TABLE
|
---|
| 978 | #endif
|
---|
| 979 |
|
---|
| 980 | #if defined(WOLFSSL_STM32F2) || defined(WOLFSSL_STM32F4) || \
|
---|
| 981 | defined(WOLFSSL_STM32F7)
|
---|
| 982 |
|
---|
| 983 | #define SIZEOF_LONG_LONG 8
|
---|
| 984 | #define NO_DEV_RANDOM
|
---|
| 985 | #define NO_WOLFSSL_DIR
|
---|
| 986 | #undef NO_RABBIT
|
---|
| 987 | #define NO_RABBIT
|
---|
| 988 | #undef NO_64BIT
|
---|
| 989 | #define NO_64BIT
|
---|
| 990 | #ifndef NO_STM32_RNG
|
---|
| 991 | #undef STM32_RNG
|
---|
| 992 | #define STM32_RNG
|
---|
| 993 | #endif
|
---|
| 994 | #ifndef NO_STM32_CRYPTO
|
---|
| 995 | #undef STM32_CRYPTO
|
---|
| 996 | #define STM32_CRYPTO
|
---|
| 997 | #endif
|
---|
| 998 | #ifndef NO_STM32_HASH
|
---|
| 999 | #undef STM32_HASH
|
---|
| 1000 | #define STM32_HASH
|
---|
| 1001 | #endif
|
---|
| 1002 | #if !defined(__GNUC__) && !defined(__ICCARM__)
|
---|
| 1003 | #define KEIL_INTRINSICS
|
---|
| 1004 | #endif
|
---|
| 1005 | #define NO_OLD_RNGNAME
|
---|
| 1006 | #ifdef WOLFSSL_STM32_CUBEMX
|
---|
| 1007 | #if defined(WOLFSSL_STM32F2)
|
---|
| 1008 | #include "stm32f2xx_hal.h"
|
---|
| 1009 | #elif defined(WOLFSSL_STM32F4)
|
---|
| 1010 | #include "stm32f4xx_hal.h"
|
---|
| 1011 | #elif defined(WOLFSSL_STM32F7)
|
---|
| 1012 | #include "stm32f7xx_hal.h"
|
---|
| 1013 | #endif
|
---|
| 1014 |
|
---|
| 1015 | #ifndef STM32_HAL_TIMEOUT
|
---|
| 1016 | #define STM32_HAL_TIMEOUT 0xFF
|
---|
| 1017 | #endif
|
---|
| 1018 | #else
|
---|
| 1019 | #if defined(WOLFSSL_STM32F2)
|
---|
| 1020 | #include "stm32f2xx.h"
|
---|
| 1021 | #ifdef STM32_CRYPTO
|
---|
| 1022 | #include "stm32f2xx_cryp.h"
|
---|
| 1023 | #endif
|
---|
| 1024 | #ifdef STM32_HASH
|
---|
| 1025 | #include "stm32f2xx_hash.h"
|
---|
| 1026 | #endif
|
---|
| 1027 | #elif defined(WOLFSSL_STM32F4)
|
---|
| 1028 | #include "stm32f4xx.h"
|
---|
| 1029 | #ifdef STM32_CRYPTO
|
---|
| 1030 | #include "stm32f4xx_cryp.h"
|
---|
| 1031 | #endif
|
---|
| 1032 | #ifdef STM32_HASH
|
---|
| 1033 | #include "stm32f4xx_hash.h"
|
---|
| 1034 | #endif
|
---|
| 1035 | #elif defined(WOLFSSL_STM32F7)
|
---|
| 1036 | #include "stm32f7xx.h"
|
---|
| 1037 | #endif
|
---|
| 1038 | #endif /* WOLFSSL_STM32_CUBEMX */
|
---|
| 1039 | #endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32F7 */
|
---|
| 1040 |
|
---|
| 1041 | #ifdef MICRIUM
|
---|
| 1042 | #include <stdlib.h>
|
---|
| 1043 | #include <os.h>
|
---|
| 1044 | #include <net_cfg.h>
|
---|
| 1045 | #include <net_sock.h>
|
---|
| 1046 | #include <net_err.h>
|
---|
| 1047 | #include <lib_mem.h>
|
---|
| 1048 | #include <lib_math.h>
|
---|
| 1049 |
|
---|
| 1050 | #define USE_FAST_MATH
|
---|
| 1051 | #define TFM_TIMING_RESISTANT
|
---|
| 1052 | #define ECC_TIMING_RESISTANT
|
---|
| 1053 | #define WC_RSA_BLINDING
|
---|
| 1054 | #define HAVE_HASHDRBG
|
---|
| 1055 |
|
---|
| 1056 | #define HAVE_ECC
|
---|
| 1057 | #define ALT_ECC_SIZE
|
---|
| 1058 | #define TFM_ECC192
|
---|
| 1059 | #define TFM_ECC224
|
---|
| 1060 | #define TFM_ECC256
|
---|
| 1061 | #define TFM_ECC384
|
---|
| 1062 | #define TFM_ECC521
|
---|
| 1063 |
|
---|
| 1064 | #define NO_RC4
|
---|
| 1065 | #define HAVE_TLS_EXTENSIONS
|
---|
| 1066 | #define HAVE_SUPPORTED_CURVES
|
---|
| 1067 | #define HAVE_EXTENDED_MASTER
|
---|
| 1068 |
|
---|
| 1069 | #define NO_WOLFSSL_DIR
|
---|
| 1070 | #define NO_WRITEV
|
---|
| 1071 |
|
---|
| 1072 | #ifndef CUSTOM_RAND_GENERATE
|
---|
| 1073 | #define CUSTOM_RAND_TYPE RAND_NBR
|
---|
| 1074 | #define CUSTOM_RAND_GENERATE Math_Rand
|
---|
| 1075 | #endif
|
---|
| 1076 |
|
---|
| 1077 | #define WOLFSSL_TYPES
|
---|
| 1078 | typedef CPU_INT08U byte;
|
---|
| 1079 | typedef CPU_INT16U word16;
|
---|
| 1080 | typedef CPU_INT32U word32;
|
---|
| 1081 |
|
---|
| 1082 | #define STRING_USER
|
---|
| 1083 | #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
|
---|
| 1084 | #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
|
---|
| 1085 | ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
|
---|
| 1086 | (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
|
---|
| 1087 | #define XSTRNCMP(pstr_1, pstr_2, len_max) \
|
---|
| 1088 | ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
|
---|
| 1089 | (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
|
---|
| 1090 | #define XSTRNCASECMP(pstr_1, pstr_2, len_max) \
|
---|
| 1091 | ((CPU_INT16S)Str_CmpIgnoreCase_N((CPU_CHAR *)(pstr_1), \
|
---|
| 1092 | (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
|
---|
| 1093 | #define XSTRSTR(pstr, pstr_srch) \
|
---|
| 1094 | ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
|
---|
| 1095 | (CPU_CHAR *)(pstr_srch)))
|
---|
| 1096 | #define XSTRNSTR(pstr, pstr_srch, len_max) \
|
---|
| 1097 | ((CPU_CHAR *)Str_Str_N((CPU_CHAR *)(pstr), \
|
---|
| 1098 | (CPU_CHAR *)(pstr_srch),(CPU_SIZE_T)(len_max)))
|
---|
| 1099 | #define XSTRNCAT(pstr_dest, pstr_cat, len_max) \
|
---|
| 1100 | ((CPU_CHAR *)Str_Cat_N((CPU_CHAR *)(pstr_dest), \
|
---|
| 1101 | (const CPU_CHAR *)(pstr_cat),(CPU_SIZE_T)(len_max)))
|
---|
| 1102 | #define XMEMSET(pmem, data_val, size) \
|
---|
| 1103 | ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
|
---|
| 1104 | (CPU_SIZE_T)(size)))
|
---|
| 1105 | #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
|
---|
| 1106 | (void *)(psrc), (CPU_SIZE_T)(size)))
|
---|
| 1107 | #define XMEMCMP(pmem_1, pmem_2, size) \
|
---|
| 1108 | (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
|
---|
| 1109 | (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
|
---|
| 1110 | #define XMEMMOVE XMEMCPY
|
---|
| 1111 |
|
---|
| 1112 | #if (OS_CFG_MUTEX_EN == DEF_DISABLED)
|
---|
| 1113 | #define SINGLE_THREADED
|
---|
| 1114 | #endif
|
---|
| 1115 |
|
---|
| 1116 | #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
|
---|
| 1117 | #define BIG_ENDIAN_ORDER
|
---|
| 1118 | #else
|
---|
| 1119 | #undef BIG_ENDIAN_ORDER
|
---|
| 1120 | #define LITTLE_ENDIAN_ORDER
|
---|
| 1121 | #endif
|
---|
| 1122 | #endif /* MICRIUM */
|
---|
| 1123 |
|
---|
| 1124 |
|
---|
| 1125 | #ifdef WOLFSSL_QL
|
---|
| 1126 | #ifndef WOLFSSL_SEP
|
---|
| 1127 | #define WOLFSSL_SEP
|
---|
| 1128 | #endif
|
---|
| 1129 | #ifndef OPENSSL_EXTRA
|
---|
| 1130 | #define OPENSSL_EXTRA
|
---|
| 1131 | #endif
|
---|
| 1132 | #ifndef SESSION_CERTS
|
---|
| 1133 | #define SESSION_CERTS
|
---|
| 1134 | #endif
|
---|
| 1135 | #ifndef HAVE_AESCCM
|
---|
| 1136 | #define HAVE_AESCCM
|
---|
| 1137 | #endif
|
---|
| 1138 | #ifndef ATOMIC_USER
|
---|
| 1139 | #define ATOMIC_USER
|
---|
| 1140 | #endif
|
---|
| 1141 | #ifndef WOLFSSL_DER_LOAD
|
---|
| 1142 | #define WOLFSSL_DER_LOAD
|
---|
| 1143 | #endif
|
---|
| 1144 | #ifndef KEEP_PEER_CERT
|
---|
| 1145 | #define KEEP_PEER_CERT
|
---|
| 1146 | #endif
|
---|
| 1147 | #ifndef HAVE_ECC
|
---|
| 1148 | #define HAVE_ECC
|
---|
| 1149 | #endif
|
---|
| 1150 | #ifndef SESSION_INDEX
|
---|
| 1151 | #define SESSION_INDEX
|
---|
| 1152 | #endif
|
---|
| 1153 | #endif /* WOLFSSL_QL */
|
---|
| 1154 |
|
---|
| 1155 |
|
---|
| 1156 | #if defined(WOLFSSL_XILINX)
|
---|
| 1157 | #define USER_TIME /* XTIME in asn.c */
|
---|
| 1158 | #define NO_WOLFSSL_DIR
|
---|
| 1159 | #define NO_DEV_RANDOM
|
---|
| 1160 | #define HAVE_AESGCM
|
---|
| 1161 | #endif
|
---|
| 1162 |
|
---|
| 1163 | #if defined(WOLFSSL_XILINX_CRYPT)
|
---|
| 1164 | #if defined(WOLFSSL_ARMASM)
|
---|
| 1165 | #error can not use both ARMv8 instructions and XILINX hardened crypto
|
---|
| 1166 | #endif
|
---|
| 1167 | #if defined(WOLFSSL_SHA3)
|
---|
| 1168 | /* only SHA3-384 is supported */
|
---|
| 1169 | #undef WOLFSSL_NOSHA3_224
|
---|
| 1170 | #undef WOLFSSL_NOSHA3_256
|
---|
| 1171 | #undef WOLFSSL_NOSHA3_512
|
---|
| 1172 | #define WOLFSSL_NOSHA3_224
|
---|
| 1173 | #define WOLFSSL_NOSHA3_256
|
---|
| 1174 | #define WOLFSSL_NOSHA3_512
|
---|
| 1175 | #endif
|
---|
| 1176 | #endif /*(WOLFSSL_XILINX_CRYPT)*/
|
---|
| 1177 |
|
---|
| 1178 | #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
|
---|
| 1179 | !defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY) && \
|
---|
| 1180 | !defined(XMALLOC_OVERRIDE)
|
---|
| 1181 | #define USE_WOLFSSL_MEMORY
|
---|
| 1182 | #endif
|
---|
| 1183 |
|
---|
| 1184 |
|
---|
| 1185 | #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
|
---|
| 1186 | #undef KEEP_PEER_CERT
|
---|
| 1187 | #define KEEP_PEER_CERT
|
---|
| 1188 | #endif
|
---|
| 1189 |
|
---|
| 1190 |
|
---|
| 1191 | /* stream ciphers except arc4 need 32bit alignment, intel ok without */
|
---|
| 1192 | #ifndef XSTREAM_ALIGN
|
---|
| 1193 | #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
|
---|
| 1194 | #define NO_XSTREAM_ALIGN
|
---|
| 1195 | #else
|
---|
| 1196 | #define XSTREAM_ALIGN
|
---|
| 1197 | #endif
|
---|
| 1198 | #endif
|
---|
| 1199 |
|
---|
| 1200 | /* write dup cannot be used with secure renegotiation because write dup
|
---|
| 1201 | * make write side write only and read side read only */
|
---|
| 1202 | #if defined(HAVE_WRITE_DUP) && defined(HAVE_SECURE_RENEGOTIATION)
|
---|
| 1203 | #error "WRITE DUP and SECURE RENEGOTIATION cannot both be on"
|
---|
| 1204 | #endif
|
---|
| 1205 |
|
---|
| 1206 | #ifdef WOLFSSL_SGX
|
---|
| 1207 | #ifdef _MSC_VER
|
---|
| 1208 | #define WOLFCRYPT_ONLY
|
---|
| 1209 | #define NO_RC4
|
---|
| 1210 | #define NO_DES3
|
---|
| 1211 | #define NO_SHA
|
---|
| 1212 | #define NO_MD5
|
---|
| 1213 | #else
|
---|
| 1214 | #define HAVE_ECC
|
---|
| 1215 | #define ECC_TIMING_RESISTANT
|
---|
| 1216 | #define TFM_TIMING_RESISTANT
|
---|
| 1217 | #define NO_FILESYSTEM
|
---|
| 1218 | #define NO_WRITEV
|
---|
| 1219 | #define NO_MAIN_DRIVER
|
---|
| 1220 | #define USER_TICKS
|
---|
| 1221 | #define WOLFSSL_LOG_PRINTF
|
---|
| 1222 | #define WOLFSSL_DH_CONST
|
---|
| 1223 | #endif /* _MSC_VER */
|
---|
| 1224 | #ifndef NO_RSA
|
---|
| 1225 | #define WC_RSA_BLINDING
|
---|
| 1226 | #endif
|
---|
| 1227 | #define SINGLE_THREADED
|
---|
| 1228 | #define NO_ASN_TIME /* can not use headers such as windows.h */
|
---|
| 1229 | #define HAVE_AESGCM
|
---|
| 1230 | #define USE_CERT_BUFFERS_2048
|
---|
| 1231 | #define USE_FAST_MATH
|
---|
| 1232 | #endif /* WOLFSSL_SGX */
|
---|
| 1233 |
|
---|
| 1234 | /* FreeScale MMCAU hardware crypto has 4 byte alignment.
|
---|
| 1235 | However, KSDK fsl_mmcau.h gives API with no alignment
|
---|
| 1236 | requirements (4 byte alignment is managed internally by fsl_mmcau.c) */
|
---|
| 1237 | #ifdef FREESCALE_MMCAU
|
---|
| 1238 | #ifdef FREESCALE_MMCAU_CLASSIC
|
---|
| 1239 | #define WOLFSSL_MMCAU_ALIGNMENT 4
|
---|
| 1240 | #else
|
---|
| 1241 | #define WOLFSSL_MMCAU_ALIGNMENT 0
|
---|
| 1242 | #endif
|
---|
| 1243 | #endif
|
---|
| 1244 |
|
---|
| 1245 | /* if using hardware crypto and have alignment requirements, specify the
|
---|
| 1246 | requirement here. The record header of SSL/TLS will prevent easy alignment.
|
---|
| 1247 | This hint tries to help as much as possible. */
|
---|
| 1248 | #ifndef WOLFSSL_GENERAL_ALIGNMENT
|
---|
| 1249 | #ifdef WOLFSSL_AESNI
|
---|
| 1250 | #define WOLFSSL_GENERAL_ALIGNMENT 16
|
---|
| 1251 | #elif defined(XSTREAM_ALIGN)
|
---|
| 1252 | #define WOLFSSL_GENERAL_ALIGNMENT 4
|
---|
| 1253 | #elif defined(FREESCALE_MMCAU) || defined(FREESCALE_MMCAU_CLASSIC)
|
---|
| 1254 | #define WOLFSSL_GENERAL_ALIGNMENT WOLFSSL_MMCAU_ALIGNMENT
|
---|
| 1255 | #else
|
---|
| 1256 | #define WOLFSSL_GENERAL_ALIGNMENT 0
|
---|
| 1257 | #endif
|
---|
| 1258 | #endif
|
---|
| 1259 |
|
---|
| 1260 | #if defined(WOLFSSL_GENERAL_ALIGNMENT) && (WOLFSSL_GENERAL_ALIGNMENT > 0)
|
---|
| 1261 | #if defined(_MSC_VER)
|
---|
| 1262 | #define XGEN_ALIGN __declspec(align(WOLFSSL_GENERAL_ALIGNMENT))
|
---|
| 1263 | #elif defined(__GNUC__)
|
---|
| 1264 | #define XGEN_ALIGN __attribute__((aligned(WOLFSSL_GENERAL_ALIGNMENT)))
|
---|
| 1265 | #else
|
---|
| 1266 | #define XGEN_ALIGN
|
---|
| 1267 | #endif
|
---|
| 1268 | #else
|
---|
| 1269 | #define XGEN_ALIGN
|
---|
| 1270 | #endif
|
---|
| 1271 |
|
---|
| 1272 | #ifdef HAVE_CRL
|
---|
| 1273 | /* not widely supported yet */
|
---|
| 1274 | #undef NO_SKID
|
---|
| 1275 | #define NO_SKID
|
---|
| 1276 | #endif
|
---|
| 1277 |
|
---|
| 1278 |
|
---|
| 1279 | #ifdef __INTEL_COMPILER
|
---|
| 1280 | #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
|
---|
| 1281 | #endif
|
---|
| 1282 |
|
---|
| 1283 | /* user can specify what curves they want with ECC_USER_CURVES otherwise
|
---|
| 1284 | * all curves are on by default for now */
|
---|
| 1285 | #ifndef ECC_USER_CURVES
|
---|
| 1286 | #ifndef HAVE_ALL_CURVES
|
---|
| 1287 | #define HAVE_ALL_CURVES
|
---|
| 1288 | #endif
|
---|
| 1289 | #endif
|
---|
| 1290 |
|
---|
| 1291 | /* ECC Configs */
|
---|
| 1292 | #ifdef HAVE_ECC
|
---|
| 1293 | /* By default enable Sign, Verify, DHE, Key Import and Key Export unless explicitly disabled */
|
---|
| 1294 | #ifndef NO_ECC_SIGN
|
---|
| 1295 | #undef HAVE_ECC_SIGN
|
---|
| 1296 | #define HAVE_ECC_SIGN
|
---|
| 1297 | #endif
|
---|
| 1298 | #ifndef NO_ECC_VERIFY
|
---|
| 1299 | #undef HAVE_ECC_VERIFY
|
---|
| 1300 | #define HAVE_ECC_VERIFY
|
---|
| 1301 | #endif
|
---|
| 1302 | #ifndef NO_ECC_DHE
|
---|
| 1303 | #undef HAVE_ECC_DHE
|
---|
| 1304 | #define HAVE_ECC_DHE
|
---|
| 1305 | #endif
|
---|
| 1306 | #ifndef NO_ECC_KEY_IMPORT
|
---|
| 1307 | #undef HAVE_ECC_KEY_IMPORT
|
---|
| 1308 | #define HAVE_ECC_KEY_IMPORT
|
---|
| 1309 | #endif
|
---|
| 1310 | #ifndef NO_ECC_KEY_EXPORT
|
---|
| 1311 | #undef HAVE_ECC_KEY_EXPORT
|
---|
| 1312 | #define HAVE_ECC_KEY_EXPORT
|
---|
| 1313 | #endif
|
---|
| 1314 | #endif /* HAVE_ECC */
|
---|
| 1315 |
|
---|
| 1316 | /* Curve255519 Configs */
|
---|
| 1317 | #ifdef HAVE_CURVE25519
|
---|
| 1318 | /* By default enable shared secret, key export and import */
|
---|
| 1319 | #ifndef NO_CURVE25519_SHARED_SECRET
|
---|
| 1320 | #undef HAVE_CURVE25519_SHARED_SECRET
|
---|
| 1321 | #define HAVE_CURVE25519_SHARED_SECRET
|
---|
| 1322 | #endif
|
---|
| 1323 | #ifndef NO_CURVE25519_KEY_EXPORT
|
---|
| 1324 | #undef HAVE_CURVE25519_KEY_EXPORT
|
---|
| 1325 | #define HAVE_CURVE25519_KEY_EXPORT
|
---|
| 1326 | #endif
|
---|
| 1327 | #ifndef NO_CURVE25519_KEY_IMPORT
|
---|
| 1328 | #undef HAVE_CURVE25519_KEY_IMPORT
|
---|
| 1329 | #define HAVE_CURVE25519_KEY_IMPORT
|
---|
| 1330 | #endif
|
---|
| 1331 | #endif /* HAVE_CURVE25519 */
|
---|
| 1332 |
|
---|
| 1333 | /* Ed255519 Configs */
|
---|
| 1334 | #ifdef HAVE_ED25519
|
---|
| 1335 | /* By default enable sign, verify, key export and import */
|
---|
| 1336 | #ifndef NO_ED25519_SIGN
|
---|
| 1337 | #undef HAVE_ED25519_SIGN
|
---|
| 1338 | #define HAVE_ED25519_SIGN
|
---|
| 1339 | #endif
|
---|
| 1340 | #ifndef NO_ED25519_VERIFY
|
---|
| 1341 | #undef HAVE_ED25519_VERIFY
|
---|
| 1342 | #define HAVE_ED25519_VERIFY
|
---|
| 1343 | #endif
|
---|
| 1344 | #ifndef NO_ED25519_KEY_EXPORT
|
---|
| 1345 | #undef HAVE_ED25519_KEY_EXPORT
|
---|
| 1346 | #define HAVE_ED25519_KEY_EXPORT
|
---|
| 1347 | #endif
|
---|
| 1348 | #ifndef NO_ED25519_KEY_IMPORT
|
---|
| 1349 | #undef HAVE_ED25519_KEY_IMPORT
|
---|
| 1350 | #define HAVE_ED25519_KEY_IMPORT
|
---|
| 1351 | #endif
|
---|
| 1352 | #endif /* HAVE_ED25519 */
|
---|
| 1353 |
|
---|
| 1354 | /* AES Config */
|
---|
| 1355 | #ifndef NO_AES
|
---|
| 1356 | /* By default enable all AES key sizes, decryption and CBC */
|
---|
| 1357 | #ifndef AES_MAX_KEY_SIZE
|
---|
| 1358 | #undef AES_MAX_KEY_SIZE
|
---|
| 1359 | #define AES_MAX_KEY_SIZE 256
|
---|
| 1360 | #endif
|
---|
| 1361 | #ifndef NO_AES_DECRYPT
|
---|
| 1362 | #undef HAVE_AES_DECRYPT
|
---|
| 1363 | #define HAVE_AES_DECRYPT
|
---|
| 1364 | #endif
|
---|
| 1365 | #ifndef NO_AES_CBC
|
---|
| 1366 | #undef HAVE_AES_CBC
|
---|
| 1367 | #define HAVE_AES_CBC
|
---|
| 1368 | #else
|
---|
| 1369 | #ifndef WOLFCRYPT_ONLY
|
---|
| 1370 | #error "AES CBC is required for TLS and can only be disabled for WOLFCRYPT_ONLY builds"
|
---|
| 1371 | #endif
|
---|
| 1372 | #endif
|
---|
| 1373 | #ifdef WOLFSSL_AES_XTS
|
---|
| 1374 | /* AES-XTS makes calls to AES direct functions */
|
---|
| 1375 | #ifndef WOLFSSL_AES_DIRECT
|
---|
| 1376 | #define WOLFSSL_AES_DIRECT
|
---|
| 1377 | #endif
|
---|
| 1378 | #endif
|
---|
| 1379 | #endif
|
---|
| 1380 |
|
---|
| 1381 | /* if desktop type system and fastmath increase default max bits */
|
---|
| 1382 | #ifdef WOLFSSL_X86_64_BUILD
|
---|
| 1383 | #ifdef USE_FAST_MATH
|
---|
| 1384 | #ifndef FP_MAX_BITS
|
---|
| 1385 | #define FP_MAX_BITS 8192
|
---|
| 1386 | #endif
|
---|
| 1387 | #endif
|
---|
| 1388 | #endif
|
---|
| 1389 |
|
---|
| 1390 | /* If using the max strength build, ensure OLD TLS is disabled. */
|
---|
| 1391 | #ifdef WOLFSSL_MAX_STRENGTH
|
---|
| 1392 | #undef NO_OLD_TLS
|
---|
| 1393 | #define NO_OLD_TLS
|
---|
| 1394 | #endif
|
---|
| 1395 |
|
---|
| 1396 |
|
---|
| 1397 | /* Default AES minimum auth tag sz, allow user to override */
|
---|
| 1398 | #ifndef WOLFSSL_MIN_AUTH_TAG_SZ
|
---|
| 1399 | #define WOLFSSL_MIN_AUTH_TAG_SZ 12
|
---|
| 1400 | #endif
|
---|
| 1401 |
|
---|
| 1402 |
|
---|
| 1403 | /* sniffer requires:
|
---|
| 1404 | * static RSA cipher suites
|
---|
| 1405 | * session stats and peak stats
|
---|
| 1406 | */
|
---|
| 1407 | #ifdef WOLFSSL_SNIFFER
|
---|
| 1408 | #ifndef WOLFSSL_STATIC_RSA
|
---|
| 1409 | #define WOLFSSL_STATIC_RSA
|
---|
| 1410 | #endif
|
---|
| 1411 | #ifndef WOLFSSL_SESSION_STATS
|
---|
| 1412 | #define WOLFSSL_SESSION_STATS
|
---|
| 1413 | #endif
|
---|
| 1414 | #ifndef WOLFSSL_PEAK_SESSIONS
|
---|
| 1415 | #define WOLFSSL_PEAK_SESSIONS
|
---|
| 1416 | #endif
|
---|
| 1417 | #endif
|
---|
| 1418 |
|
---|
| 1419 | /* Decode Public Key extras on by default, user can turn off with
|
---|
| 1420 | * WOLFSSL_NO_DECODE_EXTRA */
|
---|
| 1421 | #ifndef WOLFSSL_NO_DECODE_EXTRA
|
---|
| 1422 | #ifndef RSA_DECODE_EXTRA
|
---|
| 1423 | #define RSA_DECODE_EXTRA
|
---|
| 1424 | #endif
|
---|
| 1425 | #ifndef ECC_DECODE_EXTRA
|
---|
| 1426 | #define ECC_DECODE_EXTRA
|
---|
| 1427 | #endif
|
---|
| 1428 | #endif
|
---|
| 1429 |
|
---|
| 1430 | /* C Sharp wrapper defines */
|
---|
| 1431 | #ifdef HAVE_CSHARP
|
---|
| 1432 | #ifndef WOLFSSL_DTLS
|
---|
| 1433 | #define WOLFSSL_DTLS
|
---|
| 1434 | #endif
|
---|
| 1435 | #undef NO_PSK
|
---|
| 1436 | #undef NO_SHA256
|
---|
| 1437 | #undef NO_DH
|
---|
| 1438 | #endif
|
---|
| 1439 |
|
---|
| 1440 | /* Asynchronous Crypto */
|
---|
| 1441 | #ifdef WOLFSSL_ASYNC_CRYPT
|
---|
| 1442 | /* Make sure wolf events are enabled */
|
---|
| 1443 | #undef HAVE_WOLF_EVENT
|
---|
| 1444 | #define HAVE_WOLF_EVENT
|
---|
| 1445 |
|
---|
| 1446 | #ifdef WOLFSSL_ASYNC_CRYPT_TEST
|
---|
| 1447 | #define WC_ASYNC_DEV_SIZE 320+24
|
---|
| 1448 | #else
|
---|
| 1449 | #define WC_ASYNC_DEV_SIZE 320
|
---|
| 1450 | #endif
|
---|
| 1451 |
|
---|
| 1452 | #if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \
|
---|
| 1453 | !defined(WOLFSSL_ASYNC_CRYPT_TEST)
|
---|
| 1454 | #error No async hardware defined with WOLFSSL_ASYNC_CRYPT!
|
---|
| 1455 | #endif
|
---|
| 1456 |
|
---|
| 1457 | /* Enable ECC_CACHE_CURVE for ASYNC */
|
---|
| 1458 | #if !defined(ECC_CACHE_CURVE)
|
---|
| 1459 | #define ECC_CACHE_CURVE
|
---|
| 1460 | #endif
|
---|
| 1461 | #endif /* WOLFSSL_ASYNC_CRYPT */
|
---|
| 1462 | #ifndef WC_ASYNC_DEV_SIZE
|
---|
| 1463 | #define WC_ASYNC_DEV_SIZE 0
|
---|
| 1464 | #endif
|
---|
| 1465 |
|
---|
| 1466 | /* leantls checks */
|
---|
| 1467 | #ifdef WOLFSSL_LEANTLS
|
---|
| 1468 | #ifndef HAVE_ECC
|
---|
| 1469 | #error leantls build needs ECC
|
---|
| 1470 | #endif
|
---|
| 1471 | #endif /* WOLFSSL_LEANTLS*/
|
---|
| 1472 |
|
---|
| 1473 | /* restriction with static memory */
|
---|
| 1474 | #ifdef WOLFSSL_STATIC_MEMORY
|
---|
| 1475 | #if defined(HAVE_IO_POOL) || defined(XMALLOC_USER) || defined(NO_WOLFSSL_MEMORY)
|
---|
| 1476 | #error static memory cannot be used with HAVE_IO_POOL, XMALLOC_USER or NO_WOLFSSL_MEMORY
|
---|
| 1477 | #endif
|
---|
| 1478 | #if !defined(USE_FAST_MATH) && !defined(NO_BIG_INT)
|
---|
| 1479 | #error static memory requires fast math please define USE_FAST_MATH
|
---|
| 1480 | #endif
|
---|
| 1481 | #ifdef WOLFSSL_SMALL_STACK
|
---|
| 1482 | #error static memory does not support small stack please undefine
|
---|
| 1483 | #endif
|
---|
| 1484 | #endif /* WOLFSSL_STATIC_MEMORY */
|
---|
| 1485 |
|
---|
| 1486 | #ifdef HAVE_AES_KEYWRAP
|
---|
| 1487 | #ifndef WOLFSSL_AES_DIRECT
|
---|
| 1488 | #error AES key wrap requires AES direct please define WOLFSSL_AES_DIRECT
|
---|
| 1489 | #endif
|
---|
| 1490 | #endif
|
---|
| 1491 |
|
---|
| 1492 | #ifdef HAVE_PKCS7
|
---|
| 1493 | #ifndef HAVE_AES_KEYWRAP
|
---|
| 1494 | #error PKCS7 requires AES key wrap please define HAVE_AES_KEYWRAP
|
---|
| 1495 | #endif
|
---|
| 1496 | #ifndef HAVE_X963_KDF
|
---|
| 1497 | #error PKCS7 requires X963 KDF please define HAVE_X963_KDF
|
---|
| 1498 | #endif
|
---|
| 1499 | #endif
|
---|
| 1500 |
|
---|
| 1501 | #if !defined(WOLFCRYPT_ONLY) && !defined(NO_OLD_TLS) && \
|
---|
| 1502 | (defined(NO_SHA) || defined(NO_MD5))
|
---|
| 1503 | #error old TLS requires MD5 and SHA
|
---|
| 1504 | #endif
|
---|
| 1505 |
|
---|
| 1506 | /* for backwards compatibility */
|
---|
| 1507 | #if defined(TEST_IPV6) && !defined(WOLFSSL_IPV6)
|
---|
| 1508 | #define WOLFSSL_IPV6
|
---|
| 1509 | #endif
|
---|
| 1510 |
|
---|
| 1511 |
|
---|
| 1512 | /* Place any other flags or defines here */
|
---|
| 1513 |
|
---|
| 1514 | #if defined(WOLFSSL_MYSQL_COMPATIBLE) && defined(_WIN32) \
|
---|
| 1515 | && defined(HAVE_GMTIME_R)
|
---|
| 1516 | #undef HAVE_GMTIME_R /* don't trust macro with windows */
|
---|
| 1517 | #endif /* WOLFSSL_MYSQL_COMPATIBLE */
|
---|
| 1518 |
|
---|
| 1519 | #if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
---|
| 1520 | #define SSL_OP_NO_COMPRESSION SSL_OP_NO_COMPRESSION
|
---|
| 1521 | #define OPENSSL_NO_ENGINE
|
---|
| 1522 | #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
|
---|
| 1523 | #ifndef OPENSSL_EXTRA
|
---|
| 1524 | #define OPENSSL_EXTRA
|
---|
| 1525 | #endif
|
---|
| 1526 | #ifndef HAVE_SESSION_TICKET
|
---|
| 1527 | #define HAVE_SESSION_TICKET
|
---|
| 1528 | #endif
|
---|
| 1529 | #ifndef HAVE_OCSP
|
---|
| 1530 | #define HAVE_OCSP
|
---|
| 1531 | #endif
|
---|
| 1532 | #ifndef KEEP_OUR_CERT
|
---|
| 1533 | #define KEEP_OUR_CERT
|
---|
| 1534 | #endif
|
---|
| 1535 | #ifndef HAVE_SNI
|
---|
| 1536 | #define HAVE_SNI
|
---|
| 1537 | #endif
|
---|
| 1538 | #endif
|
---|
| 1539 |
|
---|
| 1540 | #if defined(WOLFSSL_NGINX)
|
---|
| 1541 | #define SSL_CTRL_SET_TLSEXT_HOSTNAME
|
---|
| 1542 | #endif
|
---|
| 1543 |
|
---|
| 1544 | /* both CURVE and ED small math should be enabled */
|
---|
| 1545 | #ifdef CURVED25519_SMALL
|
---|
| 1546 | #define CURVE25519_SMALL
|
---|
| 1547 | #define ED25519_SMALL
|
---|
| 1548 | #endif
|
---|
| 1549 |
|
---|
| 1550 |
|
---|
| 1551 | #ifndef WOLFSSL_ALERT_COUNT_MAX
|
---|
| 1552 | #define WOLFSSL_ALERT_COUNT_MAX 5
|
---|
| 1553 | #endif
|
---|
| 1554 |
|
---|
| 1555 | /* warning for not using harden build options (default with ./configure) */
|
---|
| 1556 | #ifndef WC_NO_HARDEN
|
---|
| 1557 | #if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \
|
---|
| 1558 | (defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \
|
---|
| 1559 | (!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS))
|
---|
| 1560 |
|
---|
| 1561 | #ifndef _MSC_VER
|
---|
| 1562 | #warning "For timing resistance / side-channel attack prevention consider using harden options"
|
---|
| 1563 | #else
|
---|
| 1564 | #pragma message("Warning: For timing resistance / side-channel attack prevention consider using harden options")
|
---|
| 1565 | #endif
|
---|
| 1566 | #endif
|
---|
| 1567 | #endif
|
---|
| 1568 |
|
---|
| 1569 | #ifdef __cplusplus
|
---|
| 1570 | } /* extern "C" */
|
---|
| 1571 | #endif
|
---|
| 1572 |
|
---|
| 1573 | #endif
|
---|