user_settings.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. #ifndef WOLFSSL_USER_SETTINGS_H
  2. #define WOLFSSL_USER_SETTINGS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "board.h"
  7. /* ------------------------------------------------------------------------- */
  8. /* Platform */
  9. /* ------------------------------------------------------------------------- */
  10. #undef WOLFSSL_GENERAL_ALIGNMENT
  11. #define WOLFSSL_GENERAL_ALIGNMENT 4
  12. #undef WOLFSSL_SMALL_STACK
  13. #define WOLFSSL_SMALL_STACK
  14. // 使用文件系统
  15. #undef WOLFSSL_USER_FILESYSTEM
  16. #define WOLFSSL_USER_FILESYSTEM
  17. // 使用FREERTOS_FAT文件系统
  18. #undef FREERTOS_FAT
  19. #define FREERTOS_FAT
  20. // 使用FREERTOS
  21. #undef FREERTOS
  22. #define FREERTOS
  23. #if USE_LWIP
  24. // 使用LWIP
  25. #undef WOLFSSL_LWIP
  26. #define WOLFSSL_LWIP
  27. #else
  28. // 使用FREERTOS_PLUS_TCP
  29. #undef FREERTOS_TCP
  30. #define FREERTOS_TCP
  31. #endif
  32. // 已有 tm 类型定义
  33. #define HAVE_TM_TYPE
  34. // 已有 time_t 类型定义
  35. #define HAVE_TIME_T_TYPE
  36. #define SIZEOF_LONG_LONG 8
  37. #ifndef CHAR_BIT
  38. #define CHAR_BIT 8
  39. #endif
  40. #define NO_WOLFSSL_DIR
  41. // 禁用 Rabbit 流密码算法
  42. #undef NO_RABBIT
  43. #define NO_RABBIT
  44. // 禁用ASN的时间检查。
  45. #define NO_ASN_TIME
  46. #define WOLFSSL_IGNORE_FILE_WARN
  47. /* ------------------------------------------------------------------------- */
  48. /* Debugging */
  49. /* ------------------------------------------------------------------------- */
  50. #undef WOLFSSL_DEBUG
  51. //#define WOLFSSL_DEBUG
  52. #ifdef WOLFSSL_DEBUG
  53. /* Use this to measure / print heap usage */
  54. #if 0
  55. #undef USE_WOLFSSL_MEMORY
  56. #define USE_WOLFSSL_MEMORY
  57. #undef WOLFSSL_TRACK_MEMORY
  58. #define WOLFSSL_TRACK_MEMORY
  59. #endif
  60. #else
  61. // #undef NO_WOLFSSL_MEMORY
  62. // #define NO_WOLFSSL_MEMORY
  63. #undef NO_ERROR_STRINGS
  64. //#define NO_ERROR_STRINGS
  65. #endif
  66. //Enable wolfssl log print
  67. #define DEBUG_WOLFSSL
  68. #ifdef DEBUG_WOLFSSL
  69. #undef WOLFSSL_DEBUG_ERRORS_ONLY
  70. #define WOLFSSL_USER_LOG(x) do { printf(x); printf("\n"); } while(0);
  71. #endif
  72. /* ------------------------------------------------------------------------- */
  73. /* Math Configuration */
  74. /* ------------------------------------------------------------------------- */
  75. #undef USE_FAST_MATH
  76. #define USE_FAST_MATH
  77. #ifdef USE_FAST_MATH
  78. #undef TFM_TIMING_RESISTANT
  79. #define TFM_TIMING_RESISTANT
  80. #undef TFM_NO_ASM
  81. //#define TFM_NO_ASM
  82. /* Optimizations (TFM_ARM, TFM_ASM or none) */
  83. //#define TFM_ASM
  84. #endif
  85. /* ------------------------------------------------------------------------- */
  86. /* Crypto */
  87. /* ------------------------------------------------------------------------- */
  88. /* ECC */
  89. #if 1
  90. #undef HAVE_ECC
  91. #define HAVE_ECC
  92. /* Manually define enabled curves */
  93. #undef ECC_USER_CURVES
  94. #define ECC_USER_CURVES
  95. //#define HAVE_ECC192
  96. //#define HAVE_ECC224
  97. #undef NO_ECC256
  98. //#define HAVE_ECC384
  99. //#define HAVE_ECC521
  100. /* Fixed point cache (speeds repeated operations against same private key) */
  101. #undef FP_ECC
  102. //#define FP_ECC
  103. #ifdef FP_ECC
  104. /* Bits / Entries */
  105. #undef FP_ENTRIES
  106. #define FP_ENTRIES 2
  107. #undef FP_LUT
  108. #define FP_LUT 4
  109. #endif
  110. /* Optional ECC calculation method */
  111. /* Note: doubles heap usage, but slightly faster */
  112. #undef ECC_SHAMIR
  113. #define ECC_SHAMIR
  114. /* Reduces heap usage, but slower */
  115. #undef ECC_TIMING_RESISTANT
  116. #define ECC_TIMING_RESISTANT
  117. #ifdef USE_FAST_MATH
  118. /* use reduced size math buffers for ecc points */
  119. #undef ALT_ECC_SIZE
  120. #define ALT_ECC_SIZE
  121. /* optionally override the default max ecc bits */
  122. //#undef FP_MAX_BITS_ECC
  123. //#define FP_MAX_BITS_ECC 512
  124. /* Enable TFM optimizations for ECC */
  125. //#define TFM_ECC192
  126. //#define TFM_ECC224
  127. //#define TFM_ECC256
  128. //#define TFM_ECC384
  129. //#define TFM_ECC521
  130. #endif
  131. #endif
  132. /* RSA */
  133. #undef NO_RSA
  134. #if 1
  135. #ifdef USE_FAST_MATH
  136. /* Maximum math bits (Max RSA key bits * 2) */
  137. #undef FP_MAX_BITS
  138. #define FP_MAX_BITS 4096
  139. #endif
  140. /* half as much memory but twice as slow */
  141. #undef RSA_LOW_MEM
  142. //#define RSA_LOW_MEM
  143. /* Enables blinding mode, to prevent timing attacks */
  144. #undef WC_RSA_BLINDING
  145. #define WC_RSA_BLINDING
  146. #else
  147. #define NO_RSA
  148. #endif
  149. /* AES */
  150. #undef NO_AES
  151. #if 1
  152. #undef HAVE_AESGCM
  153. #define HAVE_AESGCM
  154. #ifdef HAVE_AESGCM
  155. /* GCM with hardware acceleration requires AES counter/direct for unaligned sizes */
  156. #undef WOLFSSL_AES_COUNTER
  157. #define WOLFSSL_AES_COUNTER
  158. #undef WOLFSSL_AES_DIRECT
  159. #define WOLFSSL_AES_DIRECT
  160. #endif
  161. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  162. #undef GCM_SMALL
  163. #define GCM_SMALL
  164. #else
  165. #define NO_AES
  166. #endif
  167. /* ChaCha20 / Poly1305 */
  168. #undef HAVE_CHACHA
  169. #undef HAVE_POLY1305
  170. #if 0
  171. #define HAVE_CHACHA
  172. #define HAVE_POLY1305
  173. /* Needed for Poly1305 */
  174. #undef HAVE_ONE_TIME_AUTH
  175. #define HAVE_ONE_TIME_AUTH
  176. #endif
  177. /* Ed25519 / Curve25519 */
  178. #undef HAVE_CURVE25519
  179. #undef HAVE_ED25519
  180. #if 0
  181. #define HAVE_CURVE25519
  182. #define HAVE_ED25519
  183. /* Optionally use small math (less flash usage, but much slower) */
  184. #if 0
  185. #define CURVED25519_SMALL
  186. #endif
  187. #endif
  188. /* ------------------------------------------------------------------------- */
  189. /* Hashing */
  190. /* ------------------------------------------------------------------------- */
  191. /* Sha */
  192. #undef NO_SHA
  193. #if 1
  194. /* 1k smaller, but 25% slower */
  195. //#define USE_SLOW_SHA
  196. #else
  197. #define NO_SHA
  198. #endif
  199. /* Sha256 */
  200. #undef NO_SHA256
  201. #if 1
  202. #if 1
  203. #define WOLFSSL_SHA224
  204. #endif
  205. #else
  206. #define NO_SHA256
  207. #endif
  208. /* Sha512 */
  209. #undef WOLFSSL_SHA512
  210. #if 1
  211. #define WOLFSSL_SHA512
  212. /* Sha384 */
  213. #undef WOLFSSL_SHA384
  214. #if 1
  215. #define WOLFSSL_SHA384
  216. #endif
  217. /* over twice as small, but 50% slower */
  218. //#define USE_SLOW_SHA2
  219. #endif
  220. /* MD5 */
  221. // #undef NO_MD5
  222. // #if 1
  223. // /* enabled */
  224. // #else
  225. // #define NO_MD5
  226. // #endif
  227. /* ------------------------------------------------------------------------- */
  228. /* HW Crypto Acceleration */
  229. /* ------------------------------------------------------------------------- */
  230. // See settings.h STM32F4 section
  231. /* ------------------------------------------------------------------------- */
  232. /* Benchmark / Test */
  233. /* ------------------------------------------------------------------------- */
  234. /* Use reduced benchmark / test sizes */
  235. //#undef BENCH_EMBEDDED
  236. //#define BENCH_EMBEDDED
  237. //#undef USE_CERT_BUFFERS_2048
  238. //#define USE_CERT_BUFFERS_2048
  239. //#undef USE_CERT_BUFFERS_256
  240. //#define USE_CERT_BUFFERS_256
  241. /* ------------------------------------------------------------------------- */
  242. /* Port */
  243. /* ------------------------------------------------------------------------- */
  244. /* Override Current Time */
  245. /* Allows custom "custom_time()" function to be used for benchmark */
  246. #define WOLFSSL_USER_CURRTIME
  247. /* ------------------------------------------------------------------------- */
  248. /* RNG */
  249. /* ------------------------------------------------------------------------- */
  250. /* Size of returned HW RNG value */
  251. #define CUSTOM_RAND_TYPE unsigned int
  252. // 使用ARK随机数发生器
  253. #define ARK_RNG
  254. #define NO_OLD_RNGNAME
  255. /* Choose RNG method */
  256. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  257. /* P-RNG + HW RNG (P-RNG is ~8K) */
  258. #undef HAVE_HASHDRBG
  259. #define HAVE_HASHDRBG
  260. /* ------------------------------------------------------------------------- */
  261. /* Enable Features */
  262. /* ------------------------------------------------------------------------- */
  263. #undef KEEP_PEER_CERT
  264. //#define KEEP_PEER_CERT
  265. #undef HAVE_COMP_KEY
  266. //#define HAVE_COMP_KEY
  267. #undef HAVE_TLS_EXTENSIONS
  268. #define HAVE_TLS_EXTENSIONS
  269. #undef HAVE_SUPPORTED_CURVES
  270. #define HAVE_SUPPORTED_CURVES
  271. #undef WOLFSSL_BASE64_ENCODE
  272. #define WOLFSSL_BASE64_ENCODE
  273. /* TLS Session Cache */
  274. #if 0
  275. #define SMALL_SESSION_CACHE
  276. #else
  277. #define NO_SESSION_CACHE
  278. #endif
  279. #undef USER_TIME
  280. #define USER_TIME //需要在应用层定义自己的 time_t XTIME(time_t * timer) 函数,直接定义即可
  281. /* ------------------------------------------------------------------------- */
  282. /* Disable Features */
  283. /* ------------------------------------------------------------------------- */
  284. //#undef NO_WOLFSSL_SERVER
  285. ////#define NO_WOLFSSL_SERVER
  286. //#undef NO_WOLFSSL_CLIENT
  287. ////#define NO_WOLFSSL_CLIENT
  288. //#undef NO_CRYPT_TEST
  289. ////#define NO_CRYPT_TEST
  290. //#undef NO_CRYPT_BENCHMARK
  291. ////#define NO_CRYPT_BENCHMARK
  292. ///* In-lining of misc.c functions */
  293. ///* If defined, must include wolfcrypt/src/misc.c in build */
  294. ///* Slower, but about 1k smaller */
  295. //#undef NO_INLINE
  296. ////#define NO_INLINE
  297. //#undef NO_FILESYSTEM
  298. //#define NO_FILESYSTEM
  299. //#undef NO_WRITEV
  300. //#define NO_WRITEV
  301. //#undef NO_MAIN_DRIVER
  302. //#define NO_MAIN_DRIVER
  303. ////#undef NO_DEV_RANDOM
  304. ////#define NO_DEV_RANDOM
  305. //#undef NO_DSA
  306. //#define NO_DSA
  307. //#undef NO_DH
  308. //#define NO_DH
  309. //#undef NO_DES3
  310. //#define NO_DES3
  311. //#undef NO_RC4
  312. //#define NO_RC4
  313. //#undef NO_OLD_TLS
  314. //#define NO_OLD_TLS
  315. //#undef NO_HC128
  316. //#define NO_HC128
  317. //#undef NO_RABBIT
  318. //#define NO_RABBIT
  319. //#undef NO_PSK
  320. //#define NO_PSK
  321. //#undef NO_MD4
  322. //#define NO_MD4
  323. //#undef NO_PWDBASED
  324. //#define NO_PWDBASED
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328. #endif /* WOLFSSL_USER_SETTINGS_H */