This is a port of cyaSSL 2.7.0.

Dependents:   CyaSSL_DTLS_Cellular CyaSSL_DTLS_Ethernet

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers settings.h Source File

settings.h

00001 /* settings.h
00002  *
00003  * Copyright (C) 2006-2013 wolfSSL Inc.
00004  *
00005  * This file is part of CyaSSL.
00006  *
00007  * CyaSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * CyaSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00020  */
00021 
00022 /* Place OS specific preprocessor flags, defines, includes here, will be
00023    included into every file because types.h includes it */
00024 
00025 
00026 #ifndef CTAO_CRYPT_SETTINGS_H
00027 #define CTAO_CRYPT_SETTINGS_H
00028 
00029 #ifdef __cplusplus
00030     extern "C" {
00031 #endif
00032 
00033 /* Uncomment next line if using IPHONE */
00034 /* #define IPHONE */
00035 
00036 /* Uncomment next line if using ThreadX */
00037 /* #define THREADX */
00038 
00039 /* Uncomment next line if using Micrium ucOS */
00040 /* #define MICRIUM */
00041 
00042 /* Uncomment next line if using Mbed */
00043 #define MBED
00044 
00045 /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
00046 /* #define MICROCHIP_PIC32 */
00047 
00048 /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
00049 /* #define MICROCHIP_TCPIP_V5 */
00050 
00051 /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
00052 /* #define MICROCHIP_TCPIP */
00053 
00054 /* Uncomment next line if using FreeRTOS */
00055 /* #define FREERTOS */
00056 
00057 /* Uncomment next line if using FreeRTOS Windows Simulator */
00058 /* #define FREERTOS_WINSIM */
00059 
00060 /* Uncomment next line if using RTIP */
00061 /* #define EBSNET */
00062 
00063 /* Uncomment next line if using lwip */
00064 #define CYASSL_LWIP
00065 
00066 /* Uncomment next line if building CyaSSL for a game console */
00067 /* #define CYASSL_GAME_BUILD */
00068 
00069 /* Uncomment next line if building CyaSSL for LSR */
00070 /* #define CYASSL_LSR */
00071 
00072 /* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */
00073 /* #define FREESCALE_MQX */
00074 
00075 /* Uncomment next line if using STM32F2 */
00076 /* #define CYASSL_STM32F2 */
00077 
00078 
00079 #include <cyassl/ctaocrypt/visibility.h>
00080 
00081 #ifdef IPHONE
00082     #define SIZEOF_LONG_LONG 8
00083 #endif
00084 
00085 #ifdef THREADX 
00086     #define SIZEOF_LONG_LONG 8
00087 #endif
00088 
00089 #ifdef MICROCHIP_PIC32
00090     #define SIZEOF_LONG_LONG 8
00091     #define SINGLE_THREADED
00092     #define CYASSL_USER_IO
00093     #define NO_WRITEV
00094     #define NO_DEV_RANDOM
00095     #define NO_FILESYSTEM
00096     #define USE_FAST_MATH
00097     #define TFM_TIMING_RESISTANT
00098 #endif
00099 
00100 #ifdef MICROCHIP_TCPIP_V5
00101     /* include timer functions */
00102     #include "TCPIP Stack/TCPIP.h"
00103 #endif
00104 
00105 #ifdef MICROCHIP_TCPIP
00106     /* include timer, NTP functions */
00107     #include "system/system_services.h"
00108     #include "tcpip/sntp.h"
00109 #endif
00110 
00111 #ifdef MBED
00112     #define SINGLE_THREADED
00113     //#define CYASSL_USER_IO
00114     #define NO_WRITEV
00115     #define NO_DEV_RANDOM // write an OS-specific GenerateSeed() function (found in “ctaocrypt/src/random.c”).
00116     #define NO_SHA512
00117     //#define NO_DH
00118     #define NO_DSA
00119     #define NO_HC128
00120     #define NO_FILESYSTEM
00121     #define DEBUG_CYASSL
00122     //#define NO_CERTS
00123     #define SSL_CFG_PSK_EN
00124     #define CYASSL_DTLS
00125     #define SSL_CFG_DTLS_EN
00126     #define NO_DES3 // 3 des is being phased out
00127     #define NO_MD4 // MD4 is broken and shouldn't be used
00128     #define SMALL_SESSION_CACHE
00129     //#define CYASSL_CALLBACKS
00130     //#define USER_TIME
00131     //#define USE_FAST_MATH // assembler implementation of bigInt routines
00132     //#define TFM_TIMING_RESISTANT // uses less memory when fast math is enabled
00133 #endif /* MBED */
00134 
00135 #ifdef FREERTOS_WINSIM
00136     #define FREERTOS
00137     #define USE_WINDOWS_API
00138 #endif
00139 
00140 
00141 #if defined(CYASSL_LEANPSK) && !defined(XMALLOC_USER)
00142     #include <stdlib.h>
00143     #define XMALLOC(s, h, type)  malloc((s))
00144     #define XFREE(p, h, type)    free((p)) 
00145     #define XREALLOC(p, n, h, t) realloc((p), (n))
00146 #endif
00147 
00148 #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
00149     #undef  XMALLOC
00150     #define XMALLOC     yaXMALLOC
00151     #undef  XFREE
00152     #define XFREE       yaXFREE
00153     #undef  XREALLOC
00154     #define XREALLOC    yaXREALLOC
00155 #endif
00156 
00157 
00158 #ifdef FREERTOS
00159     #ifndef NO_WRITEV
00160         #define NO_WRITEV
00161     #endif
00162     #ifndef NO_SHA512
00163         #define NO_SHA512
00164     #endif
00165     #ifndef NO_DH
00166         #define NO_DH
00167     #endif
00168     #ifndef NO_DSA
00169         #define NO_DSA
00170     #endif
00171     #ifndef NO_HC128
00172         #define NO_HC128
00173     #endif
00174 
00175     #ifndef SINGLE_THREADED
00176         #include "FreeRTOS.h"
00177         #include "semphr.h"
00178     #endif
00179 #endif
00180 
00181 #ifdef EBSNET
00182     #include "rtip.h"
00183 
00184     /* #define DEBUG_CYASSL */
00185     #define NO_CYASSL_DIR  /* tbd */
00186 
00187     #if (POLLOS)
00188         #define SINGLE_THREADED
00189     #endif
00190 
00191     #if (RTPLATFORM)
00192         #if (!RTP_LITTLE_ENDIAN)
00193             #define BIG_ENDIAN_ORDER
00194         #endif
00195     #else
00196         #if (!KS_LITTLE_ENDIAN)
00197             #define BIG_ENDIAN_ORDER
00198         #endif
00199     #endif
00200 
00201     #if (WINMSP3)
00202         #undef SIZEOF_LONG
00203         #define SIZEOF_LONG_LONG 8
00204     #else
00205         #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
00206     #endif
00207 
00208     #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
00209     #define XFREE(p, h, type) (rtp_free(p))
00210     #define XREALLOC(p, n, h, t) realloc((p), (n))
00211 
00212 #endif /* EBSNET */
00213 
00214 #ifdef CYASSL_GAME_BUILD
00215     #define SIZEOF_LONG_LONG 8
00216     #if defined(__PPU) || defined(__XENON)
00217         #define BIG_ENDIAN_ORDER
00218     #endif
00219 #endif
00220 
00221 #ifdef CYASSL_LSR
00222     #define HAVE_WEBSERVER
00223     #define SIZEOF_LONG_LONG 8
00224     #define CYASSL_LOW_MEMORY
00225     #define NO_WRITEV
00226     #define NO_SHA512
00227     #define NO_DH
00228     #define NO_DSA
00229     #define NO_HC128
00230     #define NO_DEV_RANDOM
00231     #define NO_CYASSL_DIR
00232     #define NO_RABBIT
00233     #ifndef NO_FILESYSTEM
00234         #define LSR_FS
00235         #include "inc/hw_types.h"
00236         #include "fs.h"
00237     #endif
00238     #define CYASSL_LWIP
00239     #include <errno.h>  /* for tcp errno */
00240     #define CYASSL_SAFERTOS
00241     #if defined(__IAR_SYSTEMS_ICC__)
00242         /* enum uses enum */
00243         #pragma diag_suppress=Pa089
00244     #endif
00245 #endif
00246 
00247 #ifdef CYASSL_SAFERTOS
00248     #ifndef SINGLE_THREADED
00249         #include "SafeRTOS/semphr.h"
00250     #endif
00251 
00252     #include "SafeRTOS/heap.h"
00253     #define XMALLOC(s, h, type)  pvPortMalloc((s))
00254     #define XFREE(p, h, type)    vPortFree((p)) 
00255     #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
00256 #endif
00257 
00258 #ifdef CYASSL_LOW_MEMORY
00259     #undef  RSA_LOW_MEM
00260     #define RSA_LOW_MEM
00261     #undef  CYASSL_SMALL_STACK
00262     #define CYASSL_SMALL_STACK
00263     #undef  TFM_TIMING_RESISTANT
00264     #define TFM_TIMING_RESISTANT
00265 #endif
00266 
00267 #ifdef FREESCALE_MQX
00268     #define SIZEOF_LONG_LONG 8
00269     #define NO_WRITEV
00270     #define NO_DEV_RANDOM
00271     #define NO_RABBIT
00272     #define NO_CYASSL_DIR
00273     #define USE_FAST_MATH
00274     #define TFM_TIMING_RESISTANT
00275     #define FREESCALE_K70_RNGA
00276     #ifndef NO_FILESYSTEM
00277         #include "mfs.h"
00278         #include "fio.h"
00279     #endif
00280     #ifndef SINGLE_THREADED
00281         #include "mutex.h"
00282     #endif
00283 
00284     #define XMALLOC(s, h, type) (void *)_mem_alloc_system((s))
00285     #define XFREE(p, h, type)   _mem_free(p)
00286     /* Note: MQX has no realloc, using fastmath above */
00287 #endif
00288 
00289 #ifdef CYASSL_STM32F2
00290     #define SIZEOF_LONG_LONG 8
00291     #define NO_DEV_RANDOM
00292     #define NO_CYASSL_DIR
00293     #define NO_RABBIT
00294     #define STM32F2_RNG
00295     #define STM32F2_CRYPTO
00296     #define KEIL_INTRINSICS
00297 #endif
00298 
00299 #ifdef MICRIUM
00300 
00301     #include "stdlib.h"
00302     #include "net_cfg.h"
00303     #include "ssl_cfg.h"
00304     #include "net_secure_os.h"
00305 
00306     #define CYASSL_TYPES
00307 
00308     typedef CPU_INT08U byte;
00309     typedef CPU_INT16U word16;
00310     typedef CPU_INT32U word32;
00311 
00312     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
00313         #define SIZEOF_LONG        4
00314         #undef  SIZEOF_LONG_LONG
00315     #else
00316         #undef  SIZEOF_LONG
00317         #define SIZEOF_LONG_LONG   8
00318     #endif
00319 
00320     #define STRING_USER
00321 
00322     #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
00323     #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
00324                     ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
00325                      (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
00326     #define XSTRNCMP(pstr_1, pstr_2, len_max) \
00327                     ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
00328                      (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))  
00329     #define XSTRSTR(pstr, pstr_srch) \
00330                     ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
00331                      (CPU_CHAR *)(pstr_srch)))
00332     #define XMEMSET(pmem, data_val, size) \
00333                     ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
00334                     (CPU_SIZE_T)(size)))
00335     #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
00336                      (void *)(psrc), (CPU_SIZE_T)(size)))
00337     #define XMEMCMP(pmem_1, pmem_2, size) \
00338                    (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
00339                      (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
00340     #define XMEMMOVE XMEMCPY
00341 
00342 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
00343     #define MICRIUM_MALLOC    
00344     #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
00345                                  (CPU_SIZE_T)(s), (void *)0))
00346     #define XFREE(p, h, type)   (NetSecure_BlkFree((CPU_INT08U)(type), \
00347                                  (p), (void *)0))
00348     #define XREALLOC(p, n, h, t) realloc((p), (n))
00349 #endif
00350 
00351     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
00352         #undef  NO_FILESYSTEM
00353     #else
00354         #define NO_FILESYSTEM
00355     #endif
00356 
00357     #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
00358         #define DEBUG_CYASSL
00359     #else
00360         #undef  DEBUG_CYASSL
00361     #endif
00362 
00363     #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
00364         #define OPENSSL_EXTRA
00365     #else
00366         #undef  OPENSSL_EXTRA
00367     #endif
00368 
00369     #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
00370         #undef  SINGLE_THREADED
00371     #else
00372         #define SINGLE_THREADED
00373     #endif
00374 
00375     #if (SSL_CFG_DH_EN == DEF_ENABLED)
00376         #undef  NO_DH
00377     #else
00378         #define NO_DH
00379     #endif
00380 
00381     #if (SSL_CFG_DSA_EN == DEF_ENABLED)
00382         #undef  NO_DSA
00383     #else
00384         #define NO_DSA
00385     #endif
00386 
00387     #if (SSL_CFG_PSK_EN == DEF_ENABLED)
00388         #undef  NO_PSK
00389     #else
00390         #define NO_PSK
00391     #endif
00392 
00393     #if (SSL_CFG_3DES_EN == DEF_ENABLED)
00394         #undef  NO_DES
00395     #else
00396         #define NO_DES
00397     #endif
00398 
00399     #if (SSL_CFG_AES_EN == DEF_ENABLED)
00400         #undef  NO_AES
00401     #else
00402         #define NO_AES
00403     #endif
00404 
00405     #if (SSL_CFG_RC4_EN == DEF_ENABLED)
00406         #undef  NO_RC4
00407     #else
00408         #define NO_RC4
00409     #endif
00410 
00411     #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
00412         #undef  NO_RABBIT
00413     #else
00414         #define NO_RABBIT
00415     #endif
00416 
00417     #if (SSL_CFG_HC128_EN == DEF_ENABLED)
00418         #undef  NO_HC128
00419     #else
00420         #define NO_HC128
00421     #endif
00422 
00423     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
00424         #define BIG_ENDIAN_ORDER
00425     #else
00426         #undef  BIG_ENDIAN_ORDER
00427         #define LITTLE_ENDIAN_ORDER
00428     #endif
00429 
00430     #if (SSL_CFG_MD4_EN == DEF_ENABLED)
00431         #undef  NO_MD4
00432     #else
00433         #define NO_MD4
00434     #endif
00435 
00436     #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
00437         #undef  NO_WRITEV
00438     #else
00439         #define NO_WRITEV
00440     #endif
00441 
00442     #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
00443         #define NO_DEV_RANDOM   
00444     #else
00445         #undef  NO_DEV_RANDOM
00446     #endif
00447 
00448     #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
00449         #define CYASSL_USER_IO   
00450     #else
00451         #undef  CYASSL_USER_IO
00452     #endif
00453 
00454     #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
00455         #undef  LARGE_STATIC_BUFFERS
00456         #undef  STATIC_CHUNKS_ONLY
00457     #else
00458         #define LARGE_STATIC_BUFFERS
00459         #define STATIC_CHUNKS_ONLY
00460     #endif
00461 
00462     #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
00463         #define  CYASSL_DER_LOAD
00464     #else
00465         #undef   CYASSL_DER_LOAD
00466     #endif
00467 
00468     #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
00469         #define  CYASSL_DTLS
00470     #else
00471         #undef   CYASSL_DTLS
00472     #endif
00473 
00474     #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
00475          #define CYASSL_CALLBACKS
00476     #else
00477          #undef  CYASSL_CALLBACKS
00478     #endif
00479 
00480     #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
00481          #define USE_FAST_MATH
00482     #else
00483          #undef  USE_FAST_MATH
00484     #endif
00485 
00486     #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
00487          #define TFM_TIMING_RESISTANT
00488     #else
00489          #undef  TFM_TIMING_RESISTANT
00490     #endif
00491 
00492 #endif /* MICRIUM */
00493 
00494 
00495 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
00496     !defined(CYASSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
00497     #define USE_CYASSL_MEMORY
00498 #endif
00499 
00500 
00501 #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
00502     #undef  KEEP_PEER_CERT
00503     #define KEEP_PEER_CERT
00504 #endif
00505 
00506 
00507 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
00508 #ifndef XSTREAM_ALIGNMENT
00509     #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
00510         #define NO_XSTREAM_ALIGNMENT
00511     #else
00512         #define XSTREAM_ALIGNMENT
00513     #endif
00514 #endif
00515 
00516 
00517 /* if using hardware crypto and have alignment requirements, specify the
00518    requirement here.  The record header of SSL/TLS will prvent easy alignment.
00519    This hint tries to help as much as possible.  */
00520 #ifndef CYASSL_GENERAL_ALIGNMENT
00521     #ifdef CYASSL_AESNI
00522         #define CYASSL_GENERAL_ALIGNMENT 16
00523     #elif defined(XSTREAM_ALIGNMENT)
00524         #define CYASSL_GENERAL_ALIGNMENT  4
00525     #else 
00526         #define CYASSL_GENERAL_ALIGNMENT  0 
00527     #endif
00528 #endif
00529 
00530 #ifdef HAVE_CRL
00531     /* not widely supported yet */
00532     #undef NO_SKID
00533     #define NO_SKID
00534 #endif
00535 
00536 /* Place any other flags or defines here */
00537 
00538 
00539 #ifdef __cplusplus
00540     }   /* extern "C" */
00541 #endif
00542 
00543 
00544 #endif /* CTAO_CRYPT_SETTINGS_H */
00545