]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/settings.h
57bb8290ebb00cde0a6345d89eca370f5246e9f7
[freertos] / FreeRTOS-Plus / Source / CyaSSL / cyassl / ctaocrypt / settings.h
1 /* settings.h
2  *
3  * Copyright (C) 2006-2014 wolfSSL Inc.
4  *
5  * This file is part of CyaSSL.
6  *
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.
11  *
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.
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-1301, USA
20  */
21
22 /* Place OS specific preprocessor flags, defines, includes here, will be
23    included into every file because types.h includes it */
24
25
26 #ifndef CTAO_CRYPT_SETTINGS_H
27 #define CTAO_CRYPT_SETTINGS_H
28
29 #ifdef __cplusplus
30     extern "C" {
31 #endif
32
33 /* Uncomment next line if using IPHONE */
34 /* #define IPHONE */
35
36 /* Uncomment next line if using ThreadX */
37 /* #define THREADX */
38
39 /* Uncomment next line if using Micrium ucOS */
40 /* #define MICRIUM */
41
42 /* Uncomment next line if using Mbed */
43 /* #define MBED */
44
45 /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
46 /* #define MICROCHIP_PIC32 */
47
48 /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
49 /* #define MICROCHIP_TCPIP_V5 */
50
51 /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
52 /* #define MICROCHIP_TCPIP */
53
54 /* Uncomment next line if using PIC32MZ Crypto Engine */
55 /* #define CYASSL_MICROCHIP_PIC32MZ */
56         
57 /* Uncomment next line if using FreeRTOS */
58 /* #define FREERTOS */
59
60 /* Uncomment next line if using FreeRTOS Windows Simulator */
61 /* #define FREERTOS_WINSIM */
62
63 /* Uncomment next line if using RTIP */
64 /* #define EBSNET */
65
66 /* Uncomment next line if using lwip */
67 /* #define CYASSL_LWIP */
68
69 /* Uncomment next line if building CyaSSL for a game console */
70 /* #define CYASSL_GAME_BUILD */
71
72 /* Uncomment next line if building CyaSSL for LSR */
73 /* #define CYASSL_LSR */
74
75 /* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */
76 /* #define FREESCALE_MQX */
77
78 /* Uncomment next line if using STM32F2 */
79 /* #define CYASSL_STM32F2 */
80
81 /* Uncomment next line if using Comverge settings */
82 /* #define COMVERGE */
83
84 /* Uncomment next line if using QL SEP settings */
85 /* #define CYASSL_QL */
86
87 /* Uncomment next line if building for EROAD */
88 /* #define CYASSL_EROAD */
89       
90 /* Uncomment next line if building for IAR EWARM */
91 /* #define CYASSL_IAR_ARM */
92
93 #include <cyassl/ctaocrypt/visibility.h>
94
95 #ifdef IPHONE
96     #define SIZEOF_LONG_LONG 8
97 #endif
98
99
100 #ifdef CYASSL_USER_SETTINGS
101     #include <user_settings.h>
102 #endif
103
104
105 #ifdef COMVERGE
106     #define THREADX
107     #define HAVE_NETX
108     #define CYASSL_USER_IO
109     #define NO_WRITEV
110     #define NO_DEV_RANDOM
111     #define NO_FILESYSTEM
112     #define NO_SHA512
113     #define NO_DH
114     #define NO_DSA
115     #define NO_HC128
116     #define NO_RSA
117     #define NO_SESSION_CACHE
118     #define HAVE_ECC 
119 #endif
120
121
122 #ifdef THREADX 
123     #define SIZEOF_LONG_LONG 8
124 #endif
125
126 #ifdef HAVE_NETX
127     #include "nx_api.h"
128 #endif
129
130 #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
131     #define CYASSL_LWIP
132     #define NO_WRITEV
133     #define SINGLE_THREADED
134     #define CYASSL_USER_IO
135     #define NO_FILESYSTEM
136 #endif 
137     
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
144     #define NO_WRITEV
145     #define CYASSL_USER_IO
146     #define  BENCH_EMBEDDED
147 #endif
148       
149 #ifdef MICROCHIP_PIC32
150     /* #define CYASSL_MICROCHIP_PIC32MZ */
151     #define SIZEOF_LONG_LONG 8
152     #define SINGLE_THREADED
153     #define CYASSL_USER_IO
154     #define NO_WRITEV
155     #define NO_DEV_RANDOM
156     #define NO_FILESYSTEM
157     #define USE_FAST_MATH
158     #define TFM_TIMING_RESISTANT
159 #endif
160
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
168     #define HAVE_AESGCM
169     #define NO_BIG_INT
170
171 #endif
172
173 #ifdef MICROCHIP_TCPIP_V5
174     /* include timer functions */
175     #include "TCPIP Stack/TCPIP.h"
176 #endif
177
178 #ifdef MICROCHIP_TCPIP
179     /* include timer, NTP functions */
180     #ifdef MICROCHIP_MPLAB_HARMONY
181         #include "tcpip/tcpip.h"
182     #else
183         #include "system/system_services.h"
184         #include "tcpip/sntp.h"
185     #endif
186 #endif
187
188 #ifdef MBED
189     #define CYASSL_USER_IO
190     #define NO_FILESYSTEM
191     #define NO_CERT
192     #define USE_CERT_BUFFERS_1024
193     #define NO_WRITEV
194     #define NO_DEV_RANDOM
195     #define NO_SHA512
196     #define NO_DH
197     #define NO_DSA
198     #define NO_HC128
199     #define HAVE_ECC
200     #define NO_SESSION_CACHE
201     #define CYASSL_CMSIS_RTOS
202 #endif
203
204
205 #ifdef CYASSL_EROAD
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
212     #define NO_OLD_TLS
213     #define NO_ASN
214     #define NO_BIG_INT
215     #define NO_RSA
216     #define NO_DSA
217     #define NO_DH
218     #define NO_CERTS
219     #define NO_PWDBASED
220     #define NO_DES3
221     #define NO_MD4
222     #define NO_RC4
223     #define NO_MD5
224     #define NO_SESSION_CACHE
225     #define NO_MAIN_DRIVER
226 #endif
227
228 #ifdef FREERTOS_WINSIM
229     #define FREERTOS
230     #define USE_WINDOWS_API
231 #endif
232
233
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
238 #endif
239
240
241 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
242     #include <stdlib.h>
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))
246 #endif
247
248 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
249     #undef  XMALLOC
250     #define XMALLOC     yaXMALLOC
251     #undef  XFREE
252     #define XFREE       yaXFREE
253     #undef  XREALLOC
254     #define XREALLOC    yaXREALLOC
255 #endif
256
257
258 #ifdef FREERTOS
259     #ifndef NO_WRITEV
260         #define NO_WRITEV
261     #endif
262     #ifndef NO_SHA512
263         #define NO_SHA512
264     #endif
265     #ifndef NO_DH
266         #define NO_DH
267     #endif
268     #ifndef NO_DSA
269         #define NO_DSA
270     #endif
271     #ifndef NO_HC128
272         #define NO_HC128
273     #endif
274
275     #ifndef SINGLE_THREADED
276         #include "FreeRTOS.h"
277         #include "semphr.h"
278     #endif
279 #endif
280
281 #ifdef EBSNET
282     #include "rtip.h"
283
284     /* #define DEBUG_CYASSL */
285     #define NO_CYASSL_DIR  /* tbd */
286
287     #if (POLLOS)
288         #define SINGLE_THREADED
289     #endif
290
291     #if (RTPLATFORM)
292         #if (!RTP_LITTLE_ENDIAN)
293             #define BIG_ENDIAN_ORDER
294         #endif
295     #else
296         #if (!KS_LITTLE_ENDIAN)
297             #define BIG_ENDIAN_ORDER
298         #endif
299     #endif
300
301     #if (WINMSP3)
302         #undef SIZEOF_LONG
303         #define SIZEOF_LONG_LONG 8
304     #else
305         #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
306     #endif
307
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))
311
312 #endif /* EBSNET */
313
314 #ifdef CYASSL_GAME_BUILD
315     #define SIZEOF_LONG_LONG 8
316     #if defined(__PPU) || defined(__XENON)
317         #define BIG_ENDIAN_ORDER
318     #endif
319 #endif
320
321 #ifdef CYASSL_LSR
322     #define HAVE_WEBSERVER
323     #define SIZEOF_LONG_LONG 8
324     #define CYASSL_LOW_MEMORY
325     #define NO_WRITEV
326     #define NO_SHA512
327     #define NO_DH
328     #define NO_DSA
329     #define NO_HC128
330     #define NO_DEV_RANDOM
331     #define NO_CYASSL_DIR
332     #define NO_RABBIT
333     #ifndef NO_FILESYSTEM
334         #define LSR_FS
335         #include "inc/hw_types.h"
336         #include "fs.h"
337     #endif
338     #define CYASSL_LWIP
339     #include <errno.h>  /* for tcp errno */
340     #define CYASSL_SAFERTOS
341     #if defined(__IAR_SYSTEMS_ICC__)
342         /* enum uses enum */
343         #pragma diag_suppress=Pa089
344     #endif
345 #endif
346
347 #ifdef CYASSL_SAFERTOS
348     #ifndef SINGLE_THREADED
349         #include "SafeRTOS/semphr.h"
350     #endif
351
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))
356 #endif
357
358 #ifdef CYASSL_LOW_MEMORY
359     #undef  RSA_LOW_MEM
360     #define RSA_LOW_MEM
361     #undef  CYASSL_SMALL_STACK
362     #define CYASSL_SMALL_STACK
363     #undef  TFM_TIMING_RESISTANT
364     #define TFM_TIMING_RESISTANT
365 #endif
366
367 #ifdef FREESCALE_MQX
368     #define SIZEOF_LONG_LONG 8
369     #define NO_WRITEV
370     #define NO_DEV_RANDOM
371     #define NO_RABBIT
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 */
377     #include "mqx.h"
378     #ifndef NO_FILESYSTEM
379         #include "mfs.h"
380         #include "fio.h"
381     #endif
382     #ifndef SINGLE_THREADED
383         #include "mutex.h"
384     #endif
385
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 */
389 #endif
390
391 #ifdef CYASSL_STM32F2
392     #define SIZEOF_LONG_LONG 8
393     #define NO_DEV_RANDOM
394     #define NO_CYASSL_DIR
395     #define NO_RABBIT
396     #define STM32F2_RNG
397     #define STM32F2_CRYPTO
398     #define KEIL_INTRINSICS
399 #endif
400
401 #ifdef MICRIUM
402
403     #include "stdlib.h"
404     #include "net_cfg.h"
405     #include "ssl_cfg.h"
406     #include "net_secure_os.h"
407
408     #define CYASSL_TYPES
409
410     typedef CPU_INT08U byte;
411     typedef CPU_INT16U word16;
412     typedef CPU_INT32U word32;
413
414     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
415         #define SIZEOF_LONG        4
416         #undef  SIZEOF_LONG_LONG
417     #else
418         #undef  SIZEOF_LONG
419         #define SIZEOF_LONG_LONG   8
420     #endif
421
422     #define STRING_USER
423
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), \
436                     (CPU_SIZE_T)(size)))
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
443
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), \
449                                  (p), (void *)0))
450     #define XREALLOC(p, n, h, t) realloc((p), (n))
451 #endif
452
453     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
454         #undef  NO_FILESYSTEM
455     #else
456         #define NO_FILESYSTEM
457     #endif
458
459     #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
460         #define DEBUG_CYASSL
461     #else
462         #undef  DEBUG_CYASSL
463     #endif
464
465     #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
466         #define OPENSSL_EXTRA
467     #else
468         #undef  OPENSSL_EXTRA
469     #endif
470
471     #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
472         #undef  SINGLE_THREADED
473     #else
474         #define SINGLE_THREADED
475     #endif
476
477     #if (SSL_CFG_DH_EN == DEF_ENABLED)
478         #undef  NO_DH
479     #else
480         #define NO_DH
481     #endif
482
483     #if (SSL_CFG_DSA_EN == DEF_ENABLED)
484         #undef  NO_DSA
485     #else
486         #define NO_DSA
487     #endif
488
489     #if (SSL_CFG_PSK_EN == DEF_ENABLED)
490         #undef  NO_PSK
491     #else
492         #define NO_PSK
493     #endif
494
495     #if (SSL_CFG_3DES_EN == DEF_ENABLED)
496         #undef  NO_DES
497     #else
498         #define NO_DES
499     #endif
500
501     #if (SSL_CFG_AES_EN == DEF_ENABLED)
502         #undef  NO_AES
503     #else
504         #define NO_AES
505     #endif
506
507     #if (SSL_CFG_RC4_EN == DEF_ENABLED)
508         #undef  NO_RC4
509     #else
510         #define NO_RC4
511     #endif
512
513     #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
514         #undef  NO_RABBIT
515     #else
516         #define NO_RABBIT
517     #endif
518
519     #if (SSL_CFG_HC128_EN == DEF_ENABLED)
520         #undef  NO_HC128
521     #else
522         #define NO_HC128
523     #endif
524
525     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
526         #define BIG_ENDIAN_ORDER
527     #else
528         #undef  BIG_ENDIAN_ORDER
529         #define LITTLE_ENDIAN_ORDER
530     #endif
531
532     #if (SSL_CFG_MD4_EN == DEF_ENABLED)
533         #undef  NO_MD4
534     #else
535         #define NO_MD4
536     #endif
537
538     #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
539         #undef  NO_WRITEV
540     #else
541         #define NO_WRITEV
542     #endif
543
544     #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
545         #define NO_DEV_RANDOM   
546     #else
547         #undef  NO_DEV_RANDOM
548     #endif
549
550     #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
551         #define CYASSL_USER_IO   
552     #else
553         #undef  CYASSL_USER_IO
554     #endif
555
556     #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
557         #undef  LARGE_STATIC_BUFFERS
558         #undef  STATIC_CHUNKS_ONLY
559     #else
560         #define LARGE_STATIC_BUFFERS
561         #define STATIC_CHUNKS_ONLY
562     #endif
563
564     #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
565         #define  CYASSL_DER_LOAD
566     #else
567         #undef   CYASSL_DER_LOAD
568     #endif
569
570     #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
571         #define  CYASSL_DTLS
572     #else
573         #undef   CYASSL_DTLS
574     #endif
575
576     #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
577          #define CYASSL_CALLBACKS
578     #else
579          #undef  CYASSL_CALLBACKS
580     #endif
581
582     #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
583          #define USE_FAST_MATH
584     #else
585          #undef  USE_FAST_MATH
586     #endif
587
588     #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
589          #define TFM_TIMING_RESISTANT
590     #else
591          #undef  TFM_TIMING_RESISTANT
592     #endif
593
594 #endif /* MICRIUM */
595
596
597 #ifdef CYASSL_QL
598     #ifndef CYASSL_SEP
599         #define CYASSL_SEP
600     #endif
601     #ifndef OPENSSL_EXTRA
602         #define OPENSSL_EXTRA
603     #endif
604     #ifndef SESSION_CERTS
605         #define SESSION_CERTS
606     #endif
607     #ifndef HAVE_AESCCM
608         #define HAVE_AESCCM
609     #endif
610     #ifndef ATOMIC_USER
611         #define ATOMIC_USER
612     #endif
613     #ifndef CYASSL_DER_LOAD
614         #define CYASSL_DER_LOAD
615     #endif
616     #ifndef KEEP_PEER_CERT
617         #define KEEP_PEER_CERT
618     #endif
619     #ifndef HAVE_ECC
620         #define HAVE_ECC
621     #endif
622     #ifndef SESSION_INDEX
623         #define SESSION_INDEX
624     #endif
625 #endif /* CYASSL_QL */
626
627
628 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
629     !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
630     #define USE_CYASSL_MEMORY
631 #endif
632
633
634 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
635     #undef  KEEP_PEER_CERT
636     #define KEEP_PEER_CERT
637 #endif
638
639
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
644     #else
645         #define XSTREAM_ALIGNMENT
646     #endif
647 #endif
648
649
650 /* FreeScale MMCAU hardware crypto has 4 byte alignment */
651 #ifdef FREESCALE_MMCAU
652     #define CYASSL_MMCAU_ALIGNMENT 4
653 #endif
654
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
659     #ifdef CYASSL_AESNI
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
665     #else 
666         #define CYASSL_GENERAL_ALIGNMENT  0 
667     #endif
668 #endif
669
670 #ifdef HAVE_CRL
671     /* not widely supported yet */
672     #undef NO_SKID
673     #define NO_SKID
674 #endif
675
676
677 #ifdef __INTEL_COMPILER
678     #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
679 #endif
680
681
682 /* Place any other flags or defines here */
683
684
685 #ifdef __cplusplus
686     }   /* extern "C" */
687 #endif
688
689
690 #endif /* CTAO_CRYPT_SETTINGS_H */
691