wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers settings.h Source File

settings.h

00001 /* settings.h
00002  *
00003  * Copyright (C) 2006-2016 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 
00023 /* Place OS specific preprocessor flags, defines, includes here, will be
00024    included into every file because types.h includes it */
00025 
00026 
00027 #ifndef WOLF_CRYPT_SETTINGS_H
00028 #define WOLF_CRYPT_SETTINGS_H
00029 
00030 #ifdef __cplusplus
00031     extern "C" {
00032 #endif
00033 
00034 /* Uncomment next line if using IPHONE */
00035 /* #define IPHONE */
00036 
00037 /* Uncomment next line if using ThreadX */
00038 /* #define THREADX */
00039 
00040 /* Uncomment next line if using Micrium ucOS */
00041 /* #define MICRIUM */
00042 
00043 /* Uncomment next line if using Mbed */
00044 /* #define MBED */
00045 
00046 /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
00047 /* #define MICROCHIP_PIC32 */
00048 
00049 /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
00050 /* #define MICROCHIP_TCPIP_V5 */
00051 
00052 /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
00053 /* #define MICROCHIP_TCPIP */
00054 
00055 /* Uncomment next line if using PIC32MZ Crypto Engine */
00056 /* #define WOLFSSL_MICROCHIP_PIC32MZ */
00057 
00058 /* Uncomment next line if using FreeRTOS */
00059 /* #define FREERTOS */
00060 
00061 /* Uncomment next line if using FreeRTOS+ TCP */
00062 /* #define FREERTOS_TCP */
00063 
00064 /* Uncomment next line if using FreeRTOS Windows Simulator */
00065 /* #define FREERTOS_WINSIM */
00066 
00067 /* Uncomment next line if using RTIP */
00068 /* #define EBSNET */
00069 
00070 /* Uncomment next line if using lwip */
00071 /* #define WOLFSSL_LWIP */
00072 
00073 /* Uncomment next line if building wolfSSL for a game console */
00074 /* #define WOLFSSL_GAME_BUILD */
00075 
00076 /* Uncomment next line if building wolfSSL for LSR */
00077 /* #define WOLFSSL_LSR */
00078 
00079 /* Uncomment next line if building for Freescale Classic MQX/RTCS/MFS */
00080 /* #define FREESCALE_MQX */
00081 
00082 /* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
00083 /* #define FREESCALE_KSDK_MQX */
00084 
00085 /* Uncomment next line if building for Freescale KSDK Bare Metal */
00086 /* #define FREESCALE_KSDK_BM */
00087 
00088 /* Uncomment next line if building for Freescale KSDK FreeRTOS (old name FREESCALE_FREE_RTOS) */
00089 /* #define FREESCALE_KSDK_FREERTOS */
00090 
00091 /* Uncomment next line if using STM32F2 */
00092 /* #define WOLFSSL_STM32F2 */
00093 
00094 /* Uncomment next line if using QL SEP settings */
00095 /* #define WOLFSSL_QL */
00096 
00097 /* Uncomment next line if building for EROAD */
00098 /* #define WOLFSSL_EROAD */
00099 
00100 /* Uncomment next line if building for IAR EWARM */
00101 /* #define WOLFSSL_IAR_ARM */
00102 
00103 /* Uncomment next line if building for Rowley CrossWorks ARM */
00104 /* #define WOLFSSL_ROWLEY_ARM */
00105 
00106 /* Uncomment next line if using TI-RTOS settings */
00107 /* #define WOLFSSL_TIRTOS */
00108 
00109 /* Uncomment next line if building with PicoTCP */
00110 /* #define WOLFSSL_PICOTCP */
00111 
00112 /* Uncomment next line if building for PicoTCP demo bundle */
00113 /* #define WOLFSSL_PICOTCP_DEMO */
00114 
00115 /* Uncomment next line if building for uITRON4  */
00116 /* #define WOLFSSL_uITRON4 */
00117 
00118 /* Uncomment next line if building for uT-Kernel */
00119 /* #define WOLFSSL_uTKERNEL2 */
00120 
00121 /* Uncomment next line if using Max Strength build */
00122 /* #define WOLFSSL_MAX_STRENGTH */
00123 
00124 /* Uncomment next line if building for VxWorks */
00125 /* #define WOLFSSL_VXWORKS */
00126 
00127 /* Uncomment next line if building for Nordic nRF5x platofrm */
00128 /* #define WOLFSSL_NRF5x */
00129 
00130 /* Uncomment next line to enable deprecated less secure static DH suites */
00131 /* #define WOLFSSL_STATIC_DH */
00132 
00133 /* Uncomment next line to enable deprecated less secure static RSA suites */
00134 /* #define WOLFSSL_STATIC_RSA */
00135 
00136 /* Uncomment next line if building for ARDUINO */
00137 /* Uncomment both lines if building for ARDUINO on INTEL_GALILEO */
00138 /* #define WOLFSSL_ARDUINO */
00139 /* #define INTEL_GALILEO */
00140 
00141 /* Uncomment next line to enable asynchronous crypto WC_PENDING_E */
00142 /* #define WOLFSSL_ASYNC_CRYPT */
00143 
00144 /* Uncomment next line if building for uTasker */
00145 /* #define WOLFSSL_UTASKER */
00146 
00147 /* Uncomment next line if building for embOS */
00148 /* #define WOLFSSL_EMBOS */
00149 
00150 /* Uncomment next line if building for RIOT-OS */
00151 /* #define WOLFSSL_RIOT_OS */
00152 
00153 #include <wolfssl/wolfcrypt/visibility.h>
00154 #define WOLFSSL_USER_SETTINGS
00155 #ifdef WOLFSSL_USER_SETTINGS
00156     #include <user_settings.h>
00157 #endif
00158 
00159 
00160 /* make sure old RNG name is used with CTaoCrypt FIPS */
00161 #ifdef HAVE_FIPS
00162     #define WC_RNG RNG
00163     /* blinding adds API not available yet in FIPS mode */
00164     #undef WC_RSA_BLINDING
00165 #endif
00166 
00167 
00168 #ifdef IPHONE
00169     #define SIZEOF_LONG_LONG 8
00170 #endif
00171 
00172 #ifdef THREADX
00173     #define SIZEOF_LONG_LONG 8
00174 #endif
00175 
00176 #ifdef HAVE_NETX
00177     #include "nx_api.h"
00178 #endif
00179 
00180 #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
00181     #define WOLFSSL_LWIP
00182     #define NO_WRITEV
00183     #define SINGLE_THREADED
00184     #define WOLFSSL_USER_IO
00185     #define NO_FILESYSTEM
00186 #endif
00187 
00188 #if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
00189     #define NO_MAIN_DRIVER
00190     #define SINGLE_THREADED
00191     #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
00192         #define USE_CERT_BUFFERS_1024
00193     #endif
00194     #define BENCH_EMBEDDED
00195     #define NO_FILESYSTEM
00196     #define NO_WRITEV
00197     #define WOLFSSL_USER_IO
00198     #define BENCH_EMBEDDED
00199 #endif
00200 
00201 #ifdef MICROCHIP_PIC32
00202     /* #define WOLFSSL_MICROCHIP_PIC32MZ */
00203     #define SIZEOF_LONG_LONG 8
00204     #define SINGLE_THREADED
00205     #define WOLFSSL_USER_IO
00206     #define NO_WRITEV
00207     #define NO_DEV_RANDOM
00208     #define NO_FILESYSTEM
00209     #define USE_FAST_MATH
00210     #define TFM_TIMING_RESISTANT
00211     #define NEED_AES_TABLES
00212     #define WOLFSSL_HAVE_MIN
00213 #endif
00214 
00215 #ifdef WOLFSSL_MICROCHIP_PIC32MZ
00216     #define WOLFSSL_PIC32MZ_CE
00217     #define WOLFSSL_PIC32MZ_CRYPT
00218     #define HAVE_AES_ENGINE
00219     #define WOLFSSL_PIC32MZ_RNG
00220     /* #define WOLFSSL_PIC32MZ_HASH */
00221     #define WOLFSSL_AES_COUNTER
00222     #define HAVE_AESGCM
00223     #define NO_BIG_INT
00224 #endif
00225 
00226 #ifdef MICROCHIP_TCPIP_V5
00227     /* include timer functions */
00228     #include "TCPIP Stack/TCPIP.h"
00229 #endif
00230 
00231 #ifdef MICROCHIP_TCPIP
00232     /* include timer, NTP functions */
00233     #ifdef MICROCHIP_MPLAB_HARMONY
00234         #include "tcpip/tcpip.h"
00235     #else
00236         #include "system/system_services.h"
00237         #include "tcpip/sntp.h"
00238     #endif
00239 #endif
00240 
00241 #ifdef MBED
00242     #define WOLFSSL_USER_IO
00243     #define NO_FILESYSTEM
00244     #define NO_CERT
00245     #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
00246         #define USE_CERT_BUFFERS_1024
00247     #endif
00248     #define NO_WRITEV
00249     #define NO_DEV_RANDOM
00250     #define NO_SHA512
00251     #define NO_DH
00252     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00253     /* WOLFSSL_DH_CONST */
00254     #define NO_DSA
00255     #define NO_HC128
00256     #define HAVE_ECC
00257     #define NO_SESSION_CACHE
00258     #define WOLFSSL_CMSIS_RTOS
00259 #endif
00260 
00261 
00262 #ifdef WOLFSSL_EROAD
00263     #define FREESCALE_MQX
00264     #define FREESCALE_MMCAU
00265     #define SINGLE_THREADED
00266     #define NO_STDIO_FILESYSTEM
00267     #define WOLFSSL_LEANPSK
00268     #define HAVE_NULL_CIPHER
00269     #define NO_OLD_TLS
00270     #define NO_ASN
00271     #define NO_BIG_INT
00272     #define NO_RSA
00273     #define NO_DSA
00274     #define NO_DH
00275     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00276     /* WOLFSSL_DH_CONST */
00277     #define NO_CERTS
00278     #define NO_PWDBASED
00279     #define NO_DES3
00280     #define NO_MD4
00281     #define NO_RC4
00282     #define NO_MD5
00283     #define NO_SESSION_CACHE
00284     #define NO_MAIN_DRIVER
00285 #endif
00286 
00287 #ifdef WOLFSSL_PICOTCP
00288     #ifndef errno
00289         #define errno pico_err
00290     #endif
00291     #include "pico_defines.h"
00292     #include "pico_stack.h"
00293     #include "pico_constants.h"
00294     #include "pico_protocol.h"
00295     #define CUSTOM_RAND_GENERATE pico_rand
00296 #endif
00297 
00298 #ifdef WOLFSSL_PICOTCP_DEMO
00299     #define WOLFSSL_STM32
00300     #define USE_FAST_MATH
00301     #define TFM_TIMING_RESISTANT
00302     #define XMALLOC(s, h, type)  PICO_ZALLOC((s))
00303     #define XFREE(p, h, type)    PICO_FREE((p))
00304     #define SINGLE_THREADED
00305     #define NO_WRITEV
00306     #define WOLFSSL_USER_IO
00307     #define NO_DEV_RANDOM
00308     #define NO_FILESYSTEM
00309 #endif
00310 
00311 #ifdef FREERTOS_WINSIM
00312     #define FREERTOS
00313     #define USE_WINDOWS_API
00314 #endif
00315 
00316 
00317 #ifdef WOLFSSL_VXWORKS
00318     /* VxWorks simulator incorrectly detects building for i386 */
00319     #ifdef VXWORKS_SIM
00320         #define TFM_NO_ASM
00321     #endif
00322     #define WOLFSSL_PTHREADS
00323     #define WOLFSSL_HAVE_MIN
00324     #define USE_FAST_MATH
00325     #define TFM_TIMING_RESISTANT
00326     #define NO_MAIN_DRIVER
00327     #define NO_DEV_RANDOM
00328     #define NO_WRITEV
00329 #endif
00330 
00331 
00332 #ifdef WOLFSSL_ARDUINO
00333     #define NO_WRITEV
00334     #define NO_WOLFSSL_DIR
00335     #define SINGLE_THREADED
00336     #define NO_DEV_RANDOM
00337     #ifndef INTEL_GALILEO /* Galileo has time.h compatibility */
00338         #define TIME_OVERRIDES /* must define XTIME and XGMTIME externally */
00339     #endif
00340     #define WOLFSSL_USER_IO
00341     #define HAVE_ECC
00342     #define NO_DH
00343     #define NO_SESSION_CACHE
00344     #define USE_SLOW_SHA
00345     #define NO_WOLFSSL_SERVER
00346     #define NO_ERROR_STRINGS
00347 #endif
00348 
00349 
00350 #ifdef WOLFSSL_UTASKER
00351     /* uTasker configuration - used for fnRandom() */
00352     #include "config.h"
00353 
00354     #define SINGLE_THREADED
00355     #define NO_WOLFSSL_DIR
00356     #define WOLFSSL_HAVE_MIN
00357     #define NO_WRITEV
00358 
00359     #define HAVE_ECC
00360     #define ALT_ECC_SIZE
00361     #define USE_FAST_MATH
00362     #define TFM_TIMING_RESISTANT
00363     #define ECC_TIMING_RESISTANT
00364 
00365     /* used in wolfCrypt test */
00366     #define NO_MAIN_DRIVER
00367     #define USE_CERT_BUFFERS_2048
00368 
00369     /* uTasker port uses RAW sockets, use I/O callbacks
00370      * See wolfSSL uTasker example for sample callbacks */
00371     #define WOLFSSL_USER_IO
00372 
00373     /* uTasker filesystem not ported  */
00374     #define NO_FILESYSTEM
00375 
00376     /* uTasker RNG is abstracted, calls HW RNG when available */
00377     #define CUSTOM_RAND_GENERATE    fnRandom
00378     #define CUSTOM_RAND_TYPE        unsigned short
00379 
00380     /* user needs to define XTIME to function that provides
00381      * seconds since Unix epoch */
00382     #ifndef XTIME
00383         #error XTIME must be defined in wolfSSL settings.h
00384         /* #define XTIME fnSecondsSinceEpoch */
00385     #endif
00386 
00387     /* use uTasker std library replacements where available */
00388     #define STRING_USER
00389     #define XMEMCPY(d,s,l)         uMemcpy((d),(s),(l))
00390     #define XMEMSET(b,c,l)         uMemset((b),(c),(l))
00391     #define XMEMCMP(s1,s2,n)       uMemcmp((s1),(s2),(n))
00392     #define XMEMMOVE(d,s,l)        memmove((d),(s),(l))
00393 
00394     #define XSTRLEN(s1)            uStrlen((s1))
00395     #define XSTRNCPY(s1,s2,n)      strncpy((s1),(s2),(n))
00396     #define XSTRSTR(s1,s2)         strstr((s1),(s2))
00397     #define XSTRNSTR(s1,s2,n)      mystrnstr((s1),(s2),(n))
00398     #define XSTRNCMP(s1,s2,n)      strncmp((s1),(s2),(n))
00399     #define XSTRNCAT(s1,s2,n)      strncat((s1),(s2),(n))
00400     #define XSTRNCASECMP(s1,s2,n)  _strnicmp((s1),(s2),(n))
00401     #if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
00402         #define XSTRTOK            strtok_r
00403     #endif
00404 #endif
00405 
00406 #ifdef WOLFSSL_EMBOS
00407     #define NO_FILESYSTEM           /* Not ported at this time */
00408     #define USE_CERT_BUFFERS_2048   /* use when NO_FILESYSTEM */
00409     #define NO_MAIN_DRIVER
00410     #define NO_RC4
00411     #define SINGLE_THREADED         /* Not ported at this time */
00412 #endif
00413 
00414 #ifdef WOLFSSL_RIOT_OS
00415     #define NO_WRITEV
00416     #define TFM_NO_ASM
00417     #define USE_FAST_MATH
00418     #define NO_FILE_SYSTEM
00419     #define USE_CERT_BUFFERS_2048
00420     #define HAVE_ECC
00421 #endif
00422 
00423 #ifdef WOLFSSL_NRF5x
00424         #define SIZEOF_LONG 4
00425         #define SIZEOF_LONG_LONG 8
00426         #define NO_ASN_TIME
00427         #define NO_DEV_RANDOM
00428         #define NO_FILESYSTEM
00429         #define NO_MAIN_DRIVER
00430         #define NO_WRITEV
00431         #define SINGLE_THREADED
00432         #define USE_FAST_MATH
00433         #define TFM_TIMING_RESISTANT
00434         #define USE_WOLFSSL_MEMORY
00435         #define WOLFSSL_NRF51
00436         #define WOLFSSL_USER_IO
00437         #define NO_SESSION_CACHE
00438 #endif
00439 
00440 /* Micrium will use Visual Studio for compilation but not the Win32 API */
00441 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
00442     !defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
00443     !defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
00444     #define USE_WINDOWS_API
00445 #endif
00446 
00447 #if defined(WOLFSSL_uITRON4)
00448 
00449 #define XMALLOC_USER
00450 #include <stddef.h>
00451 #define ITRON_POOL_SIZE 1024*20
00452 extern int uITRON4_minit(size_t poolsz) ;
00453 extern void *uITRON4_malloc(size_t sz) ;
00454 extern void *uITRON4_realloc(void *p, size_t sz) ;
00455 extern void uITRON4_free(void *p) ;
00456 
00457 #define XMALLOC(sz, heap, type)     uITRON4_malloc(sz)
00458 #define XREALLOC(p, sz, heap, type) uITRON4_realloc(p, sz)
00459 #define XFREE(p, heap, type)        uITRON4_free(p)
00460 #endif
00461 
00462 #if defined(WOLFSSL_uTKERNEL2)
00463   #ifndef NO_TKERNEL_MEM_POOL
00464     #define XMALLOC_OVERRIDE
00465     int   uTKernel_init_mpool(unsigned int sz); /* initializing malloc pool */
00466     void* uTKernel_malloc(unsigned int sz);
00467     void* uTKernel_realloc(void *p, unsigned int sz);
00468     void  uTKernel_free(void *p);
00469     #define XMALLOC(s, h, type)  uTKernel_malloc((s))
00470     #define XREALLOC(p, n, h, t) uTKernel_realloc((p), (n))
00471     #define XFREE(p, h, type)    uTKernel_free((p))
00472   #endif
00473 
00474   #ifndef NO_STDIO_FGETS_REMAP
00475     #include <stdio.h>
00476     #include "tm/tmonitor.h"
00477 
00478     /* static char* gets(char *buff); */
00479     static char* fgets(char *buff, int sz, FILE *fp) {
00480         char * p = buff;
00481         *p = '\0';
00482         while (1) {
00483             *p = tm_getchar(-1);
00484             tm_putchar(*p);
00485             if (*p == '\r') {
00486                 tm_putchar('\n');
00487                 *p = '\0';
00488                 break;
00489             }
00490             p++;
00491         }
00492         return buff;
00493     }
00494   #endif /* !NO_STDIO_FGETS_REMAP */
00495 #endif
00496 
00497 
00498 #if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER)
00499     #include <stdlib.h>
00500     #define XMALLOC(s, h, type)  malloc((s))
00501     #define XFREE(p, h, type)    free((p))
00502     #define XREALLOC(p, n, h, t) realloc((p), (n))
00503 #endif
00504 
00505 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
00506     #undef  XMALLOC
00507     #define XMALLOC     yaXMALLOC
00508     #undef  XFREE
00509     #define XFREE       yaXFREE
00510     #undef  XREALLOC
00511     #define XREALLOC    yaXREALLOC
00512 #endif
00513 
00514 
00515 #ifdef FREERTOS
00516     #include "FreeRTOS.h"
00517 
00518     /* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */
00519     #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
00520         #define XMALLOC(s, h, type)  pvPortMalloc((s))
00521         #define XFREE(p, h, type)    vPortFree((p))
00522     #endif
00523 
00524     #ifndef NO_WRITEV
00525         #define NO_WRITEV
00526     #endif
00527     #ifndef HAVE_SHA512
00528         #ifndef NO_SHA512
00529             #define NO_SHA512
00530         #endif
00531     #endif
00532     #ifndef HAVE_DH
00533         #ifndef NO_DH
00534             #define NO_DH
00535         #endif
00536     #endif
00537     #ifndef NO_DSA
00538         #define NO_DSA
00539     #endif
00540     #ifndef NO_HC128
00541         #define NO_HC128
00542     #endif
00543 
00544     #ifndef SINGLE_THREADED
00545         #include "semphr.h"
00546     #endif
00547 #endif
00548 
00549 #ifdef FREERTOS_TCP
00550 
00551 #if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER)
00552 #define XMALLOC(s, h, type)  pvPortMalloc((s))
00553 #define XFREE(p, h, type)    vPortFree((p))
00554 #endif
00555 
00556 #define WOLFSSL_GENSEED_FORTEST
00557 
00558 #define NO_WOLFSSL_DIR
00559 #define NO_WRITEV
00560 #define USE_FAST_MATH
00561 #define TFM_TIMING_RESISTANT
00562 #define NO_MAIN_DRIVER
00563 
00564 #endif
00565 
00566 #ifdef WOLFSSL_TIRTOS
00567     #define SIZEOF_LONG_LONG 8
00568     #define NO_WRITEV
00569     #define NO_WOLFSSL_DIR
00570     #define USE_FAST_MATH
00571     #define TFM_TIMING_RESISTANT
00572     #define NO_DEV_RANDOM
00573     #define NO_FILESYSTEM
00574     #define USE_CERT_BUFFERS_2048
00575     #define NO_ERROR_STRINGS
00576     #define USER_TIME
00577     #define HAVE_ECC
00578     #define HAVE_ALPN
00579     #define HAVE_TLS_EXTENSIONS
00580     #define HAVE_AESGCM
00581     #define HAVE_SUPPORTED_CURVES
00582     #define ALT_ECC_SIZE
00583 
00584     #ifdef __IAR_SYSTEMS_ICC__
00585         #pragma diag_suppress=Pa089
00586     #elif !defined(__GNUC__)
00587         /* Suppress the sslpro warning */
00588         #pragma diag_suppress=11
00589     #endif
00590 
00591     #include <ti/sysbios/hal/Seconds.h>
00592 #endif
00593 
00594 #ifdef EBSNET
00595     #include "rtip.h"
00596 
00597     /* #define DEBUG_WOLFSSL */
00598     #define NO_WOLFSSL_DIR  /* tbd */
00599 
00600     #if (POLLOS)
00601         #define SINGLE_THREADED
00602     #endif
00603 
00604     #if (RTPLATFORM)
00605         #if (!RTP_LITTLE_ENDIAN)
00606             #define BIG_ENDIAN_ORDER
00607         #endif
00608     #else
00609         #if (!KS_LITTLE_ENDIAN)
00610             #define BIG_ENDIAN_ORDER
00611         #endif
00612     #endif
00613 
00614     #if (WINMSP3)
00615         #undef SIZEOF_LONG
00616         #define SIZEOF_LONG_LONG 8
00617     #else
00618         #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
00619     #endif
00620 
00621     #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
00622     #define XFREE(p, h, type) (rtp_free(p))
00623     #define XREALLOC(p, n, h, t) realloc((p), (n))
00624 
00625 #endif /* EBSNET */
00626 
00627 #ifdef WOLFSSL_GAME_BUILD
00628     #define SIZEOF_LONG_LONG 8
00629     #if defined(__PPU) || defined(__XENON)
00630         #define BIG_ENDIAN_ORDER
00631     #endif
00632 #endif
00633 
00634 #ifdef WOLFSSL_LSR
00635     #define HAVE_WEBSERVER
00636     #define SIZEOF_LONG_LONG 8
00637     #define WOLFSSL_LOW_MEMORY
00638     #define NO_WRITEV
00639     #define NO_SHA512
00640     #define NO_DH
00641     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00642     /* WOLFSSL_DH_CONST */
00643     #define NO_DSA
00644     #define NO_HC128
00645     #define NO_DEV_RANDOM
00646     #define NO_WOLFSSL_DIR
00647     #define NO_RABBIT
00648     #ifndef NO_FILESYSTEM
00649         #define LSR_FS
00650         #include "inc/hw_types.h"
00651         #include "fs.h"
00652     #endif
00653     #define WOLFSSL_LWIP
00654     #include <errno.h>  /* for tcp errno */
00655     #define WOLFSSL_SAFERTOS
00656     #if defined(__IAR_SYSTEMS_ICC__)
00657         /* enum uses enum */
00658         #pragma diag_suppress=Pa089
00659     #endif
00660 #endif
00661 
00662 #ifdef WOLFSSL_SAFERTOS
00663     #ifndef SINGLE_THREADED
00664         #include "SafeRTOS/semphr.h"
00665     #endif
00666 
00667     #include "SafeRTOS/heap.h"
00668     #define XMALLOC(s, h, type)  pvPortMalloc((s))
00669     #define XFREE(p, h, type)    vPortFree((p))
00670     #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
00671 #endif
00672 
00673 #ifdef WOLFSSL_LOW_MEMORY
00674     #undef  RSA_LOW_MEM
00675     #define RSA_LOW_MEM
00676     #undef  WOLFSSL_SMALL_STACK
00677     #define WOLFSSL_SMALL_STACK
00678     #undef  TFM_TIMING_RESISTANT
00679     #define TFM_TIMING_RESISTANT
00680 #endif
00681 
00682 #ifdef FREESCALE_MQX
00683     #define FREESCALE_COMMON
00684     #include "mqx.h"
00685     #ifndef NO_FILESYSTEM
00686         #include "mfs.h"
00687         #if MQX_USE_IO_OLD
00688             #include "fio.h"
00689         #else
00690             #include "nio.h"
00691         #endif
00692     #endif
00693     #ifndef SINGLE_THREADED
00694         #include "mutex.h"
00695     #endif
00696 
00697     #define XMALLOC(s, h, t)    (void *)_mem_alloc_system((s))
00698     #define XFREE(p, h, t)      {void* xp = (p); if ((xp)) _mem_free((xp));}
00699     /* Note: MQX has no realloc, using fastmath above */
00700 #endif
00701 
00702 #ifdef FREESCALE_KSDK_MQX
00703     #define FREESCALE_COMMON
00704     #include <mqx.h>
00705     #ifndef NO_FILESYSTEM
00706         #if MQX_USE_IO_OLD
00707             #include <fio.h>
00708         #else
00709             #include <stdio.h>
00710             #include <nio.h>
00711         #endif
00712     #endif
00713     #ifndef SINGLE_THREADED
00714         #include <mutex.h>
00715     #endif
00716 
00717     #define XMALLOC(s, h, t)    (void *)_mem_alloc_system((s))
00718     #define XFREE(p, h, t)      {void* xp = (p); if ((xp)) _mem_free((xp));}
00719     #define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
00720 
00721     #define MQX_FILE_PTR FILE *
00722     #define IO_SEEK_SET  SEEK_SET
00723     #define IO_SEEK_END  SEEK_END
00724 #endif /* FREESCALE_KSDK_MQX */
00725 
00726 #if defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
00727     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00728     /* WOLFSSL_DH_CONST */
00729     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00730     /* WOLFSSL_DH_CONST */
00731     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00732     /* WOLFSSL_DH_CONST */
00733     #define NO_FILESYSTEM
00734     #define WOLFSSL_CRYPT_HW_MUTEX 1
00735 
00736     #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
00737         #define XMALLOC(s, h, type)  pvPortMalloc((s))
00738         #define XFREE(p, h, type)    vPortFree((p))
00739     #endif
00740 
00741     //#define USER_TICKS
00742     /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
00743     /* WOLFSSL_DH_CONST */
00744     #define WOLFSSL_LWIP
00745     #define FREERTOS_TCP
00746 
00747     #define FREESCALE_FREE_RTOS
00748     #define FREERTOS_SOCKET_ERROR ( -1 )
00749     #define FREERTOS_EWOULDBLOCK ( -2 )
00750     #define FREERTOS_EINVAL ( -4 )
00751     #define FREERTOS_EADDRNOTAVAIL ( -5 )
00752     #define FREERTOS_EADDRINUSE ( -6 )
00753     #define FREERTOS_ENOBUFS ( -7 )
00754     #define FREERTOS_ENOPROTOOPT ( -8 )
00755 #endif /* FREESCALE_FREE_RTOS || FREESCALE_KSDK_FREERTOS */
00756 
00757 #ifdef FREESCALE_KSDK_BM
00758     #define FREESCALE_COMMON
00759     #define WOLFSSL_USER_IO
00760     #define SINGLE_THREADED
00761     #define NO_FILESYSTEM
00762     #ifndef TIME_OVERRIDES
00763         #define USER_TICKS
00764     #endif
00765 #endif /* FREESCALE_KSDK_BM */
00766 
00767 #ifdef FREESCALE_COMMON
00768     #define SIZEOF_LONG_LONG 8
00769 
00770     /* disable features */
00771     #undef  NO_WRITEV
00772     #define NO_WRITEV
00773     #undef  NO_DEV_RANDOM
00774     #define NO_DEV_RANDOM
00775     #undef  NO_RABBIT
00776     #define NO_RABBIT
00777     #undef  NO_WOLFSSL_DIR
00778     #define NO_WOLFSSL_DIR
00779     #undef  NO_RC4
00780     #define NO_RC4
00781 
00782     /* enable features */
00783     #undef  USE_FAST_MATH
00784     #define USE_FAST_MATH
00785 
00786     #define USE_CERT_BUFFERS_2048
00787     #define BENCH_EMBEDDED
00788 
00789     #define TFM_TIMING_RESISTANT
00790     #define ECC_TIMING_RESISTANT
00791 
00792     #undef  HAVE_ECC
00793     #define HAVE_ECC
00794     #ifndef NO_AES
00795         #undef  HAVE_AESCCM
00796         #define HAVE_AESCCM
00797         #undef  HAVE_AESGCM
00798         #define HAVE_AESGCM
00799         #undef  WOLFSSL_AES_COUNTER
00800         #define WOLFSSL_AES_COUNTER
00801         #undef  WOLFSSL_AES_DIRECT
00802         #define WOLFSSL_AES_DIRECT
00803     #endif
00804 
00805     #ifdef FREESCALE_KSDK_1_3
00806         #include "fsl_device_registers.h"
00807     #else
00808         #include "fsl_common.h"
00809     #endif
00810 
00811     /* random seed */
00812     #define NO_OLD_RNGNAME
00813     #if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0)
00814         #define FREESCALE_KSDK_2_0_TRNG
00815     #elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0)
00816         #ifdef FREESCALE_KSDK_1_3
00817             #include "fsl_rnga_driver.h"
00818             #define FREESCALE_RNGA
00819             #define RNGA_INSTANCE (0)
00820         #else
00821             #define FREESCALE_KSDK_2_0_RNGA
00822         #endif
00823     #elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) && !defined(FREESCALE_KSDK_FREERTOS)
00824         #define FREESCALE_RNGA
00825         #define RNGA_INSTANCE (0)
00826         /* defaulting to K70 RNGA, user should change if different */
00827         /* #define FREESCALE_K53_RNGB */
00828         #define FREESCALE_K70_RNGA
00829     #endif
00830 
00831     /* HW crypto */
00832     /* automatic enable based on Kinetis feature */
00833     /* if case manual selection is required, for example for benchmarking purposes,
00834      * just define FREESCALE_USE_MMCAU or FREESCALE_USE_LTC or none of these two macros (for software only)
00835      * both can be enabled simultaneously as LTC has priority over MMCAU in source code.
00836      */
00837     /* #define FSL_HW_CRYPTO_MANUAL_SELECTION */
00838     #ifndef FSL_HW_CRYPTO_MANUAL_SELECTION
00839         #if defined(FSL_FEATURE_SOC_MMCAU_COUNT) && FSL_FEATURE_SOC_MMCAU_COUNT
00840             #define FREESCALE_USE_MMCAU
00841         #endif
00842 
00843         #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
00844             #define FREESCALE_USE_LTC
00845         #endif
00846     #else
00847         /* #define FREESCALE_USE_MMCAU */
00848         /* #define FREESCALE_USE_LTC */
00849     #endif
00850 #endif /* FREESCALE_COMMON */
00851 
00852 #ifdef FREESCALE_USE_MMCAU
00853     /* AES and DES */
00854     #define FREESCALE_MMCAU
00855     /* MD5, SHA-1 and SHA-256 */
00856     #define FREESCALE_MMCAU_SHA
00857 #endif /* FREESCALE_USE_MMCAU */
00858 
00859 #ifdef FREESCALE_USE_LTC
00860     #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
00861         #define FREESCALE_LTC
00862         #define LTC_BASE LTC0
00863 
00864         #if defined(FSL_FEATURE_LTC_HAS_DES) && FSL_FEATURE_LTC_HAS_DES
00865             #define FREESCALE_LTC_DES
00866         #endif
00867 
00868         #if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM
00869             #define FREESCALE_LTC_AES_GCM
00870         #endif
00871 
00872         #if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA
00873             #define FREESCALE_LTC_SHA
00874         #endif
00875 
00876         #if defined(FSL_FEATURE_LTC_HAS_PKHA) && FSL_FEATURE_LTC_HAS_PKHA
00877             #define FREESCALE_LTC_ECC
00878             #define FREESCALE_LTC_TFM
00879 
00880             /* the LTC PKHA hardware limit is 2048 bits (256 bytes) for integer arithmetic.
00881                the LTC_MAX_INT_BYTES defines the size of local variables that hold big integers. */
00882             #ifndef LTC_MAX_INT_BYTES
00883                 #define LTC_MAX_INT_BYTES (256)
00884             #endif
00885 
00886             /* This FREESCALE_LTC_TFM_RSA_4096_ENABLE macro can be defined.
00887              * In such a case both software and hardware algorithm
00888              * for TFM is linked in. The decision for which algorithm is used is determined at runtime
00889              * from size of inputs. If inputs and result can fit into LTC (see LTC_MAX_INT_BYTES)
00890              * then we call hardware algorithm, otherwise we call software algorithm.
00891              *
00892              * Chinese reminder theorem is used to break RSA 4096 exponentiations (both public and private key)
00893              * into several computations with 2048-bit modulus and exponents.
00894              */
00895             /* #define FREESCALE_LTC_TFM_RSA_4096_ENABLE */
00896 
00897             /* ECC-384, ECC-256, ECC-224 and ECC-192 have been enabled with LTC PKHA acceleration */
00898             #ifdef HAVE_ECC
00899                 #undef  ECC_TIMING_RESISTANT
00900                 #define ECC_TIMING_RESISTANT
00901 
00902                 /* the LTC PKHA hardware limit is 512 bits (64 bytes) for ECC.
00903                    the LTC_MAX_ECC_BITS defines the size of local variables that hold ECC parameters
00904                    and point coordinates */
00905                 #ifndef LTC_MAX_ECC_BITS
00906                     #define LTC_MAX_ECC_BITS (384)
00907                 #endif
00908 
00909                 /* Enable curves up to 384 bits */
00910                 #if !defined(ECC_USER_CURVES) && !defined(HAVE_ALL_CURVES)
00911                     #define ECC_USER_CURVES
00912                     #define HAVE_ECC192
00913                     #define HAVE_ECC224
00914                     #undef  NO_ECC256
00915                     #define HAVE_ECC384
00916                 #endif
00917 
00918                 /* enable features */
00919                 #undef  HAVE_CURVE25519
00920                 #define HAVE_CURVE25519
00921                 #undef  HAVE_ED25519
00922                 #define HAVE_ED25519
00923                 #undef  WOLFSSL_SHA512
00924                 #define WOLFSSL_SHA512
00925             #endif
00926         #endif
00927     #endif
00928 #endif /* FREESCALE_USE_LTC */
00929 
00930 #ifdef FREESCALE_LTC_TFM_RSA_4096_ENABLE
00931     #undef  USE_CERT_BUFFERS_4096
00932     #define USE_CERT_BUFFERS_4096
00933     #undef  FP_MAX_BITS
00934     #define FP_MAX_BITS (8192)
00935 
00936     #undef  NO_DH
00937     #define NO_DH
00938     #undef  NO_DSA
00939     #define NO_DSA
00940 #endif /* FREESCALE_LTC_TFM_RSA_4096_ENABLE */
00941 
00942 /* if LTC has AES engine but doesn't have GCM, use software with LTC AES ECB mode */
00943 #if defined(FREESCALE_USE_LTC) && !defined(FREESCALE_LTC_AES_GCM)
00944     #define GCM_TABLE
00945 #endif
00946 
00947 #ifdef WOLFSSL_STM32F2
00948     #define SIZEOF_LONG_LONG 8
00949     #define NO_DEV_RANDOM
00950     #define NO_WOLFSSL_DIR
00951     #undef  NO_RABBIT
00952     #define NO_RABBIT
00953     #undef  NO_64BIT
00954     #define NO_64BIT
00955     #define STM32F2_RNG
00956     #define STM32F2_CRYPTO
00957     #if !defined(__GNUC__) && !defined(__ICCARM__)
00958         #define KEIL_INTRINSICS
00959     #endif
00960     #define NO_OLD_RNGNAME
00961     #ifdef WOLFSSL_STM32_CUBEMX
00962         #include "stm32f2xx_hal.h"
00963         #ifndef STM32_HAL_TIMEOUT
00964             #define STM32_HAL_TIMEOUT   0xFF
00965         #endif
00966     #else
00967         #include "stm32f2xx.h"
00968         #include "stm32f2xx_cryp.h"
00969         #include "stm32f2xx_hash.h"
00970     #endif /* WOLFSSL_STM32_CUBEMX */
00971 #endif
00972 
00973 #ifdef WOLFSSL_STM32F4
00974     #define SIZEOF_LONG_LONG 8
00975     #define NO_DEV_RANDOM
00976     #define NO_WOLFSSL_DIR
00977     #undef  NO_RABBIT
00978     #define NO_RABBIT
00979     #undef  NO_64BIT
00980     #define NO_64BIT
00981     #define STM32F4_RNG
00982     #define STM32F4_CRYPTO
00983     #define NO_OLD_RNGNAME
00984     #if !defined(__GNUC__) && !defined(__ICCARM__)
00985         #define KEIL_INTRINSICS
00986     #endif
00987     #ifdef WOLFSSL_STM32_CUBEMX
00988         #include "stm32f4xx_hal.h"
00989         #ifndef STM32_HAL_TIMEOUT
00990             #define STM32_HAL_TIMEOUT   0xFF
00991         #endif
00992     #else
00993         #include "stm32f4xx.h"
00994         #include "stm32f4xx_cryp.h"
00995         #include "stm32f4xx_hash.h"
00996     #endif /* WOLFSSL_STM32_CUBEMX */
00997 #endif
00998 
00999 #ifdef MICRIUM
01000 
01001     #include "stdlib.h"
01002     #include "net_cfg.h"
01003     #include "ssl_cfg.h"
01004     #include "net_secure_os.h"
01005 
01006     #define WOLFSSL_TYPES
01007 
01008     typedef CPU_INT08U byte;
01009     typedef CPU_INT16U word16;
01010     typedef CPU_INT32U word32;
01011 
01012     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
01013         #define SIZEOF_LONG        4
01014         #undef  SIZEOF_LONG_LONG
01015     #else
01016         #undef  SIZEOF_LONG
01017         #define SIZEOF_LONG_LONG   8
01018     #endif
01019 
01020     #define STRING_USER
01021 
01022     #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
01023     #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
01024                     ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
01025                      (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
01026     #define XSTRNCMP(pstr_1, pstr_2, len_max) \
01027                     ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
01028                      (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
01029     #define XSTRSTR(pstr, pstr_srch) \
01030                     ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
01031                      (CPU_CHAR *)(pstr_srch)))
01032     #define XMEMSET(pmem, data_val, size) \
01033                     ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
01034                     (CPU_SIZE_T)(size)))
01035     #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
01036                      (void *)(psrc), (CPU_SIZE_T)(size)))
01037     #define XMEMCMP(pmem_1, pmem_2, size) \
01038                    (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
01039                      (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
01040     #define XMEMMOVE XMEMCPY
01041 
01042 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
01043     #define MICRIUM_MALLOC
01044     #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
01045                                  (CPU_SIZE_T)(s), (void *)0))
01046     #define XFREE(p, h, type)   (NetSecure_BlkFree((CPU_INT08U)(type), \
01047                                  (p), (void *)0))
01048     #define XREALLOC(p, n, h, t) realloc((p), (n))
01049 #endif
01050 
01051     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
01052         #undef  NO_FILESYSTEM
01053     #else
01054         #define NO_FILESYSTEM
01055     #endif
01056 
01057     #if (SSL_CFG_TRACE_LEVEL == WOLFSSL_TRACE_LEVEL_DBG)
01058         #define DEBUG_WOLFSSL
01059     #else
01060         #undef  DEBUG_WOLFSSL
01061     #endif
01062 
01063     #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
01064         #define OPENSSL_EXTRA
01065     #else
01066         #undef  OPENSSL_EXTRA
01067     #endif
01068 
01069     #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
01070         #undef  SINGLE_THREADED
01071     #else
01072         #define SINGLE_THREADED
01073     #endif
01074 
01075     #if (SSL_CFG_DH_EN == DEF_ENABLED)
01076         #undef  NO_DH
01077     #else
01078         #define NO_DH
01079     #endif
01080 
01081     #if (SSL_CFG_DSA_EN == DEF_ENABLED)
01082         #undef  NO_DSA
01083     #else
01084         #define NO_DSA
01085     #endif
01086 
01087     #if (SSL_CFG_PSK_EN == DEF_ENABLED)
01088         #undef  NO_PSK
01089     #else
01090         #define NO_PSK
01091     #endif
01092 
01093     #if (SSL_CFG_3DES_EN == DEF_ENABLED)
01094         #undef  NO_DES
01095     #else
01096         #define NO_DES
01097     #endif
01098 
01099     #if (SSL_CFG_AES_EN == DEF_ENABLED)
01100         #undef  NO_AES
01101     #else
01102         #define NO_AES
01103     #endif
01104 
01105     #if (SSL_CFG_RC4_EN == DEF_ENABLED)
01106         #undef  NO_RC4
01107     #else
01108         #define NO_RC4
01109     #endif
01110 
01111     #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
01112         #undef  NO_RABBIT
01113     #else
01114         #define NO_RABBIT
01115     #endif
01116 
01117     #if (SSL_CFG_HC128_EN == DEF_ENABLED)
01118         #undef  NO_HC128
01119     #else
01120         #define NO_HC128
01121     #endif
01122 
01123     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
01124         #define BIG_ENDIAN_ORDER
01125     #else
01126         #undef  BIG_ENDIAN_ORDER
01127         #define LITTLE_ENDIAN_ORDER
01128     #endif
01129 
01130     #if (SSL_CFG_MD4_EN == DEF_ENABLED)
01131         #undef  NO_MD4
01132     #else
01133         #define NO_MD4
01134     #endif
01135 
01136     #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
01137         #undef  NO_WRITEV
01138     #else
01139         #define NO_WRITEV
01140     #endif
01141 
01142     #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
01143         #define NO_DEV_RANDOM
01144     #else
01145         #undef  NO_DEV_RANDOM
01146     #endif
01147 
01148     #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
01149         #define WOLFSSL_USER_IO
01150     #else
01151         #undef  WOLFSSL_USER_IO
01152     #endif
01153 
01154     #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
01155         #undef  LARGE_STATIC_BUFFERS
01156         #undef  STATIC_CHUNKS_ONLY
01157     #else
01158         #define LARGE_STATIC_BUFFERS
01159         #define STATIC_CHUNKS_ONLY
01160     #endif
01161 
01162     #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
01163         #define  WOLFSSL_DER_LOAD
01164     #else
01165         #undef   WOLFSSL_DER_LOAD
01166     #endif
01167 
01168     #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
01169         #define  WOLFSSL_DTLS
01170     #else
01171         #undef   WOLFSSL_DTLS
01172     #endif
01173 
01174     #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
01175          #define WOLFSSL_CALLBACKS
01176     #else
01177          #undef  WOLFSSL_CALLBACKS
01178     #endif
01179 
01180     #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
01181          #define USE_FAST_MATH
01182     #else
01183          #undef  USE_FAST_MATH
01184     #endif
01185 
01186     #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
01187          #define TFM_TIMING_RESISTANT
01188     #else
01189          #undef  TFM_TIMING_RESISTANT
01190     #endif
01191 
01192 #endif /* MICRIUM */
01193 
01194 
01195 #ifdef WOLFSSL_QL
01196     #ifndef WOLFSSL_SEP
01197         #define WOLFSSL_SEP
01198     #endif
01199     #ifndef OPENSSL_EXTRA
01200         #define OPENSSL_EXTRA
01201     #endif
01202     #ifndef SESSION_CERTS
01203         #define SESSION_CERTS
01204     #endif
01205     #ifndef HAVE_AESCCM
01206         #define HAVE_AESCCM
01207     #endif
01208     #ifndef ATOMIC_USER
01209         #define ATOMIC_USER
01210     #endif
01211     #ifndef WOLFSSL_DER_LOAD
01212         #define WOLFSSL_DER_LOAD
01213     #endif
01214     #ifndef KEEP_PEER_CERT
01215         #define KEEP_PEER_CERT
01216     #endif
01217     #ifndef HAVE_ECC
01218         #define HAVE_ECC
01219     #endif
01220     #ifndef SESSION_INDEX
01221         #define SESSION_INDEX
01222     #endif
01223 #endif /* WOLFSSL_QL */
01224 
01225 
01226 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
01227     !defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY) && \
01228     !defined(XMALLOC_OVERRIDE)
01229     #define USE_WOLFSSL_MEMORY
01230 #endif
01231 
01232 
01233 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
01234     #undef  KEEP_PEER_CERT
01235     #define KEEP_PEER_CERT
01236 #endif
01237 
01238 
01239 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
01240 #ifndef XSTREAM_ALIGN
01241     #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
01242         #define NO_XSTREAM_ALIGN
01243     #else
01244         #define XSTREAM_ALIGN
01245     #endif
01246 #endif
01247 
01248 /* write dup cannot be used with secure renegotiation because write dup
01249  * make write side write only and read side read only */
01250 #if defined(HAVE_WRITE_DUP) && defined(HAVE_SECURE_RENEGOTIATION)
01251     #error "WRITE DUP and SECURE RENEGOTIATION cannot both be on"
01252 #endif
01253 
01254 #ifdef WOLFSSL_SGX
01255     #define WOLFCRYPT_ONLY   /* limitation until IO resolved */
01256     #define SINGLE_THREADED
01257     #define NO_ASN_TIME /* can not use headers such as windows.h */
01258 
01259     /* options used in created example */
01260     #define HAVE_AESGCM
01261     #define USE_CERT_BUFFERS_2048
01262     #define USE_FAST_MATH
01263     #define NO_RC4
01264     #define NO_DES3
01265     #define NO_SHA
01266     #define NO_MD5
01267 #endif /* WOLFSSL_SGX */
01268 
01269 /* FreeScale MMCAU hardware crypto has 4 byte alignment.
01270    However, fsl_mmcau.h gives API with no alignment requirements (4 byte alignment is managed internally by fsl_mmcau.c) */
01271 #ifdef FREESCALE_MMCAU
01272     #define WOLFSSL_MMCAU_ALIGNMENT 0
01273 #endif
01274 
01275 /* if using hardware crypto and have alignment requirements, specify the
01276    requirement here.  The record header of SSL/TLS will prevent easy alignment.
01277    This hint tries to help as much as possible.  */
01278 #ifndef WOLFSSL_GENERAL_ALIGNMENT
01279     #ifdef WOLFSSL_AESNI
01280         #define WOLFSSL_GENERAL_ALIGNMENT 16
01281     #elif defined(XSTREAM_ALIGN)
01282         #define WOLFSSL_GENERAL_ALIGNMENT  4
01283     #elif defined(FREESCALE_MMCAU)
01284         #define WOLFSSL_GENERAL_ALIGNMENT  WOLFSSL_MMCAU_ALIGNMENT
01285     #else
01286         #define WOLFSSL_GENERAL_ALIGNMENT  0
01287     #endif
01288 #endif
01289 
01290 #if defined(WOLFSSL_GENERAL_ALIGNMENT) && (WOLFSSL_GENERAL_ALIGNMENT > 0)
01291     #if defined(_MSC_VER)
01292         #define XGEN_ALIGN __declspec(align(WOLFSSL_GENERAL_ALIGNMENT))
01293     #elif defined(__GNUC__)
01294         #define XGEN_ALIGN __attribute__((aligned(WOLFSSL_GENERAL_ALIGNMENT)))
01295     #else
01296         #define XGEN_ALIGN
01297     #endif
01298 #else
01299     #define XGEN_ALIGN
01300 #endif
01301 
01302 #ifdef HAVE_CRL
01303     /* not widely supported yet */
01304     #undef NO_SKID
01305     #define NO_SKID
01306 #endif
01307 
01308 
01309 #ifdef __INTEL_COMPILER
01310     #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
01311 #endif
01312 
01313 /* user can specify what curves they want with ECC_USER_CURVES otherwise
01314  * all curves are on by default for now */
01315 #ifndef ECC_USER_CURVES
01316     #ifndef HAVE_ALL_CURVES
01317         #define HAVE_ALL_CURVES
01318     #endif
01319 #endif
01320 
01321 /* ECC Configs */
01322 #ifdef HAVE_ECC
01323     /* By default enable Sign, Verify, DHE, Key Import and Key Export unless explicitly disabled */
01324     #ifndef NO_ECC_SIGN
01325         #undef HAVE_ECC_SIGN
01326         #define HAVE_ECC_SIGN
01327     #endif
01328     #ifndef NO_ECC_VERIFY
01329         #undef HAVE_ECC_VERIFY
01330         #define HAVE_ECC_VERIFY
01331     #endif
01332     #ifndef NO_ECC_DHE
01333         #undef HAVE_ECC_DHE
01334         #define HAVE_ECC_DHE
01335     #endif
01336     #ifndef NO_ECC_KEY_IMPORT
01337         #undef HAVE_ECC_KEY_IMPORT
01338         #define HAVE_ECC_KEY_IMPORT
01339     #endif
01340     #ifndef NO_ECC_KEY_EXPORT
01341         #undef HAVE_ECC_KEY_EXPORT
01342         #define HAVE_ECC_KEY_EXPORT
01343     #endif
01344 #endif /* HAVE_ECC */
01345 
01346 /* Curve255519 Configs */
01347 #ifdef HAVE_CURVE25519
01348     /* By default enable shared secret, key export and import */
01349     #ifndef NO_CURVE25519_SHARED_SECRET
01350         #undef HAVE_CURVE25519_SHARED_SECRET
01351         #define HAVE_CURVE25519_SHARED_SECRET
01352     #endif
01353     #ifndef NO_CURVE25519_KEY_EXPORT
01354         #undef HAVE_CURVE25519_KEY_EXPORT
01355         #define HAVE_CURVE25519_KEY_EXPORT
01356     #endif
01357     #ifndef NO_CURVE25519_KEY_IMPORT
01358         #undef HAVE_CURVE25519_KEY_IMPORT
01359         #define HAVE_CURVE25519_KEY_IMPORT
01360     #endif
01361 #endif /* HAVE_CURVE25519 */
01362 
01363 /* Ed255519 Configs */
01364 #ifdef HAVE_ED25519
01365     /* By default enable sign, verify, key export and import */
01366     #ifndef NO_ED25519_SIGN
01367         #undef HAVE_ED25519_SIGN
01368         #define HAVE_ED25519_SIGN
01369     #endif
01370     #ifndef NO_ED25519_VERIFY
01371         #undef HAVE_ED25519_VERIFY
01372         #define HAVE_ED25519_VERIFY
01373     #endif
01374     #ifndef NO_ED25519_KEY_EXPORT
01375         #undef HAVE_ED25519_KEY_EXPORT
01376         #define HAVE_ED25519_KEY_EXPORT
01377     #endif
01378     #ifndef NO_ED25519_KEY_IMPORT
01379         #undef HAVE_ED25519_KEY_IMPORT
01380         #define HAVE_ED25519_KEY_IMPORT
01381     #endif
01382 #endif /* HAVE_ED25519 */
01383 
01384 /* AES Config */
01385 #ifndef NO_AES
01386     /* By default enable all AES key sizes, decryption and CBC */
01387     #ifndef AES_MAX_KEY_SIZE
01388         #undef  AES_MAX_KEY_SIZE
01389         #define AES_MAX_KEY_SIZE    256
01390     #endif
01391     #ifndef NO_AES_DECRYPT
01392         #undef  HAVE_AES_DECRYPT
01393         #define HAVE_AES_DECRYPT
01394     #endif
01395     #ifndef NO_AES_CBC
01396         #undef  HAVE_AES_CBC
01397         #define HAVE_AES_CBC
01398     #else
01399         #ifndef WOLFCRYPT_ONLY
01400             #error "AES CBC is required for TLS and can only be disabled for WOLFCRYPT_ONLY builds"
01401         #endif
01402     #endif
01403 #endif
01404 
01405 /* if desktop type system and fastmath increase default max bits */
01406 #ifdef WOLFSSL_X86_64_BUILD
01407     #ifdef USE_FAST_MATH
01408         #ifndef FP_MAX_BITS
01409             #define FP_MAX_BITS 8192
01410         #endif
01411     #endif
01412 #endif
01413 
01414 /* If using the max strength build, ensure OLD TLS is disabled. */
01415 #ifdef WOLFSSL_MAX_STRENGTH
01416     #undef NO_OLD_TLS
01417     #define NO_OLD_TLS
01418 #endif
01419 
01420 
01421 /* Default AES minimum auth tag sz, allow user to override */
01422 #ifndef WOLFSSL_MIN_AUTH_TAG_SZ
01423     #define WOLFSSL_MIN_AUTH_TAG_SZ 12
01424 #endif
01425 
01426 
01427 /* sniffer requires:
01428  * static RSA cipher suites
01429  * session stats and peak stats
01430  */
01431 #ifdef WOLFSSL_SNIFFER
01432     #ifndef WOLFSSL_STATIC_RSA
01433         #define WOLFSSL_STATIC_RSA
01434     #endif
01435     #ifndef WOLFSSL_SESSION_STATS
01436         #define WOLFSSL_SESSION_STATS
01437     #endif
01438     #ifndef WOLFSSL_PEAK_SESSIONS
01439         #define WOLFSSL_PEAK_SESSIONS
01440     #endif
01441 #endif
01442 
01443 /* Decode Public Key extras on by default, user can turn off with
01444  * WOLFSSL_NO_DECODE_EXTRA */
01445 #ifndef WOLFSSL_NO_DECODE_EXTRA
01446     #ifndef RSA_DECODE_EXTRA
01447         #define RSA_DECODE_EXTRA
01448     #endif
01449     #ifndef ECC_DECODE_EXTRA
01450         #define ECC_DECODE_EXTRA
01451     #endif
01452 #endif
01453 
01454 /* C Sharp wrapper defines */
01455 #ifdef HAVE_CSHARP
01456     #ifndef WOLFSSL_DTLS
01457         #define WOLFSSL_DTLS
01458     #endif
01459     #undef NO_PSK
01460     #undef NO_SHA256
01461     #undef NO_DH
01462 #endif
01463 
01464 /* Asynchronous Crypto */
01465 #ifdef WOLFSSL_ASYNC_CRYPT
01466     /* Make sure wolf events are enabled */
01467     #undef HAVE_WOLF_EVENT
01468     #define HAVE_WOLF_EVENT
01469 
01470     #ifdef WOLFSSL_ASYNC_CRYPT_TEST
01471         #define WC_ASYNC_DEV_SIZE 320+24
01472     #else
01473         #define WC_ASYNC_DEV_SIZE 320
01474     #endif
01475 
01476     #if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \
01477         !defined(WOLFSSL_ASYNC_CRYPT_TEST)
01478         #error No async hardware defined with WOLFSSL_ASYNC_CRYPT!
01479     #endif
01480 
01481     /* Enable ECC_CACHE_CURVE for ASYNC */
01482     #if !defined(ECC_CACHE_CURVE)
01483         #define ECC_CACHE_CURVE
01484     #endif
01485 #endif /* WOLFSSL_ASYNC_CRYPT */
01486 #ifndef WC_ASYNC_DEV_SIZE
01487     #define WC_ASYNC_DEV_SIZE 0
01488 #endif
01489 
01490 /* leantls checks */
01491 #ifdef WOLFSSL_LEANTLS
01492     #ifndef HAVE_ECC
01493         #error leantls build needs ECC
01494     #endif
01495 #endif /* WOLFSSL_LEANTLS*/
01496 
01497 /* restriction with static memory */
01498 #ifdef WOLFSSL_STATIC_MEMORY
01499     #if defined(HAVE_IO_POOL) || defined(XMALLOC_USER) || defined(NO_WOLFSSL_MEMORY)
01500          #error static memory cannot be used with HAVE_IO_POOL, XMALLOC_USER or NO_WOLFSSL_MEMORY
01501     #endif
01502     #if !defined(USE_FAST_MATH) && !defined(NO_BIG_INT)
01503         #error static memory requires fast math please define USE_FAST_MATH
01504     #endif
01505     #ifdef WOLFSSL_SMALL_STACK
01506         #error static memory does not support small stack please undefine
01507     #endif
01508 #endif /* WOLFSSL_STATIC_MEMORY */
01509 
01510 #ifdef HAVE_AES_KEYWRAP
01511     #ifndef WOLFSSL_AES_DIRECT
01512         #error AES key wrap requires AES direct please define WOLFSSL_AES_DIRECT
01513     #endif
01514 #endif
01515 
01516 #ifdef HAVE_PKCS7
01517     #ifndef HAVE_AES_KEYWRAP
01518         #error PKCS7 requires AES key wrap please define HAVE_AES_KEYWRAP
01519     #endif
01520     #ifndef HAVE_X963_KDF
01521         #error PKCS7 requires X963 KDF please define HAVE_X963_KDF
01522     #endif
01523 #endif
01524 
01525 #if !defined(WOLFCRYPT_ONLY) && !defined(NO_OLD_TLS) && \
01526         (defined(NO_SHA) || defined(NO_MD5))
01527     #error old TLS requires MD5 and SHA
01528 #endif
01529 
01530 /* for backwards compatibility */
01531 #if defined(TEST_IPV6) && !defined(WOLFSSL_IPV6)
01532     #define WOLFSSL_IPV6
01533 #endif
01534 
01535 
01536 /* Place any other flags or defines here */
01537 
01538 #if defined(WOLFSSL_MYSQL_COMPATIBLE) && defined(_WIN32) \
01539                                       && defined(HAVE_GMTIME_R)
01540     #undef HAVE_GMTIME_R /* don't trust macro with windows */
01541 #endif /* WOLFSSL_MYSQL_COMPATIBLE */
01542 
01543 #if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
01544     #define SSL_OP_NO_COMPRESSION    SSL_OP_NO_COMPRESSION
01545     #define OPENSSL_NO_ENGINE
01546     #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
01547     #ifndef OPENSSL_EXTRA
01548         #define OPENSSL_EXTRA
01549     #endif
01550     #ifndef HAVE_SESSION_TICKET
01551         #define HAVE_SESSION_TICKET
01552     #endif
01553     #ifndef HAVE_OCSP
01554         #define HAVE_OCSP
01555     #endif
01556     #ifndef KEEP_OUR_CERT
01557         #define KEEP_OUR_CERT
01558     #endif
01559     #ifndef HAVE_SNI
01560         #define HAVE_SNI
01561     #endif
01562 #endif
01563 
01564 #if defined(WOLFSSL_NGINX)
01565     #define SSL_CTRL_SET_TLSEXT_HOSTNAME
01566 #endif
01567 
01568 #ifdef __cplusplus
01569     }   /* extern "C" */
01570 #endif
01571 
01572 #endif
01573