3 * Copyright (C) 2006-2014 wolfSSL Inc.
5 * This file is part of CyaSSL.
7 * CyaSSL 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 * CyaSSL 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
33 /* Uncomment next line if using IPHONE */
36 /* Uncomment next line if using ThreadX */
39 /* Uncomment next line if using Micrium ucOS */
42 /* Uncomment next line if using Mbed */
45 /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
46 /* #define MICROCHIP_PIC32 */
48 /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
49 /* #define MICROCHIP_TCPIP_V5 */
51 /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
52 /* #define MICROCHIP_TCPIP */
54 /* Uncomment next line if using PIC32MZ Crypto Engine */
55 /* #define CYASSL_MICROCHIP_PIC32MZ */
57 /* Uncomment next line if using FreeRTOS */
58 /* #define FREERTOS */
60 /* Uncomment next line if using FreeRTOS Windows Simulator */
61 /* #define FREERTOS_WINSIM */
63 /* Uncomment next line if using RTIP */
66 /* Uncomment next line if using lwip */
67 /* #define CYASSL_LWIP */
69 /* Uncomment next line if building CyaSSL for a game console */
70 /* #define CYASSL_GAME_BUILD */
72 /* Uncomment next line if building CyaSSL for LSR */
73 /* #define CYASSL_LSR */
75 /* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */
76 /* #define FREESCALE_MQX */
78 /* Uncomment next line if using STM32F2 */
79 /* #define CYASSL_STM32F2 */
81 /* Uncomment next line if using Comverge settings */
82 /* #define COMVERGE */
84 /* Uncomment next line if using QL SEP settings */
85 /* #define CYASSL_QL */
87 /* Uncomment next line if building for EROAD */
88 /* #define CYASSL_EROAD */
90 /* Uncomment next line if building for IAR EWARM */
91 /* #define CYASSL_IAR_ARM */
93 #include <cyassl/ctaocrypt/visibility.h>
96 #define SIZEOF_LONG_LONG 8
100 #ifdef CYASSL_USER_SETTINGS
101 #include <user_settings.h>
108 #define CYASSL_USER_IO
110 #define NO_DEV_RANDOM
111 #define NO_FILESYSTEM
117 #define NO_SESSION_CACHE
123 #define SIZEOF_LONG_LONG 8
130 #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
133 #define SINGLE_THREADED
134 #define CYASSL_USER_IO
135 #define NO_FILESYSTEM
138 #if defined(CYASSL_IAR_ARM)
139 #define NO_MAIN_DRIVER
140 #define SINGLE_THREADED
141 #define USE_CERT_BUFFERS_1024
142 #define BENCH_EMBEDDED
143 #define NO_FILESYSTEM
145 #define CYASSL_USER_IO
146 #define BENCH_EMBEDDED
149 #ifdef MICROCHIP_PIC32
150 /* #define CYASSL_MICROCHIP_PIC32MZ */
151 #define SIZEOF_LONG_LONG 8
152 #define SINGLE_THREADED
153 #define CYASSL_USER_IO
155 #define NO_DEV_RANDOM
156 #define NO_FILESYSTEM
157 #define USE_FAST_MATH
158 #define TFM_TIMING_RESISTANT
161 #ifdef CYASSL_MICROCHIP_PIC32MZ
162 #define CYASSL_PIC32MZ_CE
163 #define CYASSL_PIC32MZ_CRYPT
164 #define HAVE_AES_ENGINE
165 #define CYASSL_PIC32MZ_RNG
166 /* #define CYASSL_PIC32MZ_HASH */
167 #define CYASSL_AES_COUNTER
173 #ifdef MICROCHIP_TCPIP_V5
174 /* include timer functions */
175 #include "TCPIP Stack/TCPIP.h"
178 #ifdef MICROCHIP_TCPIP
179 /* include timer, NTP functions */
180 #ifdef MICROCHIP_MPLAB_HARMONY
181 #include "tcpip/tcpip.h"
183 #include "system/system_services.h"
184 #include "tcpip/sntp.h"
189 #define CYASSL_USER_IO
190 #define NO_FILESYSTEM
192 #define USE_CERT_BUFFERS_1024
194 #define NO_DEV_RANDOM
200 #define NO_SESSION_CACHE
201 #define CYASSL_CMSIS_RTOS
206 #define FREESCALE_MQX
207 #define FREESCALE_MMCAU
208 #define SINGLE_THREADED
209 #define NO_STDIO_FILESYSTEM
210 #define CYASSL_LEANPSK
211 #define HAVE_NULL_CIPHER
224 #define NO_SESSION_CACHE
225 #define NO_MAIN_DRIVER
228 #ifdef FREERTOS_WINSIM
230 #define USE_WINDOWS_API
234 /* Micrium will use Visual Studio for compilation but not the Win32 API */
235 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
236 && !defined(EBSNET) && !defined(CYASSL_EROAD)
237 #define USE_WINDOWS_API
241 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
243 #define XMALLOC(s, h, type) malloc((s))
244 #define XFREE(p, h, type) free((p))
245 #define XREALLOC(p, n, h, t) realloc((p), (n))
248 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
250 #define XMALLOC yaXMALLOC
252 #define XFREE yaXFREE
254 #define XREALLOC yaXREALLOC
275 #ifndef SINGLE_THREADED
276 #include "FreeRTOS.h"
284 /* #define DEBUG_CYASSL */
285 #define NO_CYASSL_DIR /* tbd */
288 #define SINGLE_THREADED
292 #if (!RTP_LITTLE_ENDIAN)
293 #define BIG_ENDIAN_ORDER
296 #if (!KS_LITTLE_ENDIAN)
297 #define BIG_ENDIAN_ORDER
303 #define SIZEOF_LONG_LONG 8
305 #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
308 #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
309 #define XFREE(p, h, type) (rtp_free(p))
310 #define XREALLOC(p, n, h, t) realloc((p), (n))
314 #ifdef CYASSL_GAME_BUILD
315 #define SIZEOF_LONG_LONG 8
316 #if defined(__PPU) || defined(__XENON)
317 #define BIG_ENDIAN_ORDER
322 #define HAVE_WEBSERVER
323 #define SIZEOF_LONG_LONG 8
324 #define CYASSL_LOW_MEMORY
330 #define NO_DEV_RANDOM
331 #define NO_CYASSL_DIR
333 #ifndef NO_FILESYSTEM
335 #include "inc/hw_types.h"
339 #include <errno.h> /* for tcp errno */
340 #define CYASSL_SAFERTOS
341 #if defined(__IAR_SYSTEMS_ICC__)
343 #pragma diag_suppress=Pa089
347 #ifdef CYASSL_SAFERTOS
348 #ifndef SINGLE_THREADED
349 #include "SafeRTOS/semphr.h"
352 #include "SafeRTOS/heap.h"
353 #define XMALLOC(s, h, type) pvPortMalloc((s))
354 #define XFREE(p, h, type) vPortFree((p))
355 #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
358 #ifdef CYASSL_LOW_MEMORY
361 #undef CYASSL_SMALL_STACK
362 #define CYASSL_SMALL_STACK
363 #undef TFM_TIMING_RESISTANT
364 #define TFM_TIMING_RESISTANT
368 #define SIZEOF_LONG_LONG 8
370 #define NO_DEV_RANDOM
372 #define NO_CYASSL_DIR
373 #define USE_FAST_MATH
374 #define TFM_TIMING_RESISTANT
375 #define FREESCALE_K70_RNGA
376 /* #define FREESCALE_K53_RNGB */
378 #ifndef NO_FILESYSTEM
382 #ifndef SINGLE_THREADED
386 #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
387 #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
388 /* Note: MQX has no realloc, using fastmath above */
391 #ifdef CYASSL_STM32F2
392 #define SIZEOF_LONG_LONG 8
393 #define NO_DEV_RANDOM
394 #define NO_CYASSL_DIR
397 #define STM32F2_CRYPTO
398 #define KEIL_INTRINSICS
406 #include "net_secure_os.h"
410 typedef CPU_INT08U byte;
411 typedef CPU_INT16U word16;
412 typedef CPU_INT32U word32;
414 #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
415 #define SIZEOF_LONG 4
416 #undef SIZEOF_LONG_LONG
419 #define SIZEOF_LONG_LONG 8
424 #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
425 #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
426 ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
427 (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
428 #define XSTRNCMP(pstr_1, pstr_2, len_max) \
429 ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
430 (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
431 #define XSTRSTR(pstr, pstr_srch) \
432 ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
433 (CPU_CHAR *)(pstr_srch)))
434 #define XMEMSET(pmem, data_val, size) \
435 ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
437 #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
438 (void *)(psrc), (CPU_SIZE_T)(size)))
439 #define XMEMCMP(pmem_1, pmem_2, size) \
440 (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
441 (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
442 #define XMEMMOVE XMEMCPY
444 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
445 #define MICRIUM_MALLOC
446 #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
447 (CPU_SIZE_T)(s), (void *)0))
448 #define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
450 #define XREALLOC(p, n, h, t) realloc((p), (n))
453 #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
456 #define NO_FILESYSTEM
459 #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
465 #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
466 #define OPENSSL_EXTRA
471 #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
472 #undef SINGLE_THREADED
474 #define SINGLE_THREADED
477 #if (SSL_CFG_DH_EN == DEF_ENABLED)
483 #if (SSL_CFG_DSA_EN == DEF_ENABLED)
489 #if (SSL_CFG_PSK_EN == DEF_ENABLED)
495 #if (SSL_CFG_3DES_EN == DEF_ENABLED)
501 #if (SSL_CFG_AES_EN == DEF_ENABLED)
507 #if (SSL_CFG_RC4_EN == DEF_ENABLED)
513 #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
519 #if (SSL_CFG_HC128_EN == DEF_ENABLED)
525 #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
526 #define BIG_ENDIAN_ORDER
528 #undef BIG_ENDIAN_ORDER
529 #define LITTLE_ENDIAN_ORDER
532 #if (SSL_CFG_MD4_EN == DEF_ENABLED)
538 #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
544 #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
545 #define NO_DEV_RANDOM
550 #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
551 #define CYASSL_USER_IO
553 #undef CYASSL_USER_IO
556 #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
557 #undef LARGE_STATIC_BUFFERS
558 #undef STATIC_CHUNKS_ONLY
560 #define LARGE_STATIC_BUFFERS
561 #define STATIC_CHUNKS_ONLY
564 #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
565 #define CYASSL_DER_LOAD
567 #undef CYASSL_DER_LOAD
570 #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
576 #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
577 #define CYASSL_CALLBACKS
579 #undef CYASSL_CALLBACKS
582 #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
583 #define USE_FAST_MATH
588 #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
589 #define TFM_TIMING_RESISTANT
591 #undef TFM_TIMING_RESISTANT
601 #ifndef OPENSSL_EXTRA
602 #define OPENSSL_EXTRA
604 #ifndef SESSION_CERTS
605 #define SESSION_CERTS
613 #ifndef CYASSL_DER_LOAD
614 #define CYASSL_DER_LOAD
616 #ifndef KEEP_PEER_CERT
617 #define KEEP_PEER_CERT
622 #ifndef SESSION_INDEX
623 #define SESSION_INDEX
625 #endif /* CYASSL_QL */
628 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
629 !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
630 #define USE_CYASSL_MEMORY
634 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
635 #undef KEEP_PEER_CERT
636 #define KEEP_PEER_CERT
640 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
641 #ifndef XSTREAM_ALIGNMENT
642 #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
643 #define NO_XSTREAM_ALIGNMENT
645 #define XSTREAM_ALIGNMENT
650 /* FreeScale MMCAU hardware crypto has 4 byte alignment */
651 #ifdef FREESCALE_MMCAU
652 #define CYASSL_MMCAU_ALIGNMENT 4
655 /* if using hardware crypto and have alignment requirements, specify the
656 requirement here. The record header of SSL/TLS will prvent easy alignment.
657 This hint tries to help as much as possible. */
658 #ifndef CYASSL_GENERAL_ALIGNMENT
660 #define CYASSL_GENERAL_ALIGNMENT 16
661 #elif defined(XSTREAM_ALIGNMENT)
662 #define CYASSL_GENERAL_ALIGNMENT 4
663 #elif defined(FREESCALE_MMCAU)
664 #define CYASSL_GENERAL_ALIGNMENT CYASSL_MMCAU_ALIGNMENT
666 #define CYASSL_GENERAL_ALIGNMENT 0
671 /* not widely supported yet */
677 #ifdef __INTEL_COMPILER
678 #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
682 /* Place any other flags or defines here */
690 #endif /* CTAO_CRYPT_SETTINGS_H */