1
0

user_settings.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /* user_settings.h
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL 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. * wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* Custom wolfSSL user settings for GCC ARM */
  22. #ifndef WOLFSSL_USER_SETTINGS_H
  23. #define WOLFSSL_USER_SETTINGS_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* ------------------------------------------------------------------------- */
  28. /* Platform */
  29. /* ------------------------------------------------------------------------- */
  30. #undef WOLFSSL_GENERAL_ALIGNMENT
  31. #define WOLFSSL_GENERAL_ALIGNMENT 4
  32. #undef THREADX
  33. #define THREADX
  34. #ifndef TX_TIMER_TICKS_PER_SECOND
  35. #define TX_TIMER_TICKS_PER_SECOND 100
  36. #endif
  37. #undef NETOS
  38. #define NETOS
  39. #undef BIG_ENDIAN_ORDER
  40. #define BIG_ENDIAN_ORDER
  41. #undef WOLFSSL_SMALL_STACK
  42. //#define WOLFSSL_SMALL_STACK
  43. #undef WOLFSSL_USER_IO
  44. //#define WOLFSSL_USER_IO
  45. #undef NO_THREAD_LS
  46. #define NO_THREAD_LS
  47. /* ------------------------------------------------------------------------- */
  48. /* Math Configuration */
  49. /* ------------------------------------------------------------------------- */
  50. #undef SIZEOF_LONG_LONG
  51. #define SIZEOF_LONG_LONG 8
  52. #undef SIZEOF_LONG
  53. #define SIZEOF_LONG 4
  54. #undef USE_FAST_MATH
  55. #if 1
  56. #define USE_FAST_MATH
  57. #undef TFM_TIMING_RESISTANT
  58. #define TFM_TIMING_RESISTANT
  59. /* Optimizations */
  60. #define TFM_ARM
  61. #endif
  62. /* ------------------------------------------------------------------------- */
  63. /* FIPS - Requires eval or license from wolfSSL */
  64. /* ------------------------------------------------------------------------- */
  65. #undef HAVE_FIPS
  66. #if 1
  67. #define HAVE_FIPS
  68. #undef HAVE_FIPS_VERSION
  69. #define HAVE_FIPS_VERSION 2
  70. #ifdef SINGLE_THREADED
  71. #undef NO_THREAD_LS
  72. #define NO_THREAD_LS
  73. #endif
  74. #if 1
  75. #undef NO_ATTRIBUTE_CONSTRUCTOR
  76. #define NO_ATTRIBUTE_CONSTRUCTOR
  77. #endif
  78. #endif
  79. /* ------------------------------------------------------------------------- */
  80. /* Crypto */
  81. /* ------------------------------------------------------------------------- */
  82. /* RSA */
  83. #undef NO_RSA
  84. #if 1
  85. #ifdef USE_FAST_MATH
  86. /* Maximum math bits (Max RSA key bits * 2) */
  87. #undef FP_MAX_BITS
  88. #define FP_MAX_BITS 8192
  89. #endif
  90. /* half as much memory but twice as slow */
  91. #undef RSA_LOW_MEM
  92. //#define RSA_LOW_MEM
  93. /* Enables blinding mode, to prevent timing attacks */
  94. #if 0
  95. #undef WC_RSA_BLINDING
  96. #define WC_RSA_BLINDING
  97. #else
  98. #undef WC_NO_HARDEN
  99. #define WC_NO_HARDEN
  100. #endif
  101. /* RSA PSS Support */
  102. #if 1
  103. #define WC_RSA_PSS
  104. #endif
  105. #if 1
  106. #define WC_RSA_NO_PADDING
  107. #endif
  108. #else
  109. #define NO_RSA
  110. #endif
  111. /* ECC */
  112. #undef HAVE_ECC
  113. #if 1
  114. #define HAVE_ECC
  115. /* Manually define enabled curves */
  116. #undef ECC_USER_CURVES
  117. //#define ECC_USER_CURVES
  118. #ifdef ECC_USER_CURVES
  119. /* Manual Curve Selection */
  120. //#define HAVE_ECC192
  121. //#define HAVE_ECC224
  122. #undef NO_ECC256
  123. //#define HAVE_ECC384
  124. //#define HAVE_ECC521
  125. #endif
  126. /* Fixed point cache (speeds repeated operations against same private key) */
  127. #undef FP_ECC
  128. //#define FP_ECC
  129. #ifdef FP_ECC
  130. /* Bits / Entries */
  131. #undef FP_ENTRIES
  132. #define FP_ENTRIES 2
  133. #undef FP_LUT
  134. #define FP_LUT 4
  135. #endif
  136. /* Optional ECC calculation method */
  137. /* Note: doubles heap usage, but slightly faster */
  138. #undef ECC_SHAMIR
  139. #define ECC_SHAMIR
  140. /* Reduces heap usage, but slower */
  141. #undef ECC_TIMING_RESISTANT
  142. #define ECC_TIMING_RESISTANT
  143. #ifdef HAVE_FIPS
  144. #undef HAVE_ECC_CDH
  145. #define HAVE_ECC_CDH /* Enable cofactor support */
  146. #undef NO_STRICT_ECDSA_LEN
  147. #define NO_STRICT_ECDSA_LEN /* Do not force fixed len w/ FIPS */
  148. #undef WOLFSSL_VALIDATE_ECC_IMPORT
  149. #define WOLFSSL_VALIDATE_ECC_IMPORT /* Validate import */
  150. #endif
  151. /* Compressed Key Support */
  152. #undef HAVE_COMP_KEY
  153. //#define HAVE_COMP_KEY
  154. /* Use alternate ECC size for ECC math */
  155. #ifdef USE_FAST_MATH
  156. /* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
  157. #ifdef NO_RSA
  158. /* Custom fastmath size if not using RSA */
  159. #undef FP_MAX_BITS
  160. #define FP_MAX_BITS (256 * 2)
  161. #else
  162. #undef ALT_ECC_SIZE
  163. #define ALT_ECC_SIZE
  164. /* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overridden */
  165. //#undef FP_MAX_BITS_ECC
  166. //#define FP_MAX_BITS_ECC (256 * 2)
  167. #endif
  168. /* Speedups specific to curve */
  169. #ifndef NO_ECC256
  170. #undef TFM_ECC256
  171. #define TFM_ECC256
  172. #endif
  173. #endif
  174. #endif
  175. /* DH */
  176. #undef NO_DH
  177. #if 1
  178. /* Use table for DH instead of -lm (math) lib dependency */
  179. #if 1
  180. #define WOLFSSL_DH_CONST
  181. #define HAVE_FFDHE_2048
  182. #define HAVE_FFDHE_4096
  183. //#define HAVE_FFDHE_6144
  184. //#define HAVE_FFDHE_8192
  185. #endif
  186. #ifdef HAVE_FIPS
  187. #define WOLFSSL_VALIDATE_FFC_IMPORT
  188. #define HAVE_FFDHE_Q
  189. #endif
  190. #else
  191. #define NO_DH
  192. #endif
  193. /* AES */
  194. #undef NO_AES
  195. #if 1
  196. #undef HAVE_AES_CBC
  197. #define HAVE_AES_CBC
  198. #undef HAVE_AESGCM
  199. #define HAVE_AESGCM
  200. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  201. // #define GCM_SMALL
  202. // #define GCM_WORD32
  203. #define GCM_TABLE
  204. #undef WOLFSSL_AES_DIRECT
  205. #define WOLFSSL_AES_DIRECT
  206. #undef HAVE_AES_ECB
  207. #define HAVE_AES_ECB
  208. #undef WOLFSSL_AES_COUNTER
  209. #define WOLFSSL_AES_COUNTER
  210. #undef HAVE_AESCCM
  211. #define HAVE_AESCCM
  212. #else
  213. #define NO_AES
  214. #endif
  215. /* DES3 */
  216. #undef NO_DES3
  217. #if 1
  218. /* No change */
  219. #else
  220. #define NO_DES3
  221. #endif
  222. /* ChaCha20 / Poly1305 */
  223. #undef HAVE_CHACHA
  224. #undef HAVE_POLY1305
  225. #if 0
  226. #define HAVE_CHACHA
  227. #define HAVE_POLY1305
  228. /* Needed for Poly1305 */
  229. #undef HAVE_ONE_TIME_AUTH
  230. #define HAVE_ONE_TIME_AUTH
  231. #endif
  232. /* Ed25519 / Curve25519 */
  233. #undef HAVE_CURVE25519
  234. #undef HAVE_ED25519
  235. #if 0
  236. #define HAVE_CURVE25519
  237. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  238. /* Optionally use small math (less flash usage, but much slower) */
  239. #if 1
  240. #define CURVED25519_SMALL
  241. #endif
  242. #endif
  243. /* ------------------------------------------------------------------------- */
  244. /* Hashing */
  245. /* ------------------------------------------------------------------------- */
  246. /* Sha */
  247. #undef NO_SHA
  248. #if 1
  249. /* 1k smaller, but 25% slower */
  250. //#define USE_SLOW_SHA
  251. #else
  252. #define NO_SHA
  253. #endif
  254. /* Sha256 */
  255. #undef NO_SHA256
  256. #if 1
  257. /* not unrolled - ~2k smaller and ~25% slower */
  258. //#define USE_SLOW_SHA256
  259. /* Sha224 */
  260. #if 1
  261. #define WOLFSSL_SHA224
  262. #endif
  263. #else
  264. #define NO_SHA256
  265. #endif
  266. /* Sha512 */
  267. #undef WOLFSSL_SHA512
  268. #if 1
  269. #define WOLFSSL_SHA512
  270. /* Sha384 */
  271. #undef WOLFSSL_SHA384
  272. #if 1
  273. #define WOLFSSL_SHA384
  274. #endif
  275. /* over twice as small, but 50% slower */
  276. //#define USE_SLOW_SHA512
  277. #endif
  278. /* Sha3 */
  279. #undef WOLFSSL_SHA3
  280. #if 1
  281. #define WOLFSSL_SHA3
  282. #endif
  283. /* MD5 */
  284. #undef NO_MD5
  285. #if 1
  286. /* No change */
  287. #else
  288. #define NO_MD5
  289. #endif
  290. /* HKDF */
  291. #undef HAVE_HKDF
  292. #if 1
  293. #define HAVE_HKDF
  294. #endif
  295. /* CMAC */
  296. #undef WOLFSSL_CMAC
  297. #if 1
  298. #define WOLFSSL_CMAC
  299. #endif
  300. /* ------------------------------------------------------------------------- */
  301. /* Benchmark / Test */
  302. /* ------------------------------------------------------------------------- */
  303. /* Use reduced benchmark / test sizes */
  304. #undef BENCH_EMBEDDED
  305. #define BENCH_EMBEDDED
  306. #undef USE_CERT_BUFFERS_2048
  307. #define USE_CERT_BUFFERS_2048
  308. #undef USE_CERT_BUFFERS_1024
  309. //#define USE_CERT_BUFFERS_1024
  310. #undef USE_CERT_BUFFERS_256
  311. #define USE_CERT_BUFFERS_256
  312. #undef FORCE_BUFFER_TEST
  313. #define FORCE_BUFFER_TEST
  314. /* ------------------------------------------------------------------------- */
  315. /* Debugging */
  316. /* ------------------------------------------------------------------------- */
  317. #undef DEBUG_WOLFSSL
  318. #undef NO_ERROR_STRINGS
  319. #if 0
  320. #define DEBUG_WOLFSSL
  321. #else
  322. #if 0
  323. #define NO_ERROR_STRINGS
  324. #endif
  325. #endif
  326. /* ------------------------------------------------------------------------- */
  327. /* Memory */
  328. /* ------------------------------------------------------------------------- */
  329. /* Override Memory API's */
  330. #if 0
  331. #undef XMALLOC_OVERRIDE
  332. #define XMALLOC_OVERRIDE
  333. /* prototypes for user heap override functions */
  334. /* Note: Realloc only required for normal math */
  335. #include <stddef.h> /* for size_t */
  336. extern void *myMalloc(size_t n, void* heap, int type);
  337. extern void myFree(void *p, void* heap, int type);
  338. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  339. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  340. #define XFREE(p, h, t) myFree(p, h, t)
  341. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  342. #endif
  343. #if 0
  344. /* Static memory requires fast math */
  345. #define WOLFSSL_STATIC_MEMORY
  346. /* Disable fallback malloc/free */
  347. #define WOLFSSL_NO_MALLOC
  348. #if 1
  349. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  350. #endif
  351. #endif
  352. /* Memory callbacks */
  353. #if 1
  354. #undef USE_WOLFSSL_MEMORY
  355. #define USE_WOLFSSL_MEMORY
  356. /* Use this to measure / print heap usage */
  357. #if 0
  358. #undef WOLFSSL_TRACK_MEMORY
  359. // #define WOLFSSL_TRACK_MEMORY
  360. #undef WOLFSSL_DEBUG_MEMORY
  361. //#define WOLFSSL_DEBUG_MEMORY
  362. #undef WOLFSSL_DEBUG_MEMORY_PRINT
  363. //#define WOLFSSL_DEBUG_MEMORY_PRINT
  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. /* RNG */
  373. /* ------------------------------------------------------------------------- */
  374. /* Seed Source */
  375. #if 1
  376. extern int my_rng_generate_seed(unsigned char* output, int sz);
  377. #undef CUSTOM_RAND_GENERATE_SEED
  378. #define CUSTOM_RAND_GENERATE_SEED my_rng_generate_seed
  379. #endif
  380. /* NETOS */
  381. #if 0
  382. extern unsigned char get_byte_from_pool(void);
  383. #define CUSTOM_RAND_GENERATE get_byte_from_pool
  384. #define CUSTOM_RAND_TYPE unsigned char
  385. #endif
  386. /* Choose RNG method */
  387. #if 1
  388. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  389. /* P-RNG + HW RNG (P-RNG is ~8K) */
  390. //#define WOLFSSL_GENSEED_FORTEST
  391. #undef HAVE_HASHDRBG
  392. #define HAVE_HASHDRBG
  393. #else
  394. #undef WC_NO_HASHDRBG
  395. #define WC_NO_HASHDRBG
  396. /* Bypass P-RNG and use only HW RNG */
  397. extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
  398. #undef CUSTOM_RAND_GENERATE_BLOCK
  399. #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
  400. #endif
  401. /* ------------------------------------------------------------------------- */
  402. /* Enable Features */
  403. /* ------------------------------------------------------------------------- */
  404. #undef WOLFSSL_TLS13
  405. #if 0
  406. #define WOLFSSL_TLS13
  407. #endif
  408. #undef WOLFSSL_KEY_GEN
  409. #if 1
  410. #define WOLFSSL_KEY_GEN
  411. #endif
  412. #if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
  413. #define WOLFSSL_OLD_PRIME_CHECK
  414. #endif
  415. #undef KEEP_PEER_CERT
  416. //#define KEEP_PEER_CERT
  417. #undef HAVE_COMP_KEY
  418. //#define HAVE_COMP_KEY
  419. #undef HAVE_TLS_EXTENSIONS
  420. #define HAVE_TLS_EXTENSIONS
  421. #undef HAVE_SUPPORTED_CURVES
  422. #define HAVE_SUPPORTED_CURVES
  423. #undef WOLFSSL_BASE64_ENCODE
  424. #define WOLFSSL_BASE64_ENCODE
  425. /* TLS Session Cache */
  426. #if 0
  427. #define SMALL_SESSION_CACHE
  428. #else
  429. #define NO_SESSION_CACHE
  430. #endif
  431. /* ------------------------------------------------------------------------- */
  432. /* Disable Features */
  433. /* ------------------------------------------------------------------------- */
  434. #undef NO_WOLFSSL_SERVER
  435. //#define NO_WOLFSSL_SERVER
  436. #undef NO_WOLFSSL_CLIENT
  437. //#define NO_WOLFSSL_CLIENT
  438. #undef NO_CRYPT_TEST
  439. //#define NO_CRYPT_TEST
  440. #undef NO_CRYPT_BENCHMARK
  441. //#define NO_CRYPT_BENCHMARK
  442. #undef WOLFCRYPT_ONLY
  443. //#define WOLFCRYPT_ONLY
  444. /* In-lining of misc.c functions */
  445. /* If defined, must include wolfcrypt/src/misc.c in build */
  446. /* Slower, but about 1k smaller */
  447. #undef NO_INLINE
  448. //#define NO_INLINE
  449. #undef NO_FILESYSTEM
  450. #define NO_FILESYSTEM
  451. #undef NO_WOLFSSL_DIR
  452. #define NO_WOLFSSL_DIR
  453. #undef NO_WRITEV
  454. #define NO_WRITEV
  455. #undef NO_MAIN_DRIVER
  456. #define NO_MAIN_DRIVER
  457. #undef NO_DEV_RANDOM
  458. #define NO_DEV_RANDOM
  459. #undef NO_DSA
  460. #define NO_DSA
  461. #undef NO_RC4
  462. #define NO_RC4
  463. #undef NO_OLD_TLS
  464. #define NO_OLD_TLS
  465. #undef NO_PSK
  466. #define NO_PSK
  467. #undef NO_MD4
  468. #define NO_MD4
  469. #undef NO_PWDBASED
  470. //#define NO_PWDBASED
  471. #undef NO_CODING
  472. //#define NO_CODING
  473. #undef NO_ASN_TIME
  474. //#define NO_ASN_TIME
  475. #undef NO_CERTS
  476. //#define NO_CERTS
  477. #undef NO_SIG_WRAPPER
  478. //#define NO_SIG_WRAPPER
  479. /* ACVP Testing ONLY specific settings */
  480. #if 0
  481. #undef USE_NORMAL_PRINTF
  482. #define USE_NORMAL_PRINTF
  483. #undef USE_UART_READ_LINE
  484. #define USE_UART_READ_LINE
  485. #undef USE_SMALL_MONTE
  486. #define USE_SMALL_MONTE
  487. #undef WOLFSSL_PUBLIC_MP
  488. #define WOLFSSL_PUBLIC_MP
  489. #undef HAVE_FORCE_FIPS_FAILURE
  490. #define HAVE_FORCE_FIPS_FAILURE
  491. #endif
  492. #ifdef __cplusplus
  493. }
  494. #endif
  495. #endif /* WOLFSSL_USER_SETTINGS_H */