user_settings.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /* Copyright (C) 2006-2018 wolfSSL Inc.
  2. *
  3. * This file is part of wolfSSL.
  4. *
  5. * wolfSSL is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * wolfSSL is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  18. */
  19. /* Custom wolfSSL user settings for Cypress WICED Studio. */
  20. #ifndef WOLFSSL_USER_SETTINGS_H
  21. #define WOLFSSL_USER_SETTINGS_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* ------------------------------------------------------------------------- */
  26. /* Platform */
  27. /* ------------------------------------------------------------------------- */
  28. #undef WOLFSSL_GENERAL_ALIGNMENT
  29. #define WOLFSSL_GENERAL_ALIGNMENT 4
  30. #undef SINGLE_THREADED
  31. #if 0
  32. #define SINGLE_THREADED
  33. #endif
  34. #undef WOLFSSL_SMALL_STACK
  35. #if 1
  36. #define WOLFSSL_SMALL_STACK
  37. #endif
  38. #undef WOLFSSL_USER_IO
  39. #define WOLFSSL_USER_IO
  40. /* ------------------------------------------------------------------------- */
  41. /* Math Configuration */
  42. /* ------------------------------------------------------------------------- */
  43. #undef USE_FAST_MATH
  44. #define USE_FAST_MATH
  45. #undef SIZEOF_LONG_LONG
  46. #define SIZEOF_LONG_LONG 8
  47. #undef USE_FAST_MATH
  48. #if 1
  49. #define USE_FAST_MATH
  50. #undef TFM_TIMING_RESISTANT
  51. #define TFM_TIMING_RESISTANT
  52. /* Optimizations */
  53. //#define TFM_ARM
  54. #endif
  55. /* Wolf Single Precision Math */
  56. #undef WOLFSSL_SP
  57. #if 0
  58. #define WOLFSSL_SP
  59. #define WOLFSSL_SP_SMALL
  60. #define WOLFSSL_HAVE_SP_RSA
  61. #define WOLFSSL_HAVE_SP_DH
  62. #define WOLFSSL_HAVE_SP_ECC
  63. #define WOLFSSL_SP_CACHE_RESISTANT
  64. //#define WOLFSSL_SP_MATH
  65. /* 64 or 32 bit version */
  66. //#define WOLFSSL_SP_ARM32_ASM
  67. //#define WOLFSSL_SP_ARM64_ASM
  68. #endif
  69. /* ------------------------------------------------------------------------- */
  70. /* FIPS - Requires eval or license from wolfSSL */
  71. /* ------------------------------------------------------------------------- */
  72. #undef HAVE_FIPS
  73. #if 0
  74. #define HAVE_FIPS
  75. #undef HAVE_FIPS_VERSION
  76. #define HAVE_FIPS_VERSION 2
  77. #ifdef SINGLE_THREADED
  78. #undef NO_THREAD_LS
  79. #define NO_THREAD_LS
  80. #endif
  81. #endif
  82. /* ------------------------------------------------------------------------- */
  83. /* Crypto */
  84. /* ------------------------------------------------------------------------- */
  85. /* RSA */
  86. #undef NO_RSA
  87. #if 1
  88. #ifdef USE_FAST_MATH
  89. /* Maximum math bits (Max RSA key bits * 2) */
  90. #undef FP_MAX_BITS
  91. #define FP_MAX_BITS 4096
  92. #endif
  93. /* half as much memory but twice as slow */
  94. #undef RSA_LOW_MEM
  95. //#define RSA_LOW_MEM
  96. /* Enables blinding mode, to prevent timing attacks */
  97. #if 1
  98. #undef WC_RSA_BLINDING
  99. #define WC_RSA_BLINDING
  100. #else
  101. #undef WC_NO_HARDEN
  102. #define WC_NO_HARDEN
  103. #endif
  104. /* RSA PSS Support */
  105. #if 1
  106. #define WC_RSA_PSS
  107. #endif
  108. #if 0
  109. #define WC_RSA_NO_PADDING
  110. #endif
  111. #else
  112. #define NO_RSA
  113. #endif
  114. /* ECC */
  115. #undef HAVE_ECC
  116. #if 1
  117. #define HAVE_ECC
  118. /* Manually define enabled curves */
  119. #undef ECC_USER_CURVES
  120. #define ECC_USER_CURVES
  121. #ifdef ECC_USER_CURVES
  122. /* Manual Curve Selection */
  123. //#define HAVE_ECC192
  124. //#define HAVE_ECC224
  125. #undef NO_ECC256
  126. //#define HAVE_ECC384
  127. //#define HAVE_ECC521
  128. #endif
  129. /* Fixed point cache (speeds repeated operations against same private key) */
  130. #undef FP_ECC
  131. //#define FP_ECC
  132. #ifdef FP_ECC
  133. /* Bits / Entries */
  134. #undef FP_ENTRIES
  135. #define FP_ENTRIES 2
  136. #undef FP_LUT
  137. #define FP_LUT 4
  138. #endif
  139. /* Optional ECC calculation method */
  140. /* Note: doubles heap usage, but slightly faster */
  141. #undef ECC_SHAMIR
  142. #define ECC_SHAMIR
  143. #undef TFM_ECC256
  144. #define TFM_ECC256
  145. /* Reduces heap usage, but slower */
  146. #undef ECC_TIMING_RESISTANT
  147. #define ECC_TIMING_RESISTANT
  148. /* Enable cofactor support */
  149. #ifdef HAVE_FIPS
  150. #undef HAVE_ECC_CDH
  151. #define HAVE_ECC_CDH
  152. #endif
  153. /* Validate import */
  154. #ifdef HAVE_FIPS
  155. #undef WOLFSSL_VALIDATE_ECC_IMPORT
  156. #define WOLFSSL_VALIDATE_ECC_IMPORT
  157. #endif
  158. /* Compressed Key Support */
  159. #undef HAVE_COMP_KEY
  160. //#define HAVE_COMP_KEY
  161. /* Use alternate ECC size for ECC math */
  162. #ifdef USE_FAST_MATH
  163. #ifdef NO_RSA
  164. /* Custom fastmath size if not using RSA */
  165. /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */
  166. #undef FP_MAX_BITS
  167. #define FP_MAX_BITS (256 + 32)
  168. #else
  169. #undef ALT_ECC_SIZE
  170. #define ALT_ECC_SIZE
  171. #endif
  172. /* Speedups specific to curve */
  173. #ifndef NO_ECC256
  174. #undef TFM_ECC256
  175. #define TFM_ECC256
  176. #endif
  177. #endif
  178. #endif
  179. /* DH */
  180. #undef NO_DH
  181. #if 1
  182. /* Use table for DH instead of -lm (math) lib dependency */
  183. #if 1
  184. #define WOLFSSL_DH_CONST
  185. #define HAVE_FFDHE_2048
  186. #define HAVE_FFDHE_4096
  187. //#define HAVE_FFDHE_6144
  188. //#define HAVE_FFDHE_8192
  189. #endif
  190. #ifdef HAVE_FIPS
  191. #define WOLFSSL_VALIDATE_FFC_IMPORT
  192. #define HAVE_FFDHE_Q
  193. #endif
  194. #else
  195. #define NO_DH
  196. #endif
  197. /* AES */
  198. #undef NO_AES
  199. #if 1
  200. #undef HAVE_AES_CBC
  201. #define HAVE_AES_CBC
  202. #undef HAVE_AESGCM
  203. #define HAVE_AESGCM
  204. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  205. #define GCM_SMALL
  206. #undef WOLFSSL_AES_DIRECT
  207. #define WOLFSSL_AES_DIRECT
  208. #undef HAVE_AES_ECB
  209. //#define HAVE_AES_ECB
  210. #undef WOLFSSL_AES_COUNTER
  211. #define WOLFSSL_AES_COUNTER
  212. #undef HAVE_AESCCM
  213. #define HAVE_AESCCM
  214. #else
  215. #define NO_AES
  216. #endif
  217. /* DES3 */
  218. #undef NO_DES3
  219. #if 1
  220. #else
  221. #define NO_DES3
  222. #endif
  223. /* ChaCha20 / Poly1305 */
  224. #undef HAVE_CHACHA
  225. #undef HAVE_POLY1305
  226. #if 1
  227. #define HAVE_CHACHA
  228. #define HAVE_POLY1305
  229. /* Needed for Poly1305 */
  230. #undef HAVE_ONE_TIME_AUTH
  231. #define HAVE_ONE_TIME_AUTH
  232. #endif
  233. /* Ed25519 / Curve25519 */
  234. #undef HAVE_CURVE25519
  235. #undef HAVE_ED25519
  236. #if 0
  237. #define HAVE_CURVE25519
  238. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  239. /* Optionally use small math (less flash usage, but much slower) */
  240. #if 1
  241. #define CURVED25519_SMALL
  242. #endif
  243. #endif
  244. /* ------------------------------------------------------------------------- */
  245. /* Hashing */
  246. /* ------------------------------------------------------------------------- */
  247. /* Sha */
  248. #undef NO_SHA
  249. #if 1
  250. /* 1k smaller, but 25% slower */
  251. #define USE_SLOW_SHA
  252. #else
  253. #define NO_SHA
  254. #endif
  255. /* Sha256 */
  256. #undef NO_SHA256
  257. #if 1
  258. /* not unrolled - ~2k smaller and ~25% slower */
  259. //#define USE_SLOW_SHA256
  260. /* Sha224 */
  261. #if 1
  262. #define WOLFSSL_SHA224
  263. #endif
  264. #else
  265. #define NO_SHA256
  266. #endif
  267. /* Sha512 */
  268. #undef WOLFSSL_SHA512
  269. #if 1
  270. #define WOLFSSL_SHA512
  271. /* Sha384 */
  272. #undef WOLFSSL_SHA384
  273. #if 1
  274. #define WOLFSSL_SHA384
  275. #endif
  276. #undef WOLFSSL_SHA224
  277. #if 1
  278. #define WOLFSSL_SHA224
  279. #endif
  280. /* over twice as small, but 50% slower */
  281. //#define USE_SLOW_SHA512
  282. #endif
  283. /* Sha3 */
  284. #undef WOLFSSL_SHA3
  285. #if 0
  286. #define WOLFSSL_SHA3
  287. #endif
  288. /* MD5 */
  289. #undef NO_MD5
  290. #if 1
  291. #else
  292. #define NO_MD5
  293. #endif
  294. /* HKDF */
  295. #undef HAVE_HKDF
  296. #if 1
  297. #define HAVE_HKDF
  298. #endif
  299. /* CMAC */
  300. #undef WOLFSSL_CMAC
  301. #if 0
  302. #define WOLFSSL_CMAC
  303. #endif
  304. /* ------------------------------------------------------------------------- */
  305. /* Benchmark / Test */
  306. /* ------------------------------------------------------------------------- */
  307. /* Use reduced benchmark / test sizes */
  308. #undef BENCH_EMBEDDED
  309. #define BENCH_EMBEDDED
  310. #undef USE_CERT_BUFFERS_2048
  311. #define USE_CERT_BUFFERS_2048
  312. #undef USE_CERT_BUFFERS_1024
  313. #define USE_CERT_BUFFERS_1024
  314. #undef USE_CERT_BUFFERS_256
  315. #define USE_CERT_BUFFERS_256
  316. /* ------------------------------------------------------------------------- */
  317. /* Debugging */
  318. /* ------------------------------------------------------------------------- */
  319. #undef DEBUG_WOLFSSL
  320. #undef NO_ERROR_STRINGS
  321. #if 1
  322. #define DEBUG_WOLFSSL
  323. #else
  324. #if 0
  325. #define NO_ERROR_STRINGS
  326. #endif
  327. #endif
  328. /* ------------------------------------------------------------------------- */
  329. /* Memory */
  330. /* ------------------------------------------------------------------------- */
  331. /* Override Memory API's */
  332. #if 0
  333. #undef XMALLOC_OVERRIDE
  334. #define XMALLOC_OVERRIDE
  335. /* prototypes for user heap override functions */
  336. /* Note: Realloc only required for normal math */
  337. #include <stddef.h> /* for size_t */
  338. extern void *myMalloc(size_t n, void* heap, int type);
  339. extern void myFree(void *p, void* heap, int type);
  340. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  341. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  342. #define XFREE(p, h, t) myFree(p, h, t)
  343. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  344. #endif
  345. #if 0
  346. /* Static memory requires fast math */
  347. #define WOLFSSL_STATIC_MEMORY
  348. /* Disable fallback malloc/free */
  349. #define WOLFSSL_NO_MALLOC
  350. #if 1
  351. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  352. #endif
  353. #endif
  354. /* Memory callbacks */
  355. #if 0
  356. #undef USE_WOLFSSL_MEMORY
  357. #define USE_WOLFSSL_MEMORY
  358. /* Use this to measure / print heap usage */
  359. #if 1
  360. #undef WOLFSSL_TRACK_MEMORY
  361. #define WOLFSSL_TRACK_MEMORY
  362. #undef WOLFSSL_DEBUG_MEMORY
  363. #define WOLFSSL_DEBUG_MEMORY
  364. #endif
  365. #else
  366. #ifndef WOLFSSL_STATIC_MEMORY
  367. #define NO_WOLFSSL_MEMORY
  368. /* Otherwise we will use stdlib malloc, free and realloc */
  369. #endif
  370. #endif
  371. /* ------------------------------------------------------------------------- */
  372. /* Port */
  373. /* ------------------------------------------------------------------------- */
  374. /* Override Current Time */
  375. /* Allows custom "custom_time()" function to be used for benchmark */
  376. //#define WOLFSSL_USER_CURRTIME
  377. //#define WOLFSSL_GMTIME
  378. //#define USER_TICKS
  379. extern unsigned long my_time(unsigned long* timer);
  380. #if 0
  381. #define XTIME my_time
  382. #endif
  383. /* ------------------------------------------------------------------------- */
  384. /* RNG */
  385. /* ------------------------------------------------------------------------- */
  386. /* Seed Source */
  387. /* Size of returned HW RNG value */
  388. //#define CUSTOM_RAND_TYPE unsigned int
  389. extern unsigned int my_rng_seed_gen(void);
  390. #undef CUSTOM_RAND_GENERATE
  391. //#define CUSTOM_RAND_GENERATE my_rng_seed_gen
  392. /* Choose RNG method */
  393. #if 1
  394. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  395. /* P-RNG + HW RNG (P-RNG is ~8K) */
  396. #undef HAVE_HASHDRBG
  397. #define HAVE_HASHDRBG
  398. #else
  399. #undef WC_NO_HASHDRBG
  400. #define WC_NO_HASHDRBG
  401. /* Bypass P-RNG and use only HW RNG */
  402. extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
  403. #undef CUSTOM_RAND_GENERATE_BLOCK
  404. #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
  405. #endif
  406. /* ------------------------------------------------------------------------- */
  407. /* Custom Standard Lib */
  408. /* ------------------------------------------------------------------------- */
  409. /* Allows override of all standard library functions */
  410. #undef STRING_USER
  411. #if 1
  412. #define STRING_USER
  413. #include <string.h>
  414. #undef USE_WOLF_STRSEP
  415. #define USE_WOLF_STRSEP
  416. #define XSTRSEP(s1,d) wc_strsep((s1),(d))
  417. #undef USE_WOLF_STRTOK
  418. #define USE_WOLF_STRTOK
  419. #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
  420. #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
  421. #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
  422. #define XMEMSET(b,c,l) memset((b),(c),(l))
  423. #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
  424. #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
  425. #define XSTRLEN(s1) strlen((s1))
  426. #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
  427. #define XSTRSTR(s1,s2) strstr((s1),(s2))
  428. #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
  429. #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
  430. #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
  431. #define XSNPRINTF snprintf
  432. #endif
  433. /* ------------------------------------------------------------------------- */
  434. /* Enable Features */
  435. /* ------------------------------------------------------------------------- */
  436. #undef WOLFSSL_TLS13
  437. #if 1
  438. #define WOLFSSL_TLS13
  439. #endif
  440. #undef WOLFSSL_KEY_GEN
  441. #if 0
  442. #define WOLFSSL_KEY_GEN
  443. #endif
  444. #if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
  445. #define WOLFSSL_OLD_PRIME_CHECK
  446. #endif
  447. #undef KEEP_PEER_CERT
  448. //#define KEEP_PEER_CERT
  449. #undef HAVE_COMP_KEY
  450. //#define HAVE_COMP_KEY
  451. #undef HAVE_TLS_EXTENSIONS
  452. #define HAVE_TLS_EXTENSIONS
  453. #undef HAVE_SUPPORTED_CURVES
  454. #define HAVE_SUPPORTED_CURVES
  455. #undef WOLFSSL_BASE64_ENCODE
  456. #define WOLFSSL_BASE64_ENCODE
  457. /* TLS Session Cache */
  458. #if 1
  459. #define SMALL_SESSION_CACHE
  460. #else
  461. #define NO_SESSION_CACHE
  462. #endif
  463. #undef HAVE_EXTENDED_MASTER
  464. #define HAVE_EXTENDED_MASTER
  465. #undef HAVE_TRUNCATED_HMAC
  466. #define HAVE_TRUNCATED_HMAC
  467. #undef WOLFSSL_ALLOW_TLSV10
  468. #define WOLFSSL_ALLOW_TLSV10
  469. #undef HAVE_SNI
  470. #if 1
  471. #define HAVE_SNI
  472. #endif
  473. #undef HAVE_MAX_FRAGMENT
  474. #if 1
  475. /* Set maximum fragment size. */
  476. #define HAVE_MAX_FRAGMENT
  477. #endif
  478. #if 1
  479. #define FP_MAX_BITS_ECC (256 + 32)
  480. #endif
  481. /* ------------------------------------------------------------------------- */
  482. /* TCP STACK */
  483. /* ------------------------------------------------------------------------- */
  484. #undef HAVE_NETX
  485. #if 1
  486. #define HAVE_NETX
  487. #endif
  488. #undef WOLFSSL_LWIP
  489. #if 0
  490. #define WOLFSSL_LWIP
  491. #endif
  492. /* ------------------------------------------------------------------------- */
  493. /* RTOS */
  494. /* ------------------------------------------------------------------------- */
  495. #undef THREADX
  496. #if 1
  497. #define THREADX
  498. #undef THREADX_NO_DC_PRINTF
  499. #if 1
  500. #define THREADX_NO_DC_PRINTF
  501. #endif
  502. #endif
  503. /* ------------------------------------------------------------------------- */
  504. /* Disable Features */
  505. /* ------------------------------------------------------------------------- */
  506. #undef NO_WOLFSSL_SERVER
  507. //#define NO_WOLFSSL_SERVER
  508. #undef NO_WOLFSSL_CLIENT
  509. //#define NO_WOLFSSL_CLIENT
  510. #undef NO_CRYPT_TEST
  511. //#define NO_CRYPT_TEST
  512. #undef NO_CRYPT_BENCHMARK
  513. //#define NO_CRYPT_BENCHMARK
  514. #undef WOLFCRYPT_ONLY
  515. //#define WOLFCRYPT_ONLY
  516. /* In-lining of misc.c functions */
  517. /* If defined, must include wolfcrypt/src/misc.c in build */
  518. /* Slower, but about 1k smaller */
  519. #undef NO_INLINE
  520. //#define NO_INLINE
  521. #undef NO_FILESYSTEM
  522. #define NO_FILESYSTEM
  523. #undef NO_WRITEV
  524. #define NO_WRITEV
  525. #undef NO_MAIN_DRIVER
  526. #define NO_MAIN_DRIVER
  527. #undef NO_DEV_RANDOM
  528. #define NO_DEV_RANDOM
  529. #undef NO_DSA
  530. //#define NO_DSA
  531. #undef NO_RC4
  532. //#define NO_RC4
  533. #undef NO_OLD_TLS
  534. //#define NO_OLD_TLS
  535. #undef NO_PSK
  536. //#define NO_PSK
  537. #undef NO_MD4
  538. //#define NO_MD4
  539. #undef NO_PWDBASED
  540. #define NO_PWDBASED
  541. #undef NO_CODING
  542. //#define NO_CODING
  543. #undef NO_ASN_TIME
  544. //#define NO_ASN_TIME
  545. #undef NO_CERTS
  546. //#define NO_CERTS
  547. #undef NO_SIG_WRAPPER
  548. //#define NO_SIG_WRAPPER
  549. #undef NO_OLD_WC_NAMES
  550. //#define NO_OLD_WC_NAMES
  551. #undef NO_WOLFSSL_DIR
  552. //#define NO_WOLFSSL_DIR
  553. /* ------------------------------------------------------------------------- */
  554. /* WICED SDK */
  555. /* ------------------------------------------------------------------------- */
  556. #undef WOLFSSL_WICED
  557. #if 1
  558. #define WOLFSSL_WICED
  559. #undef WICED_MBEDTLS
  560. #endif
  561. #ifdef __cplusplus
  562. }
  563. #endif
  564. #endif /* WOLFSSL_USER_SETTINGS_H */