3 * Copyright (C) 2006-2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 using LwIP native TCP socket settings */
88 /* #define HAVE_LWIP_NATIVE */
90 /* Uncomment next line if building for EROAD */
91 /* #define CYASSL_EROAD */
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 #ifdef MICROCHIP_PIC32
139 /* #define CYASSL_MICROCHIP_PIC32MZ */
140 #define SIZEOF_LONG_LONG 8
141 #define SINGLE_THREADED
142 #define CYASSL_USER_IO
144 #define NO_DEV_RANDOM
145 #define NO_FILESYSTEM
146 #define USE_FAST_MATH
147 #define TFM_TIMING_RESISTANT
150 #ifdef CYASSL_MICROCHIP_PIC32MZ
151 #define CYASSL_PIC32MZ_CE
152 #define CYASSL_PIC32MZ_CRYPT
153 #define HAVE_AES_ENGINE
154 #define CYASSL_PIC32MZ_RNG
155 /* #define CYASSL_PIC32MZ_HASH */
156 #define CYASSL_AES_COUNTER
162 #ifdef MICROCHIP_TCPIP_V5
163 /* include timer functions */
164 #include "TCPIP Stack/TCPIP.h"
167 #ifdef MICROCHIP_TCPIP
168 /* include timer, NTP functions */
169 #ifdef MICROCHIP_MPLAB_HARMONY
170 #include "tcpip/tcpip.h"
172 #include "system/system_services.h"
173 #include "tcpip/sntp.h"
178 #define CYASSL_USER_IO
179 #define NO_FILESYSTEM
181 #define USE_CERT_BUFFERS_1024
183 #define NO_DEV_RANDOM
189 #define NO_SESSION_CACHE
190 #define CYASSL_CMSIS_RTOS
195 #define FREESCALE_MQX
196 #define FREESCALE_MMCAU
197 #define SINGLE_THREADED
198 #define NO_STDIO_FILESYSTEM
199 #define CYASSL_LEANPSK
200 #define HAVE_NULL_CIPHER
213 #define NO_SESSION_CACHE
214 #define NO_MAIN_DRIVER
217 #ifdef FREERTOS_WINSIM
219 #define USE_WINDOWS_API
223 /* Micrium will use Visual Studio for compilation but not the Win32 API */
224 #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
225 && !defined(EBSNET) && !defined(CYASSL_EROAD)
226 #define USE_WINDOWS_API
230 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
232 #define XMALLOC(s, h, type) malloc((s))
233 #define XFREE(p, h, type) free((p))
234 #define XREALLOC(p, n, h, t) realloc((p), (n))
237 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
239 #define XMALLOC yaXMALLOC
241 #define XFREE yaXFREE
243 #define XREALLOC yaXREALLOC
264 #ifndef SINGLE_THREADED
265 #include "FreeRTOS.h"
273 /* #define DEBUG_CYASSL */
274 #define NO_CYASSL_DIR /* tbd */
277 #define SINGLE_THREADED
281 #if (!RTP_LITTLE_ENDIAN)
282 #define BIG_ENDIAN_ORDER
285 #if (!KS_LITTLE_ENDIAN)
286 #define BIG_ENDIAN_ORDER
292 #define SIZEOF_LONG_LONG 8
294 #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
297 #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
298 #define XFREE(p, h, type) (rtp_free(p))
299 #define XREALLOC(p, n, h, t) realloc((p), (n))
303 #ifdef CYASSL_GAME_BUILD
304 #define SIZEOF_LONG_LONG 8
305 #if defined(__PPU) || defined(__XENON)
306 #define BIG_ENDIAN_ORDER
311 #define HAVE_WEBSERVER
312 #define SIZEOF_LONG_LONG 8
313 #define CYASSL_LOW_MEMORY
319 #define NO_DEV_RANDOM
320 #define NO_CYASSL_DIR
322 #ifndef NO_FILESYSTEM
324 #include "inc/hw_types.h"
328 #include <errno.h> /* for tcp errno */
329 #define CYASSL_SAFERTOS
330 #if defined(__IAR_SYSTEMS_ICC__)
332 #pragma diag_suppress=Pa089
336 #ifdef CYASSL_SAFERTOS
337 #ifndef SINGLE_THREADED
338 #include "SafeRTOS/semphr.h"
341 #include "SafeRTOS/heap.h"
342 #define XMALLOC(s, h, type) pvPortMalloc((s))
343 #define XFREE(p, h, type) vPortFree((p))
344 #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
347 #ifdef CYASSL_LOW_MEMORY
350 #undef CYASSL_SMALL_STACK
351 #define CYASSL_SMALL_STACK
352 #undef TFM_TIMING_RESISTANT
353 #define TFM_TIMING_RESISTANT
357 #define SIZEOF_LONG_LONG 8
359 #define NO_DEV_RANDOM
361 #define NO_CYASSL_DIR
362 #define USE_FAST_MATH
363 #define TFM_TIMING_RESISTANT
364 #define FREESCALE_K70_RNGA
365 /* #define FREESCALE_K53_RNGB */
367 #ifndef NO_FILESYSTEM
371 #ifndef SINGLE_THREADED
375 #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
376 #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
377 /* Note: MQX has no realloc, using fastmath above */
380 #ifdef CYASSL_STM32F2
381 #define SIZEOF_LONG_LONG 8
382 #define NO_DEV_RANDOM
383 #define NO_CYASSL_DIR
386 #define STM32F2_CRYPTO
387 #define KEIL_INTRINSICS
395 #include "net_secure_os.h"
399 typedef CPU_INT08U byte;
400 typedef CPU_INT16U word16;
401 typedef CPU_INT32U word32;
403 #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
404 #define SIZEOF_LONG 4
405 #undef SIZEOF_LONG_LONG
408 #define SIZEOF_LONG_LONG 8
413 #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
414 #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
415 ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
416 (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
417 #define XSTRNCMP(pstr_1, pstr_2, len_max) \
418 ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
419 (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
420 #define XSTRSTR(pstr, pstr_srch) \
421 ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
422 (CPU_CHAR *)(pstr_srch)))
423 #define XMEMSET(pmem, data_val, size) \
424 ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
426 #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
427 (void *)(psrc), (CPU_SIZE_T)(size)))
428 #define XMEMCMP(pmem_1, pmem_2, size) \
429 (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
430 (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
431 #define XMEMMOVE XMEMCPY
433 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
434 #define MICRIUM_MALLOC
435 #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
436 (CPU_SIZE_T)(s), (void *)0))
437 #define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
439 #define XREALLOC(p, n, h, t) realloc((p), (n))
442 #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
445 #define NO_FILESYSTEM
448 #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
454 #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
455 #define OPENSSL_EXTRA
460 #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
461 #undef SINGLE_THREADED
463 #define SINGLE_THREADED
466 #if (SSL_CFG_DH_EN == DEF_ENABLED)
472 #if (SSL_CFG_DSA_EN == DEF_ENABLED)
478 #if (SSL_CFG_PSK_EN == DEF_ENABLED)
484 #if (SSL_CFG_3DES_EN == DEF_ENABLED)
490 #if (SSL_CFG_AES_EN == DEF_ENABLED)
496 #if (SSL_CFG_RC4_EN == DEF_ENABLED)
502 #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
508 #if (SSL_CFG_HC128_EN == DEF_ENABLED)
514 #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
515 #define BIG_ENDIAN_ORDER
517 #undef BIG_ENDIAN_ORDER
518 #define LITTLE_ENDIAN_ORDER
521 #if (SSL_CFG_MD4_EN == DEF_ENABLED)
527 #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
533 #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
534 #define NO_DEV_RANDOM
539 #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
540 #define CYASSL_USER_IO
542 #undef CYASSL_USER_IO
545 #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
546 #undef LARGE_STATIC_BUFFERS
547 #undef STATIC_CHUNKS_ONLY
549 #define LARGE_STATIC_BUFFERS
550 #define STATIC_CHUNKS_ONLY
553 #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
554 #define CYASSL_DER_LOAD
556 #undef CYASSL_DER_LOAD
559 #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
565 #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
566 #define CYASSL_CALLBACKS
568 #undef CYASSL_CALLBACKS
571 #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
572 #define USE_FAST_MATH
577 #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
578 #define TFM_TIMING_RESISTANT
580 #undef TFM_TIMING_RESISTANT
590 #ifndef OPENSSL_EXTRA
591 #define OPENSSL_EXTRA
593 #ifndef SESSION_CERTS
594 #define SESSION_CERTS
602 #ifndef CYASSL_DER_LOAD
603 #define CYASSL_DER_LOAD
605 #ifndef KEEP_PEER_CERT
606 #define KEEP_PEER_CERT
611 #ifndef SESSION_INDEX
612 #define SESSION_INDEX
614 #endif /* CYASSL_QL */
617 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
618 !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
619 #define USE_CYASSL_MEMORY
623 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
624 #undef KEEP_PEER_CERT
625 #define KEEP_PEER_CERT
629 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
630 #ifndef XSTREAM_ALIGNMENT
631 #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
632 #define NO_XSTREAM_ALIGNMENT
634 #define XSTREAM_ALIGNMENT
639 /* if using hardware crypto and have alignment requirements, specify the
640 requirement here. The record header of SSL/TLS will prvent easy alignment.
641 This hint tries to help as much as possible. */
642 #ifndef CYASSL_GENERAL_ALIGNMENT
644 #define CYASSL_GENERAL_ALIGNMENT 16
645 #elif defined(XSTREAM_ALIGNMENT)
646 #define CYASSL_GENERAL_ALIGNMENT 4
648 #define CYASSL_GENERAL_ALIGNMENT 0
653 /* not widely supported yet */
658 /* Place any other flags or defines here */
666 #endif /* CTAO_CRYPT_SETTINGS_H */