2
0

user_settings.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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. #undef IPHONE
  39. #define IPHONE
  40. #undef NO_WRITE_TEMP_FILES
  41. #define NO_WRITE_TEMP_FILES
  42. /* ------------------------------------------------------------------------- */
  43. /* Math Configuration */
  44. /* ------------------------------------------------------------------------- */
  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. #undef TFM_NO_ASM
  53. #define TFM_NO_ASM
  54. /* Optimizations */
  55. //#define TFM_ARM
  56. #endif
  57. /* Wolf Single Precision Math */
  58. #undef WOLFSSL_SP
  59. #if 1 /* SP Assembly Speedups (wPAA) */
  60. #define WOLFSSL_SP
  61. #define WOLFSSL_SP_SMALL /* use smaller version of code */
  62. #define WOLFSSL_HAVE_SP_RSA
  63. #define WOLFSSL_HAVE_SP_DH
  64. #define WOLFSSL_HAVE_SP_ECC
  65. #define WOLFSSL_ARMASM
  66. #define WOLFSSL_SP_ARM64_ASM
  67. #endif
  68. /* ------------------------------------------------------------------------- */
  69. /* FIPS - Requires eval or license from wolfSSL */
  70. /* ------------------------------------------------------------------------- */
  71. #undef HAVE_FIPS
  72. #if 1
  73. #define HAVE_FIPS
  74. #undef HAVE_FIPS_VERSION
  75. #define HAVE_FIPS_VERSION 2
  76. #ifdef SINGLE_THREADED
  77. #undef NO_THREAD_LS
  78. #define NO_THREAD_LS
  79. #endif
  80. #if 0
  81. #undef NO_ATTRIBUTE_CONSTRUCTOR
  82. #define NO_ATTRIBUTE_CONSTRUCTOR
  83. #endif
  84. #endif
  85. /* ------------------------------------------------------------------------- */
  86. /* Crypto */
  87. /* ------------------------------------------------------------------------- */
  88. /* RSA */
  89. #undef NO_RSA
  90. #if 1
  91. #ifdef USE_FAST_MATH
  92. /* Maximum math bits (Max RSA key bits * 2) */
  93. #undef FP_MAX_BITS
  94. #define FP_MAX_BITS 8192
  95. #endif
  96. /* half as much memory but twice as slow */
  97. #undef RSA_LOW_MEM
  98. //#define RSA_LOW_MEM
  99. /* Enables blinding mode, to prevent timing attacks */
  100. #if 0
  101. #undef WC_RSA_BLINDING
  102. #define WC_RSA_BLINDING
  103. #else
  104. #undef WC_NO_HARDEN
  105. #define WC_NO_HARDEN
  106. #endif
  107. /* RSA PSS Support */
  108. #if 1
  109. #undef WC_RSA_PSS
  110. #define WC_RSA_PSS
  111. #endif
  112. #if 1
  113. #define WC_RSA_NO_PADDING
  114. #endif
  115. #else
  116. #define NO_RSA
  117. #endif
  118. /* ECC */
  119. #undef HAVE_ECC
  120. #if 1
  121. #define HAVE_ECC
  122. /* Manually define enabled curves */
  123. #undef ECC_USER_CURVES
  124. //#define ECC_USER_CURVES
  125. #ifdef ECC_USER_CURVES
  126. /* Manual Curve Selection */
  127. //#define HAVE_ECC192
  128. //#define HAVE_ECC224
  129. #undef NO_ECC256
  130. //#define HAVE_ECC384
  131. //#define HAVE_ECC521
  132. #endif
  133. /* Fixed point cache (speeds repeated operations against same private key) */
  134. #undef FP_ECC
  135. //#define FP_ECC
  136. #ifdef FP_ECC
  137. /* Bits / Entries */
  138. #undef FP_ENTRIES
  139. #define FP_ENTRIES 2
  140. #undef FP_LUT
  141. #define FP_LUT 4
  142. #endif
  143. /* Optional ECC calculation method */
  144. /* Note: doubles heap usage, but slightly faster */
  145. #undef ECC_SHAMIR
  146. #define ECC_SHAMIR
  147. /* Reduces heap usage, but slower */
  148. #undef ECC_TIMING_RESISTANT
  149. #define ECC_TIMING_RESISTANT
  150. #ifdef HAVE_FIPS
  151. #undef HAVE_ECC_CDH
  152. #define HAVE_ECC_CDH /* Enable cofactor support */
  153. #undef NO_STRICT_ECDSA_LEN
  154. #define NO_STRICT_ECDSA_LEN /* Do not force fixed len w/ FIPS */
  155. #undef WOLFSSL_VALIDATE_ECC_IMPORT
  156. #define WOLFSSL_VALIDATE_ECC_IMPORT /* Validate 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. /* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
  164. #ifdef NO_RSA
  165. /* Custom fastmath size if not using RSA */
  166. #undef FP_MAX_BITS
  167. #define FP_MAX_BITS (256 * 2)
  168. #else
  169. #undef ALT_ECC_SIZE
  170. #define ALT_ECC_SIZE
  171. /* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overridden */
  172. //#undef FP_MAX_BITS_ECC
  173. //#define FP_MAX_BITS_ECC (256 * 2)
  174. #endif
  175. /* Speedups specific to curve */
  176. #ifndef NO_ECC256
  177. #undef TFM_ECC256
  178. #define TFM_ECC256
  179. #endif
  180. #endif
  181. #endif
  182. /* DH */
  183. #undef NO_DH
  184. #if 1
  185. /* Use table for DH instead of -lm (math) lib dependency */
  186. #if 1
  187. #define WOLFSSL_DH_CONST
  188. #define HAVE_FFDHE_2048
  189. #define HAVE_FFDHE_3072
  190. #define HAVE_FFDHE_4096
  191. //#define HAVE_FFDHE_6144
  192. //#define HAVE_FFDHE_8192
  193. #endif
  194. #ifdef HAVE_FIPS
  195. #define WOLFSSL_VALIDATE_FFC_IMPORT
  196. #define HAVE_FFDHE_Q
  197. #endif
  198. #else
  199. #define NO_DH
  200. #endif
  201. /* AES */
  202. #undef NO_AES
  203. #if 1
  204. #undef HAVE_AES_CBC
  205. #define HAVE_AES_CBC
  206. #undef HAVE_AESGCM
  207. #define HAVE_AESGCM
  208. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  209. #define GCM_TABLE
  210. #undef WOLFSSL_AES_DIRECT
  211. #define WOLFSSL_AES_DIRECT
  212. #undef HAVE_AES_ECB
  213. #define HAVE_AES_ECB
  214. #undef WOLFSSL_AES_COUNTER
  215. #define WOLFSSL_AES_COUNTER
  216. #undef HAVE_AESCCM
  217. #define HAVE_AESCCM
  218. #undef HAVE_AES_KEYWRAP
  219. #define HAVE_AES_KEYWRAP
  220. #else
  221. #define NO_AES
  222. #endif
  223. /* DES3 */
  224. #undef NO_DES3
  225. #if 1
  226. #if 1
  227. #undef WOLFSSL_DES_ECB
  228. #define WOLFSSL_DES_ECB
  229. #endif
  230. #else
  231. #define NO_DES3
  232. #endif
  233. /* ChaCha20 / Poly1305 */
  234. #undef HAVE_CHACHA
  235. #undef HAVE_POLY1305
  236. #if 0
  237. #define HAVE_CHACHA
  238. #define HAVE_POLY1305
  239. /* Needed for Poly1305 */
  240. #undef HAVE_ONE_TIME_AUTH
  241. #define HAVE_ONE_TIME_AUTH
  242. #endif
  243. /* Ed25519 / Curve25519 */
  244. #undef HAVE_CURVE25519
  245. #undef HAVE_ED25519
  246. #if 0
  247. #define HAVE_CURVE25519
  248. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  249. /* Optionally use small math (less flash usage, but much slower) */
  250. #if 1
  251. #define CURVED25519_SMALL
  252. #endif
  253. #endif
  254. /* ------------------------------------------------------------------------- */
  255. /* Hashing */
  256. /* ------------------------------------------------------------------------- */
  257. /* Sha */
  258. #undef NO_SHA
  259. #if 1
  260. /* 1k smaller, but 25% slower */
  261. //#define USE_SLOW_SHA
  262. #else
  263. #define NO_SHA
  264. #endif
  265. /* Sha256 */
  266. #undef NO_SHA256
  267. #if 1
  268. /* not unrolled - ~2k smaller and ~25% slower */
  269. //#define USE_SLOW_SHA256
  270. /* Sha224 */
  271. #if 1
  272. #define WOLFSSL_SHA224
  273. #endif
  274. #else
  275. #define NO_SHA256
  276. #endif
  277. /* Sha512 */
  278. #undef WOLFSSL_SHA512
  279. #if 1
  280. #define WOLFSSL_SHA512
  281. /* Sha384 */
  282. #undef WOLFSSL_SHA384
  283. #if 1
  284. #define WOLFSSL_SHA384
  285. #endif
  286. /* over twice as small, but 50% slower */
  287. //#define USE_SLOW_SHA512
  288. #endif
  289. /* Sha3 */
  290. #undef WOLFSSL_SHA3
  291. #if 1
  292. #define WOLFSSL_SHA3
  293. #endif
  294. /* MD5 */
  295. #undef NO_MD5
  296. #if 1
  297. #else
  298. #define NO_MD5
  299. #endif
  300. /* HKDF */
  301. #undef HAVE_HKDF
  302. #if 1
  303. #define HAVE_HKDF
  304. #endif
  305. /* CMAC */
  306. #undef WOLFSSL_CMAC
  307. #if 1
  308. #define WOLFSSL_CMAC
  309. #endif
  310. /* ------------------------------------------------------------------------- */
  311. /* Benchmark / Test */
  312. /* ------------------------------------------------------------------------- */
  313. /* Use reduced benchmark / test sizes */
  314. #undef BENCH_EMBEDDED
  315. #define BENCH_EMBEDDED
  316. #undef USE_CERT_BUFFERS_2048
  317. #define USE_CERT_BUFFERS_2048
  318. #undef USE_CERT_BUFFERS_1024
  319. //#define USE_CERT_BUFFERS_1024
  320. #undef USE_CERT_BUFFERS_256
  321. #define USE_CERT_BUFFERS_256
  322. /* ------------------------------------------------------------------------- */
  323. /* Debugging */
  324. /* ------------------------------------------------------------------------- */
  325. #undef DEBUG_WOLFSSL
  326. #undef NO_ERROR_STRINGS
  327. #if 0
  328. #define DEBUG_WOLFSSL
  329. #else
  330. #if 0
  331. #define NO_ERROR_STRINGS
  332. #endif
  333. #endif
  334. /* ------------------------------------------------------------------------- */
  335. /* Memory */
  336. /* ------------------------------------------------------------------------- */
  337. /* Override Memory API's */
  338. #if 0
  339. #undef XMALLOC_OVERRIDE
  340. #define XMALLOC_OVERRIDE
  341. /* prototypes for user heap override functions */
  342. /* Note: Realloc only required for normal math */
  343. /* Note2: XFREE(NULL) must be properly handled */
  344. #include <stddef.h> /* for size_t */
  345. extern void *myMalloc(size_t n, void* heap, int type);
  346. extern void myFree(void *p, void* heap, int type);
  347. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  348. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  349. #define XFREE(p, h, t) myFree(p, h, t)
  350. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  351. #endif
  352. #if 0
  353. /* Static memory requires fast math */
  354. #define WOLFSSL_STATIC_MEMORY
  355. /* Disable fallback malloc/free */
  356. #define WOLFSSL_NO_MALLOC
  357. #if 1
  358. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  359. #endif
  360. #endif
  361. /* Memory callbacks */
  362. #if 1
  363. #undef USE_WOLFSSL_MEMORY
  364. #define USE_WOLFSSL_MEMORY
  365. /* Use this to measure / print heap usage */
  366. #if 0
  367. #undef WOLFSSL_TRACK_MEMORY
  368. // #define WOLFSSL_TRACK_MEMORY
  369. #undef WOLFSSL_DEBUG_MEMORY
  370. //#define WOLFSSL_DEBUG_MEMORY
  371. #undef WOLFSSL_DEBUG_MEMORY_PRINT
  372. //#define WOLFSSL_DEBUG_MEMORY_PRINT
  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. /* Seed Source */
  395. // extern int my_rng_generate_seed(unsigned char* output, int sz);
  396. // #undef CUSTOM_RAND_GENERATE_SEED
  397. // #define CUSTOM_RAND_GENERATE_SEED my_rng_generate_seed
  398. /* Choose RNG method */
  399. #if 1
  400. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  401. /* P-RNG + HW RNG (P-RNG is ~8K) */
  402. //#define WOLFSSL_GENSEED_FORTEST
  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 1
  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. #undef OPENSSL_EXTRA
  471. #define OPENSSL_EXTRA
  472. #undef WOLFSSL_DER_LOAD
  473. #define WOLFSSL_DER_LOAD
  474. #undef HAVE_SESSION_TICKET
  475. #define HAVE_SESSION_TICKET
  476. #undef HAVE_EX_DATA
  477. #define HAVE_EX_DATA
  478. #undef HAVE_ENCRYPT_THEN_MAC
  479. #define HAVE_ENCRYPT_THEN_MAC
  480. #undef WOLFSSL_CERT_GEN
  481. #define WOLFSSL_CERT_GEN
  482. #undef ATOMIC_USER
  483. #define ATOMIC_USER
  484. #undef HAVE_SECRET_CALLBACK
  485. #define HAVE_SECRET_CALLBACK
  486. /* ------------------------------------------------------------------------- */
  487. /* Disable Features */
  488. /* ------------------------------------------------------------------------- */
  489. #undef NO_WOLFSSL_SERVER
  490. //#define NO_WOLFSSL_SERVER
  491. #undef NO_WOLFSSL_CLIENT
  492. //#define NO_WOLFSSL_CLIENT
  493. #undef NO_CRYPT_TEST
  494. //#define NO_CRYPT_TEST
  495. #undef NO_CRYPT_BENCHMARK
  496. //#define NO_CRYPT_BENCHMARK
  497. #undef WOLFCRYPT_ONLY
  498. //#define WOLFCRYPT_ONLY
  499. /* In-lining of misc.c functions */
  500. /* If defined, must include wolfcrypt/src/misc.c in build */
  501. /* Slower, but about 1k smaller */
  502. #undef NO_INLINE
  503. //#define NO_INLINE
  504. #undef NO_FILESYSTEM
  505. //#define NO_FILESYSTEM
  506. #undef NO_WRITEV
  507. //#define NO_WRITEV
  508. #undef NO_MAIN_DRIVER
  509. #define NO_MAIN_DRIVER
  510. #undef NO_DEV_RANDOM
  511. //#define NO_DEV_RANDOM
  512. #undef NO_DSA
  513. //#define NO_DSA
  514. #undef NO_RC4
  515. #define NO_RC4
  516. #undef NO_OLD_TLS
  517. #define NO_OLD_TLS
  518. #undef NO_PSK
  519. #define NO_PSK
  520. #undef NO_MD4
  521. #define NO_MD4
  522. #undef NO_PWDBASED
  523. //#define NO_PWDBASED
  524. #undef NO_CODING
  525. //#define NO_CODING
  526. #undef NO_ASN_TIME
  527. //#define NO_ASN_TIME
  528. #undef NO_CERTS
  529. //#define NO_CERTS
  530. #undef NO_SIG_WRAPPER
  531. //#define NO_SIG_WRAPPER
  532. /* wolfSSL engineering ACVP algo and operational testing only (Default: Off) */
  533. #if 0
  534. #undef WOLFSSL_PUBLIC_MP
  535. #define WOLFSSL_PUBLIC_MP
  536. #undef HAVE_FORCE_FIPS_FAILURE
  537. #define HAVE_FORCE_FIPS_FAILURE
  538. #endif
  539. #ifdef __cplusplus
  540. }
  541. #endif
  542. #endif /* WOLFSSL_USER_SETTINGS_H */