os_settings.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /* os_settings.h
  2. *
  3. * Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
  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. /* Place OS specific preprocessor flags, defines, includes here, will be
  22. included into every file because types.h includes it */
  23. #ifndef CTAO_CRYPT_OS_SETTINGS_H
  24. #define CTAO_CRYPT_OS_SETTINGS_H
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Uncomment next line if using IPHONE */
  29. /* #define IPHONE */
  30. /* Uncomment next line if using ThreadX */
  31. /* #define THREADX */
  32. /* Uncomment next line if using Micrium ucOS */
  33. /* #define MICRIUM */
  34. /* Uncomment next line if using Mbed */
  35. /* #define MBED */
  36. #ifdef IPHONE
  37. #define SIZEOF_LONG_LONG 8
  38. #endif
  39. #ifdef THREADX
  40. #define SIZEOF_LONG_LONG 8
  41. #endif
  42. #ifdef MBED
  43. #define SINGLE_THREADED
  44. #define CYASSL_USER_IO
  45. #define NO_WRITEV
  46. #define NO_DEV_RANDOM
  47. #define NO_SHA512
  48. #define NO_DH
  49. #define NO_DSA
  50. #define NO_HC128
  51. #endif /* MBED */
  52. #ifdef MICRIUM
  53. #include "net_cfg.h"
  54. #include "ssl_cfg.h"
  55. #include "net_secure_os.h"
  56. #define CYASSL_TYPES
  57. typedef CPU_INT08U byte;
  58. typedef CPU_INT16U word16;
  59. typedef CPU_INT32U word32;
  60. #if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
  61. #define SIZEOF_LONG 4
  62. #undef SIZEOF_LONG_LONG
  63. #else
  64. #undef SIZEOF_LONG
  65. #define SIZEOF_LONG_LONG 8
  66. #endif
  67. #define STRING_USER
  68. #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
  69. #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
  70. ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
  71. (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
  72. #define XSTRNCMP(pstr_1, pstr_2, len_max) \
  73. ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
  74. (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
  75. #define XSTRSTR(pstr, pstr_srch) \
  76. ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
  77. (CPU_CHAR *)(pstr_srch)))
  78. #define XMEMSET(pmem, data_val, size) \
  79. ((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
  80. (CPU_SIZE_T)(size)))
  81. #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
  82. (void *)(psrc), (CPU_SIZE_T)(size)))
  83. #define XMEMCMP(pmem_1, pmem_2, size) \
  84. (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
  85. (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
  86. #define XMEMMOVE XMEMCPY
  87. #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
  88. #define MICRIUM_MALLOC
  89. #define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
  90. (CPU_SIZE_T)(s), (void *)0))
  91. #define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
  92. (p), (void *)0))
  93. #define XREALLOC(p, n, h, t) realloc((p), (n))
  94. #endif
  95. #if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
  96. #undef NO_FILESYSTEM
  97. #else
  98. #define NO_FILESYSTEM
  99. #endif
  100. #if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
  101. #define DEBUG_CYASSL
  102. #else
  103. #undef DEBUG_CYASSL
  104. #endif
  105. #if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
  106. #define OPENSSL_EXTRA
  107. #else
  108. #undef OPENSSL_EXTRA
  109. #endif
  110. #if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
  111. #undef SINGLE_THREADED
  112. #else
  113. #define SINGLE_THREADED
  114. #endif
  115. #if (SSL_CFG_DH_EN == DEF_ENABLED)
  116. #undef NO_DH
  117. #else
  118. #define NO_DH
  119. #endif
  120. #if (SSL_CFG_DSA_EN == DEF_ENABLED)
  121. #undef NO_DSA
  122. #else
  123. #define NO_DSA
  124. #endif
  125. #if (SSL_CFG_PSK_EN == DEF_ENABLED)
  126. #undef NO_PSK
  127. #else
  128. #define NO_PSK
  129. #endif
  130. #if (SSL_CFG_3DES_EN == DEF_ENABLED)
  131. #undef NO_DES
  132. #else
  133. #define NO_DES
  134. #endif
  135. #if (SSL_CFG_AES_EN == DEF_ENABLED)
  136. #undef NO_AES
  137. #else
  138. #define NO_AES
  139. #endif
  140. #if (SSL_CFG_RC4_EN == DEF_ENABLED)
  141. #undef NO_RC4
  142. #else
  143. #define NO_RC4
  144. #endif
  145. #if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
  146. #undef NO_RABBIT
  147. #else
  148. #define NO_RABBIT
  149. #endif
  150. #if (SSL_CFG_HC128_EN == DEF_ENABLED)
  151. #undef NO_HC128
  152. #else
  153. #define NO_HC128
  154. #endif
  155. #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  156. #define BIG_ENDIAN_ORDER
  157. #else
  158. #undef BIG_ENDIAN_ORDER
  159. #define LITTLE_ENDIAN_ORDER
  160. #endif
  161. #if (SSL_CFG_MD4_EN == DEF_ENABLED)
  162. #undef NO_MD4
  163. #else
  164. #define NO_MD4
  165. #endif
  166. #if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
  167. #undef NO_WRITEV
  168. #else
  169. #define NO_WRITEV
  170. #endif
  171. #if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
  172. #define NO_DEV_RANDOM
  173. #else
  174. #undef NO_DEV_RANDOM
  175. #endif
  176. #if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
  177. #define CYASSL_USER_IO
  178. #else
  179. #undef CYASSL_USER_IO
  180. #endif
  181. #if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
  182. #undef LARGE_STATIC_BUFFERS
  183. #undef STATIC_CHUNKS_ONLY
  184. #else
  185. #define LARGE_STATIC_BUFFERS
  186. #define STATIC_CHUNKS_ONLY
  187. #endif
  188. #if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
  189. #define CYASSL_DER_LOAD
  190. #else
  191. #undef CYASSL_DER_LOAD
  192. #endif
  193. #if (SSL_CFG_DTLS_EN == DEF_ENABLED)
  194. #define CYASSL_DTLS
  195. #else
  196. #undef CYASSL_DTLS
  197. #endif
  198. #if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
  199. #define CYASSL_CALLBACKS
  200. #else
  201. #undef CYASSL_CALLBACKS
  202. #endif
  203. #if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
  204. #define USE_FAST_MATH
  205. #else
  206. #undef USE_FAST_MATH
  207. #endif
  208. #if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
  209. #define TFM_TIMING_RESISTANT
  210. #else
  211. #undef TFM_TIMING_RESISTANT
  212. #endif
  213. #endif /* MICRIUM */
  214. /* Place any other flags or defines here */
  215. #ifdef __cplusplus
  216. } /* extern "C" */
  217. #endif
  218. #endif /* CTAO_CRYPT_OS_SETTINGS_H */