3 * Copyright (C) 2006-2015 wolfSSL Inc.
5 * This file is part of wolfSSL. (formerly known as CyaSSL)
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.
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.
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-1301, USA
22 /* Place OS specific preprocessor flags, defines, includes here, will be
23 included into every file because types.h includes it */
26 #ifndef CTAO_CRYPT_SETTINGS_H
27 #define CTAO_CRYPT_SETTINGS_H
29 /* for reverse compatibility after name change */
30 #include <cyassl/ctaocrypt/settings_comp.h>
36 /* Uncomment next line if using IPHONE */
39 /* Uncomment next line if using ThreadX */
42 /* Uncomment next line if using Micrium ucOS */
45 /* Uncomment next line if using Mbed */
48 /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
49 /* #define MICROCHIP_PIC32 */
51 /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
52 /* #define MICROCHIP_TCPIP_V5 */
54 /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
55 /* #define MICROCHIP_TCPIP */
57 /* Uncomment next line if using PIC32MZ Crypto Engine */
58 /* #define CYASSL_MICROCHIP_PIC32MZ */
60 /* Uncomment next line if using FreeRTOS */
61 /* #define FREERTOS */
63 /* Uncomment next line if using FreeRTOS Windows Simulator */
64 /* #define FREERTOS_WINSIM */
66 /* Uncomment next line if using RTIP */
69 /* Uncomment next line if using lwip */
70 /* #define CYASSL_LWIP */
72 /* Uncomment next line if building CyaSSL for a game console */
73 /* #define CYASSL_GAME_BUILD */
75 /* Uncomment next line if building CyaSSL for LSR */
76 /* #define CYASSL_LSR */
78 /* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */
79 /* #define FREESCALE_MQX */
81 /* Uncomment next line if using STM32F2 */
82 /* #define CYASSL_STM32F2 */
84 /* Uncomment next line if using Comverge settings */
85 /* #define COMVERGE */
87 /* Uncomment next line if using QL SEP settings */
88 /* #define CYASSL_QL */
90 /* Uncomment next line if building for EROAD */
91 /* #define CYASSL_EROAD */
93 /* Uncomment next line if building for IAR EWARM */
94 /* #define CYASSL_IAR_ARM */
96 /* Uncomment next line if using TI-RTOS settings */
97 /* #define CYASSL_TIRTOS */
99 /* Uncomment next line if building with PicoTCP */
100 /* #define CYASSL_PICOTCP */
102 /* Uncomment next line if building for PicoTCP demo bundle */
103 /* #define CYASSL_PICOTCP_DEMO */
105 #include <cyassl/ctaocrypt/visibility.h>
108 #define SIZEOF_LONG_LONG 8
112 #ifdef CYASSL_USER_SETTINGS
113 #include <user_settings.h>
120 #define CYASSL_USER_IO
122 #define NO_DEV_RANDOM
123 #define NO_FILESYSTEM
129 #define NO_SESSION_CACHE
135 #define SIZEOF_LONG_LONG 8
142 #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
145 #define SINGLE_THREADED
146 #define CYASSL_USER_IO
147 #define NO_FILESYSTEM
150 #if defined(CYASSL_IAR_ARM)
151 #define NO_MAIN_DRIVER
152 #define SINGLE_THREADED
153 #define USE_CERT_BUFFERS_1024
154 #define BENCH_EMBEDDED
155 #define NO_FILESYSTEM
157 #define CYASSL_USER_IO
158 #define BENCH_EMBEDDED
161 #ifdef MICROCHIP_PIC32
162 /* #define CYASSL_MICROCHIP_PIC32MZ */
163 #define SIZEOF_LONG_LONG 8
164 #define SINGLE_THREADED
165 #define CYASSL_USER_IO
167 #define NO_DEV_RANDOM
168 #define NO_FILESYSTEM
169 #define USE_FAST_MATH
170 #define TFM_TIMING_RESISTANT
173 #ifdef CYASSL_MICROCHIP_PIC32MZ
174 #define CYASSL_PIC32MZ_CE
175 #define CYASSL_PIC32MZ_CRYPT
176 #define HAVE_AES_ENGINE
177 #define CYASSL_PIC32MZ_RNG
178 /* #define CYASSL_PIC32MZ_HASH */
179 #define CYASSL_AES_COUNTER
185 #ifdef MICROCHIP_TCPIP_V5
186 /* include timer functions */
187 #include "TCPIP Stack/TCPIP.h"
190 #ifdef MICROCHIP_TCPIP
191 /* include timer, NTP functions */
192 #ifdef MICROCHIP_MPLAB_HARMONY
193 #include "tcpip/tcpip.h"
195 #include "system/system_services.h"
196 #include "tcpip/sntp.h"
201 #define CYASSL_USER_IO
202 #define NO_FILESYSTEM
204 #define USE_CERT_BUFFERS_1024
206 #define NO_DEV_RANDOM
212 #define NO_SESSION_CACHE
213 #define CYASSL_CMSIS_RTOS
218 #define FREESCALE_MQX
219 #define FREESCALE_MMCAU
220 #define SINGLE_THREADED
221 #define NO_STDIO_FILESYSTEM
222 #define CYASSL_LEANPSK
223 #define HAVE_NULL_CIPHER
236 #define NO_SESSION_CACHE
237 #define NO_MAIN_DRIVER
240 #ifdef CYASSL_PICOTCP
241 #define errno pico_err
242 #include "pico_defines.h"
243 #include "pico_stack.h"
244 #include "pico_constants.h"
245 #define CUSTOM_RAND_GENERATE pico_rand
248 #ifdef CYASSL_PICOTCP_DEMO
250 #define USE_FAST_MATH
251 #define TFM_TIMING_RESISTANT
252 #define XMALLOC(s, h, type) PICO_ZALLOC((s))
253 #define XFREE(p, h, type) PICO_FREE((p))
254 #define SINGLE_THREADED
256 #define CYASSL_USER_IO
257 #define NO_DEV_RANDOM
258 #define NO_FILESYSTEM
261 #ifdef FREERTOS_WINSIM
263 #define USE_WINDOWS_API
267 /* Micrium will use Visual Studio for compilation but not the Win32 API */
268 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
269 && !defined(EBSNET) && !defined(CYASSL_EROAD)
270 #define USE_WINDOWS_API
274 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
276 #define XMALLOC(s, h, type) malloc((s))
277 #define XFREE(p, h, type) free((p))
278 #define XREALLOC(p, n, h, t) realloc((p), (n))
281 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
283 #define XMALLOC yaXMALLOC
285 #define XFREE yaXFREE
287 #define XREALLOC yaXREALLOC
308 #ifndef SINGLE_THREADED
309 #include "FreeRTOS.h"
315 #define SIZEOF_LONG_LONG 8
317 #define NO_CYASSL_DIR
318 #define USE_FAST_MATH
319 #define TFM_TIMING_RESISTANT
320 #define NO_DEV_RANDOM
321 #define NO_FILESYSTEM
322 #define USE_CERT_BUFFERS_2048
323 #define NO_ERROR_STRINGS
326 #ifdef __IAR_SYSTEMS_ICC__
327 #pragma diag_suppress=Pa089
328 #elif !defined(__GNUC__)
329 /* Suppress the sslpro warning */
330 #pragma diag_suppress=11
333 #include <ti/ndk/nettools/mytime/mytime.h>
339 /* #define DEBUG_CYASSL */
340 #define NO_CYASSL_DIR /* tbd */
343 #define SINGLE_THREADED
347 #if (!RTP_LITTLE_ENDIAN)
348 #define BIG_ENDIAN_ORDER
351 #if (!KS_LITTLE_ENDIAN)
352 #define BIG_ENDIAN_ORDER
358 #define SIZEOF_LONG_LONG 8
360 #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
363 #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
364 #define XFREE(p, h, type) (rtp_free(p))
365 #define XREALLOC(p, n, h, t) realloc((p), (n))
369 #ifdef CYASSL_GAME_BUILD
370 #define SIZEOF_LONG_LONG 8
371 #if defined(__PPU) || defined(__XENON)
372 #define BIG_ENDIAN_ORDER
377 #define HAVE_WEBSERVER
378 #define SIZEOF_LONG_LONG 8
379 #define CYASSL_LOW_MEMORY
385 #define NO_DEV_RANDOM
386 #define NO_CYASSL_DIR
388 #ifndef NO_FILESYSTEM
390 #include "inc/hw_types.h"
394 #include <errno.h> /* for tcp errno */
395 #define CYASSL_SAFERTOS
396 #if defined(__IAR_SYSTEMS_ICC__)
398 #pragma diag_suppress=Pa089
402 #ifdef CYASSL_SAFERTOS
403 #ifndef SINGLE_THREADED
404 #include "SafeRTOS/semphr.h"
407 #include "SafeRTOS/heap.h"
408 #define XMALLOC(s, h, type) pvPortMalloc((s))
409 #define XFREE(p, h, type) vPortFree((p))
410 #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
413 #ifdef CYASSL_LOW_MEMORY
416 #undef CYASSL_SMALL_STACK
417 #define CYASSL_SMALL_STACK
418 #undef TFM_TIMING_RESISTANT
419 #define TFM_TIMING_RESISTANT
423 #define SIZEOF_LONG_LONG 8
425 #define NO_DEV_RANDOM
427 #define NO_CYASSL_DIR
428 #define USE_FAST_MATH
429 #define TFM_TIMING_RESISTANT
430 #define FREESCALE_K70_RNGA
431 /* #define FREESCALE_K53_RNGB */
433 #ifndef NO_FILESYSTEM
437 #ifndef SINGLE_THREADED
441 #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
442 #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
443 /* Note: MQX has no realloc, using fastmath above */
446 #ifdef CYASSL_STM32F2
447 #define SIZEOF_LONG_LONG 8
448 #define NO_DEV_RANDOM
449 #define NO_CYASSL_DIR
452 #define STM32F2_CRYPTO
453 #define KEIL_INTRINSICS
461 #include "net_secure_os.h"
465 typedef CPU_INT08U byte;
466 typedef CPU_INT16U word16;
467 typedef CPU_INT32U word32;
469 #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
470 #define SIZEOF_LONG 4
471 #undef SIZEOF_LONG_LONG
474 #define SIZEOF_LONG_LONG 8
479 #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
480 #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
481 ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
482 (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
483 #define XSTRNCMP(pstr_1, pstr_2, len_max) \
484 ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
485 (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
486 #define XSTRSTR(pstr, pstr_srch) \
487 ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
488 (CPU_CHAR *)(pstr_srch)))
489 #define XMEMSET(pmem, data_val, size) \
490 ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
492 #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
493 (void *)(psrc), (CPU_SIZE_T)(size)))
494 #define XMEMCMP(pmem_1, pmem_2, size) \
495 (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
496 (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
497 #define XMEMMOVE XMEMCPY
499 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
500 #define MICRIUM_MALLOC
501 #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
502 (CPU_SIZE_T)(s), (void *)0))
503 #define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
505 #define XREALLOC(p, n, h, t) realloc((p), (n))
508 #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
511 #define NO_FILESYSTEM
514 #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
520 #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
521 #define OPENSSL_EXTRA
526 #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
527 #undef SINGLE_THREADED
529 #define SINGLE_THREADED
532 #if (SSL_CFG_DH_EN == DEF_ENABLED)
538 #if (SSL_CFG_DSA_EN == DEF_ENABLED)
544 #if (SSL_CFG_PSK_EN == DEF_ENABLED)
550 #if (SSL_CFG_3DES_EN == DEF_ENABLED)
556 #if (SSL_CFG_AES_EN == DEF_ENABLED)
562 #if (SSL_CFG_RC4_EN == DEF_ENABLED)
568 #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
574 #if (SSL_CFG_HC128_EN == DEF_ENABLED)
580 #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
581 #define BIG_ENDIAN_ORDER
583 #undef BIG_ENDIAN_ORDER
584 #define LITTLE_ENDIAN_ORDER
587 #if (SSL_CFG_MD4_EN == DEF_ENABLED)
593 #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
599 #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
600 #define NO_DEV_RANDOM
605 #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
606 #define CYASSL_USER_IO
608 #undef CYASSL_USER_IO
611 #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
612 #undef LARGE_STATIC_BUFFERS
613 #undef STATIC_CHUNKS_ONLY
615 #define LARGE_STATIC_BUFFERS
616 #define STATIC_CHUNKS_ONLY
619 #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
620 #define CYASSL_DER_LOAD
622 #undef CYASSL_DER_LOAD
625 #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
631 #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
632 #define CYASSL_CALLBACKS
634 #undef CYASSL_CALLBACKS
637 #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
638 #define USE_FAST_MATH
643 #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
644 #define TFM_TIMING_RESISTANT
646 #undef TFM_TIMING_RESISTANT
656 #ifndef OPENSSL_EXTRA
657 #define OPENSSL_EXTRA
659 #ifndef SESSION_CERTS
660 #define SESSION_CERTS
668 #ifndef CYASSL_DER_LOAD
669 #define CYASSL_DER_LOAD
671 #ifndef KEEP_PEER_CERT
672 #define KEEP_PEER_CERT
677 #ifndef SESSION_INDEX
678 #define SESSION_INDEX
680 #endif /* CYASSL_QL */
683 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
684 !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
685 #define USE_CYASSL_MEMORY
689 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
690 #undef KEEP_PEER_CERT
691 #define KEEP_PEER_CERT
695 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
696 #ifndef XSTREAM_ALIGNMENT
697 #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
698 #define NO_XSTREAM_ALIGNMENT
700 #define XSTREAM_ALIGNMENT
705 /* FreeScale MMCAU hardware crypto has 4 byte alignment */
706 #ifdef FREESCALE_MMCAU
707 #define CYASSL_MMCAU_ALIGNMENT 4
710 /* if using hardware crypto and have alignment requirements, specify the
711 requirement here. The record header of SSL/TLS will prvent easy alignment.
712 This hint tries to help as much as possible. */
713 #ifndef CYASSL_GENERAL_ALIGNMENT
715 #define CYASSL_GENERAL_ALIGNMENT 16
716 #elif defined(XSTREAM_ALIGNMENT)
717 #define CYASSL_GENERAL_ALIGNMENT 4
718 #elif defined(FREESCALE_MMCAU)
719 #define CYASSL_GENERAL_ALIGNMENT CYASSL_MMCAU_ALIGNMENT
721 #define CYASSL_GENERAL_ALIGNMENT 0
726 /* not widely supported yet */
732 #ifdef __INTEL_COMPILER
733 #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
737 /* Place any other flags or defines here */
745 #endif /* CTAO_CRYPT_SETTINGS_H */