2
0

user_settings.h 15 KB

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