CyaSSL is an SSL library for devices like mbed.

Dependents:   cyassl-client Sync

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers os_settings.h Source File

os_settings.h

00001 /* os_settings.h
00002  *
00003  * Copyright (C) 2006-2010 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 #ifndef CTAO_CRYPT_OS_SETTINGS_H
00026 #define CTAO_CRYPT_OS_SETTINGS_H
00027 
00028 #ifdef __cplusplus
00029     extern "C" {
00030 #endif
00031 
00032 /* Uncomment next line if using IPHONE */
00033 /* #define IPHONE */
00034 
00035 /* Uncomment next line if using ThreadX */
00036 /* #define THREADX */
00037 
00038 /* Uncomment next line if using Micrium ucOS */
00039 /* #define MICRIUM */
00040 
00041 
00042 #ifdef IPHONE
00043     #define SIZEOF_LONG_LONG 8
00044 #endif
00045 
00046 #ifdef THREADX 
00047     #define SIZEOF_LONG_LONG 8
00048 #endif
00049 
00050 #define MBED
00051 
00052 #ifdef MBED
00053 
00054     #define SINGLE_THREADED
00055     #define CYASSL_USER_IO
00056     #define NO_WRITEV
00057     #define NO_DEV_RANDOM
00058     #define NO_SHA512
00059     #define NO_DH
00060     #define NO_DSA
00061     #define NO_HC128
00062 
00063 #endif /* MBED */
00064 
00065 
00066 #ifdef MICRIUM
00067 
00068     #include "net_cfg.h"
00069     #include "cyassl_cfg.h"
00070     #include "net_secure_os.h"
00071 
00072     #define CYASSL_TYPES
00073 
00074     typedef CPU_INT08U byte;
00075     typedef CPU_INT16U word16;
00076     typedef CPU_INT32U word32;
00077 
00078     #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
00079         #define SIZEOF_LONG        8
00080         #undef  SIZEOF_LONG_LONG
00081     #else
00082         #undef  SIZEOF_LONG
00083         #define SIZEOF_LONG_LONG   8
00084     #endif
00085 
00086     #define STRING_USER
00087 
00088     #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
00089     #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
00090                     ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
00091                      (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
00092     #define XSTRNCMP(pstr_1, pstr_2, len_max) \
00093                     ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
00094                      (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))  
00095     #define XSTRSTR(pstr, pstr_srch) \
00096                     ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
00097                      (CPU_CHAR *)(pstr_srch)))
00098     #define XMEMSET(pmem, data_val, size) \
00099                     ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
00100                     (CPU_SIZE_T)(size)))
00101     #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
00102                      (void *)(psrc), (CPU_SIZE_T)(size)))
00103     #define XMEMCMP(pmem_1, pmem_2, size) \
00104                    (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
00105                      (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
00106 
00107     #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
00108         #define MICRIUM_MALLOC
00109         #define XMALLOC(s, h, type) (((type) <= DYNAMIC_TYPE_SIGNER) ? \
00110                                  ((void *)NetSecure_Malloc((CPU_INT08U)(type), \
00111                                  (CPU_SIZE_T)(s))) : malloc(s))
00112         #define XFREE(p, h, type)   (((type) <= DYNAMIC_TYPE_SIGNER) ? \
00113                           (NetSecure_Free((CPU_INT08U)(type), (p))) : free((p)))
00114         #define XREALLOC(p, n, h, t) realloc((p), (n))
00115     #endif
00116 
00117     #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
00118         #undef  NO_FILESYSTEM
00119     #else
00120         #define NO_FILESYSTEM
00121     #endif
00122 
00123     #if (CYASSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
00124         #define DEBUG_CYASSL
00125     #else
00126         #undef  DEBUG_CYASSL
00127     #endif
00128 
00129     #if (CYASSL_CFG_OPENSSL_EN == DEF_ENABLED)
00130         #define OPENSSL_EXTRA
00131     #else
00132         #undef  OPENSSL_EXTRA
00133     #endif
00134 
00135     #if (CYASSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
00136         #undef  SINGLE_THREADED
00137     #else
00138         #define SINGLE_THREADED
00139     #endif
00140 
00141     #if (CYASSL_CFG_DH_EN == DEF_ENABLED)
00142         #undef  NO_DH
00143     #else
00144         #define NO_DH
00145     #endif
00146 
00147     #if (CYASSL_CFG_DSA_EN == DEF_ENABLED)
00148         #undef  NO_DSA
00149     #else
00150         #define NO_DSA
00151     #endif
00152 
00153     #if (CYASSL_CFG_PSK_EN == DEF_ENABLED)
00154         #undef  NO_PSK
00155     #else
00156         #define NO_PSK
00157     #endif
00158 
00159     #if (CYASSL_CFG_3DES_EN == DEF_ENABLED)
00160         #undef  NO_DES
00161     #else
00162         #define NO_DES
00163     #endif
00164 
00165     #if (CYASSL_CFG_AES_EN == DEF_ENABLED)
00166         #undef  NO_AES
00167     #else
00168         #define NO_AES
00169     #endif
00170 
00171     #if (CYASSL_CFG_RC4_EN == DEF_ENABLED)
00172         #undef  NO_RC4
00173     #else
00174         #define NO_RC4
00175     #endif
00176 
00177     #if (CYASSL_CFG_RABBIT_EN == DEF_ENABLED)
00178         #undef  NO_RABBIT
00179     #else
00180         #define NO_RABBIT
00181     #endif
00182 
00183     #if (CYASSL_CFG_HC128_EN == DEF_ENABLED)
00184         #undef  NO_HC128
00185     #else
00186         #define NO_HC128
00187     #endif
00188 
00189     #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
00190         #define BIG_ENDIAN_ORDER
00191     #else
00192         #undef  BIG_ENDIAN_ORDER
00193         #define LITTLE_ENDIAN_ORDER
00194     #endif
00195 
00196 
00197     #define  NO_MD4
00198     #define  NO_WRITEV
00199     #define  NO_DEV_RANDOM
00200     #define  CYASSL_USER_IO
00201     #define  LARGE_STATIC_BUFFERS
00202     #define  CYASSL_DER_LOAD
00203     #undef   CYASSL_DTLS
00204 
00205 #endif /* MICRIUM */
00206 
00207 /* Place any other flags or defines here */
00208 
00209 
00210 #ifdef __cplusplus
00211     }   /* extern "C" */
00212 #endif
00213 
00214 
00215 #endif /* CTAO_CRYPT_OS_SETTINGS_H */
00216