Ivan Grokhotkov / hmac_md5

Dependents:   RFrec_full RFtrans_full

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-2012 Sawtooth Consulting Ltd.
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 FreeRTOS */
00049 /* #define FREERTOS */
00050 
00051 /* Uncomment next line if using FreeRTOS Windows Simulator */
00052 /* #define FREERTOS_WINSIM */
00053 
00054 /* Uncomment next line if using RTIP */
00055 /* #define EBSNET */
00056 
00057 /* Uncomment next line if using lwip */
00058 /* #define CYASSL_LWIP */
00059 
00060 /* Uncomment next line if building CyaSSL for a game console */
00061 /* #define CYASSL_GAME_BUILD */
00062 
00063 /* Uncomment next line if building CyaSSL for LSR */
00064 /* #define CYASSL_LSR */
00065 
00066 /* Uncomment next line if building CyaSSL for Freescale MQX/RTCS/MFS */
00067 /* #define FREESCALE_MQX */
00068 
00069 /* Uncomment next line if using STM32F2 */
00070 /* #define CYASSL_STM32F2 */
00071 
00072 
00073 #include "visibility.h"
00074 
00075 /* stream ciphers except arc4 need 32bit alignment, intel ok without */
00076 #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
00077     #define NO_XSTREAM_ALIGNMENT
00078 #else
00079     #define XSTREAM_ALIGNMENT
00080 #endif
00081 
00082 #ifdef IPHONE
00083     #define SIZEOF_LONG_LONG 8
00084 #endif
00085 
00086 #ifdef THREADX 
00087     #define SIZEOF_LONG_LONG 8
00088 #endif
00089 
00090 #ifdef MICROCHIP_PIC32
00091     #define SIZEOF_LONG_LONG 8
00092     #define SINGLE_THREADED
00093     #define CYASSL_USER_IO
00094     #define NO_WRITEV
00095     #define NO_DEV_RANDOM
00096     #define NO_FILESYSTEM
00097     #define USE_FAST_MATH
00098     #define TFM_TIMING_RESISTANT
00099 #endif
00100 
00101 #ifdef MBED
00102     #define SINGLE_THREADED
00103     #define CYASSL_USER_IO
00104     #define NO_WRITEV
00105     #define NO_DEV_RANDOM
00106     #define NO_SHA512
00107     #define NO_DH
00108     #define NO_DSA
00109     #define NO_HC128
00110 #endif /* MBED */
00111 
00112 #ifdef FREERTOS_WINSIM
00113     #define FREERTOS
00114     #define USE_WINDOWS_API
00115 #endif
00116 
00117 
00118 #ifdef CYASSL_LEANPSK
00119     #include <stdlib.h>
00120     #define XMALLOC(s, h, type)  malloc((s))
00121     #define XFREE(p, h, type)    free((p)) 
00122     #define XREALLOC(p, n, h, t) realloc((p), (n))
00123 #endif
00124 
00125 
00126 #ifdef FREERTOS
00127     #define NO_WRITEV
00128     #define NO_SHA512
00129     #define NO_DH
00130     #define NO_DSA
00131     #define NO_HC128
00132 
00133     #ifndef SINGLE_THREADED
00134         #include "FreeRTOS.h"
00135         #include "semphr.h"
00136     #endif
00137 #endif
00138 
00139 #ifdef EBSNET
00140     #include "rtip.h"
00141 
00142     /* #define DEBUG_CYASSL */
00143     #define NO_CYASSL_DIR  /* tbd */
00144 
00145     #if (POLLOS)
00146         #define SINGLE_THREADED
00147     #endif
00148 
00149     #if (RTPLATFORM)
00150         #if (!RTP_LITTLE_ENDIAN)
00151             #define BIG_ENDIAN_ORDER
00152         #endif
00153     #else
00154         #if (!KS_LITTLE_ENDIAN)
00155             #define BIG_ENDIAN_ORDER
00156         #endif
00157     #endif
00158 
00159     #if (WINMSP3)
00160         #undef SIZEOF_LONG
00161         #define SIZEOF_LONG_LONG 8
00162     #else
00163         #sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
00164     #endif
00165 
00166     #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
00167     #define XFREE(p, h, type) (rtp_free(p))
00168     #define XREALLOC(p, n, h, t) realloc((p), (n))
00169 
00170 #endif /* EBSNET */
00171 
00172 #ifdef CYASSL_GAME_BUILD
00173     #define SIZEOF_LONG_LONG 8
00174     #if defined(__PPU) || defined(__XENON)
00175         #define BIG_ENDIAN_ORDER
00176     #endif
00177 #endif
00178 
00179 #ifdef CYASSL_LSR
00180     #define HAVE_WEBSERVER
00181     #define SIZEOF_LONG_LONG 8
00182     #define CYASSL_LOW_MEMORY
00183     #define NO_WRITEV
00184     #define NO_SHA512
00185     #define NO_DH
00186     #define NO_DSA
00187     #define NO_HC128
00188     #define NO_DEV_RANDOM
00189     #define NO_CYASSL_DIR
00190     #define NO_RABBIT
00191     #ifndef NO_FILESYSTEM
00192         #define LSR_FS
00193         #include "inc/hw_types.h"
00194         #include "fs.h"
00195     #endif
00196     #define CYASSL_LWIP
00197     #include <errno.h>  /* for tcp errno */
00198     #define CYASSL_SAFERTOS
00199     #if defined(__IAR_SYSTEMS_ICC__)
00200         /* enum uses enum */
00201         #pragma diag_suppress=Pa089
00202     #endif
00203 #endif
00204 
00205 #ifdef CYASSL_SAFERTOS
00206     #ifndef SINGLE_THREADED
00207         #include "SafeRTOS/semphr.h"
00208     #endif
00209 
00210     #include "SafeRTOS/heap.h"
00211     #define XMALLOC(s, h, type)  pvPortMalloc((s))
00212     #define XFREE(p, h, type)    vPortFree((p)) 
00213     #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
00214 #endif
00215 
00216 #ifdef CYASSL_LOW_MEMORY
00217     #define RSA_LOW_MEM
00218     #define CYASSL_SMALL_STACK
00219     #define TFM_TIMING_RESISTANT
00220 #endif
00221 
00222 #ifdef FREESCALE_MQX
00223     #define SIZEOF_LONG_LONG 8
00224     #define NO_WRITEV
00225     #define NO_DEV_RANDOM
00226     #define NO_RABBIT
00227     #define NO_CYASSL_DIR
00228     #define USE_FAST_MATH
00229     #define TFM_TIMING_RESISTANT
00230     #define FREESCALE_K70_RNGA
00231     #ifndef NO_FILESYSTEM
00232         #include "mfs.h"
00233         #include "fio.h"
00234     #endif
00235     #ifndef SINGLE_THREADED
00236         #include "mutex.h"
00237     #endif
00238 
00239     #define XMALLOC(s, h, type) (void *)_mem_alloc_system((s))
00240     #define XFREE(p, h, type)   _mem_free(p)
00241     /* Note: MQX has no realloc, using fastmath above */
00242 #endif
00243 
00244 #ifdef CYASSL_STM32F2
00245     #define SIZEOF_LONG_LONG 8
00246     #define NO_DEV_RANDOM
00247     #define NO_CYASSL_DIR
00248     #define NO_RABBIT
00249     #define STM32F2_RNG
00250     #define STM32F2_CRYPTO
00251     #define KEIL_INTRINSICS
00252 #endif
00253 
00254 #ifdef MICRIUM
00255 
00256     #include "stdlib.h"
00257     #include "net_cfg.h"
00258     #include "ssl_cfg.h"
00259     #include "net_secure_os.h"
00260 
00261     #define CYASSL_TYPES
00262 
00263     typedef CPU_INT08U byte;
00264     typedef CPU_INT16U word16;
00265     typedef CPU_INT32U word32;
00266 
00267     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
00268         #define SIZEOF_LONG        4
00269         #undef  SIZEOF_LONG_LONG
00270     #else
00271         #undef  SIZEOF_LONG
00272         #define SIZEOF_LONG_LONG   8
00273     #endif
00274 
00275     #define STRING_USER
00276 
00277     #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
00278     #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
00279                     ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
00280                      (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
00281     #define XSTRNCMP(pstr_1, pstr_2, len_max) \
00282                     ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
00283                      (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))  
00284     #define XSTRSTR(pstr, pstr_srch) \
00285                     ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
00286                      (CPU_CHAR *)(pstr_srch)))
00287     #define XMEMSET(pmem, data_val, size) \
00288                     ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
00289                     (CPU_SIZE_T)(size)))
00290     #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
00291                      (void *)(psrc), (CPU_SIZE_T)(size)))
00292     #define XMEMCMP(pmem_1, pmem_2, size) \
00293                    (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
00294                      (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
00295     #define XMEMMOVE XMEMCPY
00296 
00297 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
00298     #define MICRIUM_MALLOC    
00299     #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
00300                                  (CPU_SIZE_T)(s), (void *)0))
00301     #define XFREE(p, h, type)   (NetSecure_BlkFree((CPU_INT08U)(type), \
00302                                  (p), (void *)0))
00303     #define XREALLOC(p, n, h, t) realloc((p), (n))
00304 #endif
00305 
00306     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
00307         #undef  NO_FILESYSTEM
00308     #else
00309         #define NO_FILESYSTEM
00310     #endif
00311 
00312     #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
00313         #define DEBUG_CYASSL
00314     #else
00315         #undef  DEBUG_CYASSL
00316     #endif
00317 
00318     #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
00319         #define OPENSSL_EXTRA
00320     #else
00321         #undef  OPENSSL_EXTRA
00322     #endif
00323 
00324     #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
00325         #undef  SINGLE_THREADED
00326     #else
00327         #define SINGLE_THREADED
00328     #endif
00329 
00330     #if (SSL_CFG_DH_EN == DEF_ENABLED)
00331         #undef  NO_DH
00332     #else
00333         #define NO_DH
00334     #endif
00335 
00336     #if (SSL_CFG_DSA_EN == DEF_ENABLED)
00337         #undef  NO_DSA
00338     #else
00339         #define NO_DSA
00340     #endif
00341 
00342     #if (SSL_CFG_PSK_EN == DEF_ENABLED)
00343         #undef  NO_PSK
00344     #else
00345         #define NO_PSK
00346     #endif
00347 
00348     #if (SSL_CFG_3DES_EN == DEF_ENABLED)
00349         #undef  NO_DES
00350     #else
00351         #define NO_DES
00352     #endif
00353 
00354     #if (SSL_CFG_AES_EN == DEF_ENABLED)
00355         #undef  NO_AES
00356     #else
00357         #define NO_AES
00358     #endif
00359 
00360     #if (SSL_CFG_RC4_EN == DEF_ENABLED)
00361         #undef  NO_RC4
00362     #else
00363         #define NO_RC4
00364     #endif
00365 
00366     #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
00367         #undef  NO_RABBIT
00368     #else
00369         #define NO_RABBIT
00370     #endif
00371 
00372     #if (SSL_CFG_HC128_EN == DEF_ENABLED)
00373         #undef  NO_HC128
00374     #else
00375         #define NO_HC128
00376     #endif
00377 
00378     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
00379         #define BIG_ENDIAN_ORDER
00380     #else
00381         #undef  BIG_ENDIAN_ORDER
00382         #define LITTLE_ENDIAN_ORDER
00383     #endif
00384 
00385     #if (SSL_CFG_MD4_EN == DEF_ENABLED)
00386         #undef  NO_MD4
00387     #else
00388         #define NO_MD4
00389     #endif
00390 
00391     #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
00392         #undef  NO_WRITEV
00393     #else
00394         #define NO_WRITEV
00395     #endif
00396 
00397     #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
00398         #define NO_DEV_RANDOM   
00399     #else
00400         #undef  NO_DEV_RANDOM
00401     #endif
00402 
00403     #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
00404         #define CYASSL_USER_IO   
00405     #else
00406         #undef  CYASSL_USER_IO
00407     #endif
00408 
00409     #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
00410         #undef  LARGE_STATIC_BUFFERS
00411         #undef  STATIC_CHUNKS_ONLY
00412     #else
00413         #define LARGE_STATIC_BUFFERS
00414         #define STATIC_CHUNKS_ONLY
00415     #endif
00416 
00417     #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
00418         #define  CYASSL_DER_LOAD
00419     #else
00420         #undef   CYASSL_DER_LOAD
00421     #endif
00422 
00423     #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
00424         #define  CYASSL_DTLS
00425     #else
00426         #undef   CYASSL_DTLS
00427     #endif
00428 
00429     #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
00430          #define CYASSL_CALLBACKS
00431     #else
00432          #undef  CYASSL_CALLBACKS
00433     #endif
00434 
00435     #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
00436          #define USE_FAST_MATH
00437     #else
00438          #undef  USE_FAST_MATH
00439     #endif
00440 
00441     #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
00442          #define TFM_TIMING_RESISTANT
00443     #else
00444          #undef  TFM_TIMING_RESISTANT
00445     #endif
00446 
00447 #endif /* MICRIUM */
00448 
00449 
00450 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
00451                               !defined(CYASSL_LEANPSK)
00452     #define USE_CYASSL_MEMORY
00453 #endif
00454 
00455 /* Place any other flags or defines here */
00456 
00457 
00458 #ifdef __cplusplus
00459     }   /* extern "C" */
00460 #endif
00461 
00462 
00463 #endif /* CTAO_CRYPT_SETTINGS_H */
00464