]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CryptTest/RTE/wolfSSL/settings.h
Update CyaSSL to latest version.
[freertos] / FreeRTOS-Plus / Source / CyaSSL / IDE / MDK5-ARM / Projects / CryptTest / RTE / wolfSSL / settings.h
1 /* settings.h
2  *
3  * Copyright (C) 2006-2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 using LwIP native TCP socket settings */
88 /* #define HAVE_LWIP_NATIVE */
89
90 /* Uncomment next line if building for EROAD */
91 /* #define CYASSL_EROAD */
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 #ifdef MICROCHIP_PIC32
139     /* #define CYASSL_MICROCHIP_PIC32MZ */
140     #define SIZEOF_LONG_LONG 8
141     #define SINGLE_THREADED
142     #define CYASSL_USER_IO
143     #define NO_WRITEV
144     #define NO_DEV_RANDOM
145     #define NO_FILESYSTEM
146     #define USE_FAST_MATH
147     #define TFM_TIMING_RESISTANT
148 #endif
149
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
157     #define HAVE_AESGCM
158     #define NO_BIG_INT
159
160 #endif
161
162 #ifdef MICROCHIP_TCPIP_V5
163     /* include timer functions */
164     #include "TCPIP Stack/TCPIP.h"
165 #endif
166
167 #ifdef MICROCHIP_TCPIP
168     /* include timer, NTP functions */
169     #ifdef MICROCHIP_MPLAB_HARMONY
170         #include "tcpip/tcpip.h"
171     #else
172         #include "system/system_services.h"
173         #include "tcpip/sntp.h"
174     #endif
175 #endif
176
177 #ifdef MBED
178     #define CYASSL_USER_IO
179     #define NO_FILESYSTEM
180     #define NO_CERT
181     #define USE_CERT_BUFFERS_1024
182     #define NO_WRITEV
183     #define NO_DEV_RANDOM
184     #define NO_SHA512
185     #define NO_DH
186     #define NO_DSA
187     #define NO_HC128
188     #define HAVE_ECC
189     #define NO_SESSION_CACHE
190     #define CYASSL_CMSIS_RTOS
191 #endif
192
193
194 #ifdef CYASSL_EROAD
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
201     #define NO_OLD_TLS
202     #define NO_ASN
203     #define NO_BIG_INT
204     #define NO_RSA
205     #define NO_DSA
206     #define NO_DH
207     #define NO_CERTS
208     #define NO_PWDBASED
209     #define NO_DES3
210     #define NO_MD4
211     #define NO_RC4
212     #define NO_MD5
213     #define NO_SESSION_CACHE
214     #define NO_MAIN_DRIVER
215 #endif
216
217 #ifdef FREERTOS_WINSIM
218     #define FREERTOS
219     #define USE_WINDOWS_API
220 #endif
221
222
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
227 #endif
228
229
230 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
231     #include <stdlib.h>
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))
235 #endif
236
237 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
238     #undef  XMALLOC
239     #define XMALLOC     yaXMALLOC
240     #undef  XFREE
241     #define XFREE       yaXFREE
242     #undef  XREALLOC
243     #define XREALLOC    yaXREALLOC
244 #endif
245
246
247 #ifdef FREERTOS
248     #ifndef NO_WRITEV
249         #define NO_WRITEV
250     #endif
251     #ifndef NO_SHA512
252         #define NO_SHA512
253     #endif
254     #ifndef NO_DH
255         #define NO_DH
256     #endif
257     #ifndef NO_DSA
258         #define NO_DSA
259     #endif
260     #ifndef NO_HC128
261         #define NO_HC128
262     #endif
263
264     #ifndef SINGLE_THREADED
265         #include "FreeRTOS.h"
266         #include "semphr.h"
267     #endif
268 #endif
269
270 #ifdef EBSNET
271     #include "rtip.h"
272
273     /* #define DEBUG_CYASSL */
274     #define NO_CYASSL_DIR  /* tbd */
275
276     #if (POLLOS)
277         #define SINGLE_THREADED
278     #endif
279
280     #if (RTPLATFORM)
281         #if (!RTP_LITTLE_ENDIAN)
282             #define BIG_ENDIAN_ORDER
283         #endif
284     #else
285         #if (!KS_LITTLE_ENDIAN)
286             #define BIG_ENDIAN_ORDER
287         #endif
288     #endif
289
290     #if (WINMSP3)
291         #undef SIZEOF_LONG
292         #define SIZEOF_LONG_LONG 8
293     #else
294         #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
295     #endif
296
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))
300
301 #endif /* EBSNET */
302
303 #ifdef CYASSL_GAME_BUILD
304     #define SIZEOF_LONG_LONG 8
305     #if defined(__PPU) || defined(__XENON)
306         #define BIG_ENDIAN_ORDER
307     #endif
308 #endif
309
310 #ifdef CYASSL_LSR
311     #define HAVE_WEBSERVER
312     #define SIZEOF_LONG_LONG 8
313     #define CYASSL_LOW_MEMORY
314     #define NO_WRITEV
315     #define NO_SHA512
316     #define NO_DH
317     #define NO_DSA
318     #define NO_HC128
319     #define NO_DEV_RANDOM
320     #define NO_CYASSL_DIR
321     #define NO_RABBIT
322     #ifndef NO_FILESYSTEM
323         #define LSR_FS
324         #include "inc/hw_types.h"
325         #include "fs.h"
326     #endif
327     #define CYASSL_LWIP
328     #include <errno.h>  /* for tcp errno */
329     #define CYASSL_SAFERTOS
330     #if defined(__IAR_SYSTEMS_ICC__)
331         /* enum uses enum */
332         #pragma diag_suppress=Pa089
333     #endif
334 #endif
335
336 #ifdef CYASSL_SAFERTOS
337     #ifndef SINGLE_THREADED
338         #include "SafeRTOS/semphr.h"
339     #endif
340
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))
345 #endif
346
347 #ifdef CYASSL_LOW_MEMORY
348     #undef  RSA_LOW_MEM
349     #define RSA_LOW_MEM
350     #undef  CYASSL_SMALL_STACK
351     #define CYASSL_SMALL_STACK
352     #undef  TFM_TIMING_RESISTANT
353     #define TFM_TIMING_RESISTANT
354 #endif
355
356 #ifdef FREESCALE_MQX
357     #define SIZEOF_LONG_LONG 8
358     #define NO_WRITEV
359     #define NO_DEV_RANDOM
360     #define NO_RABBIT
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 */
366     #include "mqx.h"
367     #ifndef NO_FILESYSTEM
368         #include "mfs.h"
369         #include "fio.h"
370     #endif
371     #ifndef SINGLE_THREADED
372         #include "mutex.h"
373     #endif
374
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 */
378 #endif
379
380 #ifdef CYASSL_STM32F2
381     #define SIZEOF_LONG_LONG 8
382     #define NO_DEV_RANDOM
383     #define NO_CYASSL_DIR
384     #define NO_RABBIT
385     #define STM32F2_RNG
386     #define STM32F2_CRYPTO
387     #define KEIL_INTRINSICS
388 #endif
389
390 #ifdef MICRIUM
391
392     #include "stdlib.h"
393     #include "net_cfg.h"
394     #include "ssl_cfg.h"
395     #include "net_secure_os.h"
396
397     #define CYASSL_TYPES
398
399     typedef CPU_INT08U byte;
400     typedef CPU_INT16U word16;
401     typedef CPU_INT32U word32;
402
403     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
404         #define SIZEOF_LONG        4
405         #undef  SIZEOF_LONG_LONG
406     #else
407         #undef  SIZEOF_LONG
408         #define SIZEOF_LONG_LONG   8
409     #endif
410
411     #define STRING_USER
412
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), \
425                     (CPU_SIZE_T)(size)))
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
432
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), \
438                                  (p), (void *)0))
439     #define XREALLOC(p, n, h, t) realloc((p), (n))
440 #endif
441
442     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
443         #undef  NO_FILESYSTEM
444     #else
445         #define NO_FILESYSTEM
446     #endif
447
448     #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
449         #define DEBUG_CYASSL
450     #else
451         #undef  DEBUG_CYASSL
452     #endif
453
454     #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
455         #define OPENSSL_EXTRA
456     #else
457         #undef  OPENSSL_EXTRA
458     #endif
459
460     #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
461         #undef  SINGLE_THREADED
462     #else
463         #define SINGLE_THREADED
464     #endif
465
466     #if (SSL_CFG_DH_EN == DEF_ENABLED)
467         #undef  NO_DH
468     #else
469         #define NO_DH
470     #endif
471
472     #if (SSL_CFG_DSA_EN == DEF_ENABLED)
473         #undef  NO_DSA
474     #else
475         #define NO_DSA
476     #endif
477
478     #if (SSL_CFG_PSK_EN == DEF_ENABLED)
479         #undef  NO_PSK
480     #else
481         #define NO_PSK
482     #endif
483
484     #if (SSL_CFG_3DES_EN == DEF_ENABLED)
485         #undef  NO_DES
486     #else
487         #define NO_DES
488     #endif
489
490     #if (SSL_CFG_AES_EN == DEF_ENABLED)
491         #undef  NO_AES
492     #else
493         #define NO_AES
494     #endif
495
496     #if (SSL_CFG_RC4_EN == DEF_ENABLED)
497         #undef  NO_RC4
498     #else
499         #define NO_RC4
500     #endif
501
502     #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
503         #undef  NO_RABBIT
504     #else
505         #define NO_RABBIT
506     #endif
507
508     #if (SSL_CFG_HC128_EN == DEF_ENABLED)
509         #undef  NO_HC128
510     #else
511         #define NO_HC128
512     #endif
513
514     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
515         #define BIG_ENDIAN_ORDER
516     #else
517         #undef  BIG_ENDIAN_ORDER
518         #define LITTLE_ENDIAN_ORDER
519     #endif
520
521     #if (SSL_CFG_MD4_EN == DEF_ENABLED)
522         #undef  NO_MD4
523     #else
524         #define NO_MD4
525     #endif
526
527     #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
528         #undef  NO_WRITEV
529     #else
530         #define NO_WRITEV
531     #endif
532
533     #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
534         #define NO_DEV_RANDOM   
535     #else
536         #undef  NO_DEV_RANDOM
537     #endif
538
539     #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
540         #define CYASSL_USER_IO   
541     #else
542         #undef  CYASSL_USER_IO
543     #endif
544
545     #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
546         #undef  LARGE_STATIC_BUFFERS
547         #undef  STATIC_CHUNKS_ONLY
548     #else
549         #define LARGE_STATIC_BUFFERS
550         #define STATIC_CHUNKS_ONLY
551     #endif
552
553     #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
554         #define  CYASSL_DER_LOAD
555     #else
556         #undef   CYASSL_DER_LOAD
557     #endif
558
559     #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
560         #define  CYASSL_DTLS
561     #else
562         #undef   CYASSL_DTLS
563     #endif
564
565     #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
566          #define CYASSL_CALLBACKS
567     #else
568          #undef  CYASSL_CALLBACKS
569     #endif
570
571     #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
572          #define USE_FAST_MATH
573     #else
574          #undef  USE_FAST_MATH
575     #endif
576
577     #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
578          #define TFM_TIMING_RESISTANT
579     #else
580          #undef  TFM_TIMING_RESISTANT
581     #endif
582
583 #endif /* MICRIUM */
584
585
586 #ifdef CYASSL_QL
587     #ifndef CYASSL_SEP
588         #define CYASSL_SEP
589     #endif
590     #ifndef OPENSSL_EXTRA
591         #define OPENSSL_EXTRA
592     #endif
593     #ifndef SESSION_CERTS
594         #define SESSION_CERTS
595     #endif
596     #ifndef HAVE_AESCCM
597         #define HAVE_AESCCM
598     #endif
599     #ifndef ATOMIC_USER
600         #define ATOMIC_USER
601     #endif
602     #ifndef CYASSL_DER_LOAD
603         #define CYASSL_DER_LOAD
604     #endif
605     #ifndef KEEP_PEER_CERT
606         #define KEEP_PEER_CERT
607     #endif
608     #ifndef HAVE_ECC
609         #define HAVE_ECC
610     #endif
611     #ifndef SESSION_INDEX
612         #define SESSION_INDEX
613     #endif
614 #endif /* CYASSL_QL */
615
616
617 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
618     !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
619     #define USE_CYASSL_MEMORY
620 #endif
621
622
623 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
624     #undef  KEEP_PEER_CERT
625     #define KEEP_PEER_CERT
626 #endif
627
628
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
633     #else
634         #define XSTREAM_ALIGNMENT
635     #endif
636 #endif
637
638
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
643     #ifdef CYASSL_AESNI
644         #define CYASSL_GENERAL_ALIGNMENT 16
645     #elif defined(XSTREAM_ALIGNMENT)
646         #define CYASSL_GENERAL_ALIGNMENT  4
647     #else 
648         #define CYASSL_GENERAL_ALIGNMENT  0 
649     #endif
650 #endif
651
652 #ifdef HAVE_CRL
653     /* not widely supported yet */
654     #undef NO_SKID
655     #define NO_SKID
656 #endif
657
658 /* Place any other flags or defines here */
659
660
661 #ifdef __cplusplus
662     }   /* extern "C" */
663 #endif
664
665
666 #endif /* CTAO_CRYPT_SETTINGS_H */
667