user_settings.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /* user_settings.h
  2. *
  3. * Copyright (C) 2006-2023 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 XCODE-FIPSv2/macOS-C++/Intel */
  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. #endif
  55. #if 1 /* AESNI (wPAA) */
  56. #define WOLFSSL_AESNI
  57. #endif
  58. /* ------------------------------------------------------------------------- */
  59. /* FIPS - Requires eval or license from wolfSSL */
  60. /* ------------------------------------------------------------------------- */
  61. #undef HAVE_FIPS
  62. #if 1
  63. #define HAVE_FIPS
  64. #undef HAVE_FIPS_VERSION
  65. #define HAVE_FIPS_VERSION 2
  66. #ifdef SINGLE_THREADED
  67. #undef NO_THREAD_LS
  68. #define NO_THREAD_LS
  69. #endif
  70. #if 0
  71. #undef NO_ATTRIBUTE_CONSTRUCTOR
  72. #define NO_ATTRIBUTE_CONSTRUCTOR
  73. #endif
  74. #endif
  75. /* ------------------------------------------------------------------------- */
  76. /* Crypto */
  77. /* ------------------------------------------------------------------------- */
  78. /* RSA */
  79. #undef NO_RSA
  80. #if 1
  81. #ifdef USE_FAST_MATH
  82. /* Maximum math bits (Max RSA key bits * 2) */
  83. #undef FP_MAX_BITS
  84. #define FP_MAX_BITS 8192
  85. #endif
  86. /* half as much memory but twice as slow */
  87. #undef RSA_LOW_MEM
  88. //#define RSA_LOW_MEM
  89. /* Enables blinding mode, to prevent timing attacks */
  90. #if 0
  91. #undef WC_RSA_BLINDING
  92. #define WC_RSA_BLINDING
  93. #else
  94. #undef WC_NO_HARDEN
  95. #define WC_NO_HARDEN
  96. #endif
  97. /* RSA PSS Support */
  98. #if 1
  99. #undef WC_RSA_PSS
  100. #define WC_RSA_PSS
  101. #endif
  102. #if 1
  103. #define WC_RSA_NO_PADDING
  104. #endif
  105. #else
  106. #define NO_RSA
  107. #endif
  108. /* ECC */
  109. #undef HAVE_ECC
  110. #if 1
  111. #define HAVE_ECC
  112. /* Manually define enabled curves */
  113. #undef ECC_USER_CURVES
  114. //#define ECC_USER_CURVES
  115. #ifdef ECC_USER_CURVES
  116. /* Manual Curve Selection */
  117. //#define HAVE_ECC192
  118. //#define HAVE_ECC224
  119. #undef NO_ECC256
  120. //#define HAVE_ECC384
  121. //#define HAVE_ECC521
  122. #endif
  123. /* Fixed point cache (speeds repeated operations against same private key) */
  124. #undef FP_ECC
  125. //#define FP_ECC
  126. #ifdef FP_ECC
  127. /* Bits / Entries */
  128. #undef FP_ENTRIES
  129. #define FP_ENTRIES 2
  130. #undef FP_LUT
  131. #define FP_LUT 4
  132. #endif
  133. /* Optional ECC calculation method */
  134. /* Note: doubles heap usage, but slightly faster */
  135. #undef ECC_SHAMIR
  136. #define ECC_SHAMIR
  137. /* Reduces heap usage, but slower */
  138. #undef ECC_TIMING_RESISTANT
  139. #define ECC_TIMING_RESISTANT
  140. #ifdef HAVE_FIPS
  141. #undef HAVE_ECC_CDH
  142. #define HAVE_ECC_CDH /* Enable cofactor support */
  143. #undef NO_STRICT_ECDSA_LEN
  144. #define NO_STRICT_ECDSA_LEN /* Do not force fixed len w/ FIPS */
  145. #undef WOLFSSL_VALIDATE_ECC_IMPORT
  146. #define WOLFSSL_VALIDATE_ECC_IMPORT /* Validate import */
  147. #endif
  148. /* Compressed Key Support */
  149. #undef HAVE_COMP_KEY
  150. //#define HAVE_COMP_KEY
  151. /* Use alternate ECC size for ECC math */
  152. #ifdef USE_FAST_MATH
  153. /* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
  154. #ifdef NO_RSA
  155. /* Custom fastmath size if not using RSA */
  156. #undef FP_MAX_BITS
  157. #define FP_MAX_BITS (256 * 2)
  158. #else
  159. #undef ALT_ECC_SIZE
  160. #define ALT_ECC_SIZE
  161. /* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overridden */
  162. //#undef FP_MAX_BITS_ECC
  163. //#define FP_MAX_BITS_ECC (256 * 2)
  164. #endif
  165. /* Speedups specific to curve */
  166. #ifndef NO_ECC256
  167. #undef TFM_ECC256
  168. #define TFM_ECC256
  169. #endif
  170. #endif
  171. #endif
  172. /* DH */
  173. #undef NO_DH
  174. #if 1
  175. /* Use table for DH instead of -lm (math) lib dependency */
  176. #if 1
  177. #define WOLFSSL_DH_CONST
  178. #define HAVE_FFDHE_2048
  179. #define HAVE_FFDHE_3072
  180. #define HAVE_FFDHE_4096
  181. //#define HAVE_FFDHE_6144
  182. //#define HAVE_FFDHE_8192
  183. #endif
  184. #ifdef HAVE_FIPS
  185. #define WOLFSSL_VALIDATE_FFC_IMPORT
  186. #define HAVE_FFDHE_Q
  187. #endif
  188. #else
  189. #define NO_DH
  190. #endif
  191. /* AES */
  192. #undef NO_AES
  193. #if 1
  194. #undef HAVE_AES_CBC
  195. #define HAVE_AES_CBC
  196. #undef HAVE_AESGCM
  197. #define HAVE_AESGCM
  198. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  199. #define GCM_TABLE
  200. #undef WOLFSSL_AES_DIRECT
  201. #define WOLFSSL_AES_DIRECT
  202. #undef HAVE_AES_ECB
  203. #define HAVE_AES_ECB
  204. #undef WOLFSSL_AES_COUNTER
  205. #define WOLFSSL_AES_COUNTER
  206. #undef HAVE_AESCCM
  207. #define HAVE_AESCCM
  208. #undef HAVE_AES_KEYWRAP
  209. #define HAVE_AES_KEYWRAP
  210. #else
  211. #define NO_AES
  212. #endif
  213. /* DES3 */
  214. #undef NO_DES3
  215. #if 1
  216. #if 1
  217. #undef WOLFSSL_DES_ECB
  218. #define WOLFSSL_DES_ECB
  219. #endif
  220. #else
  221. #define NO_DES3
  222. #endif
  223. /* ChaCha20 / Poly1305 */
  224. #undef HAVE_CHACHA
  225. #undef HAVE_POLY1305
  226. #if 0
  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. /* over twice as small, but 50% slower */
  277. //#define USE_SLOW_SHA512
  278. #endif
  279. /* Sha3 */
  280. #undef WOLFSSL_SHA3
  281. #if 1
  282. #define WOLFSSL_SHA3
  283. #endif
  284. /* MD5 */
  285. #undef NO_MD5
  286. #if 0 /* NOTE: If NO_OLD_TLS is not defined this needs to be set to '#if 1' */
  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. /* ------------------------------------------------------------------------- */
  313. /* Debugging */
  314. /* ------------------------------------------------------------------------- */
  315. #undef DEBUG_WOLFSSL
  316. #undef NO_ERROR_STRINGS
  317. #if 0
  318. #define DEBUG_WOLFSSL
  319. #else
  320. #if 0
  321. #define NO_ERROR_STRINGS
  322. #endif
  323. #endif
  324. /* ------------------------------------------------------------------------- */
  325. /* Memory */
  326. /* ------------------------------------------------------------------------- */
  327. /* Override Memory API's */
  328. #if 0
  329. #undef XMALLOC_OVERRIDE
  330. #define XMALLOC_OVERRIDE
  331. /* prototypes for user heap override functions */
  332. /* Note: Realloc only required for normal math */
  333. #include <stddef.h> /* for size_t */
  334. extern void *myMalloc(size_t n, void* heap, int type);
  335. extern void myFree(void *p, void* heap, int type);
  336. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  337. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  338. #define XFREE(p, h, t) myFree(p, h, t)
  339. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  340. #endif
  341. #if 0
  342. /* Static memory requires fast math */
  343. #define WOLFSSL_STATIC_MEMORY
  344. /* Disable fallback malloc/free */
  345. #define WOLFSSL_NO_MALLOC
  346. #if 1
  347. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  348. #endif
  349. #endif
  350. /* Memory callbacks */
  351. #if 1
  352. #undef USE_WOLFSSL_MEMORY
  353. #define USE_WOLFSSL_MEMORY
  354. /* Use this to measure / print heap usage */
  355. #if 0
  356. #undef WOLFSSL_TRACK_MEMORY
  357. // #define WOLFSSL_TRACK_MEMORY
  358. #undef WOLFSSL_DEBUG_MEMORY
  359. //#define WOLFSSL_DEBUG_MEMORY
  360. #undef WOLFSSL_DEBUG_MEMORY_PRINT
  361. //#define WOLFSSL_DEBUG_MEMORY_PRINT
  362. #endif
  363. #else
  364. #ifndef WOLFSSL_STATIC_MEMORY
  365. #define NO_WOLFSSL_MEMORY
  366. /* Otherwise we will use stdlib malloc, free and realloc */
  367. #endif
  368. #endif
  369. /* ------------------------------------------------------------------------- */
  370. /* Port */
  371. /* ------------------------------------------------------------------------- */
  372. /* Override Current Time */
  373. /* Allows custom "custom_time()" function to be used for benchmark */
  374. //#define WOLFSSL_USER_CURRTIME
  375. //#define WOLFSSL_GMTIME
  376. //#define USER_TICKS
  377. //extern unsigned long my_time(unsigned long* timer);
  378. //#define XTIME my_time
  379. /* ------------------------------------------------------------------------- */
  380. /* RNG */
  381. /* ------------------------------------------------------------------------- */
  382. /* Seed Source */
  383. /* Seed Source */
  384. // extern int my_rng_generate_seed(unsigned char* output, int sz);
  385. // #undef CUSTOM_RAND_GENERATE_SEED
  386. // #define CUSTOM_RAND_GENERATE_SEED my_rng_generate_seed
  387. /* Choose RNG method */
  388. #if 1
  389. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  390. /* P-RNG + HW RNG (P-RNG is ~8K) */
  391. //#define WOLFSSL_GENSEED_FORTEST
  392. #undef HAVE_HASHDRBG
  393. #define HAVE_HASHDRBG
  394. #else
  395. #undef WC_NO_HASHDRBG
  396. #define WC_NO_HASHDRBG
  397. /* Bypass P-RNG and use only HW RNG */
  398. extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
  399. #undef CUSTOM_RAND_GENERATE_BLOCK
  400. #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
  401. #endif
  402. /* ------------------------------------------------------------------------- */
  403. /* Custom Standard Lib */
  404. /* ------------------------------------------------------------------------- */
  405. /* Allows override of all standard library functions */
  406. #undef STRING_USER
  407. #if 0
  408. #define STRING_USER
  409. #include <string.h>
  410. #undef USE_WOLF_STRSEP
  411. #define USE_WOLF_STRSEP
  412. #define XSTRSEP(s1,d) wc_strsep((s1),(d))
  413. #undef USE_WOLF_STRTOK
  414. #define USE_WOLF_STRTOK
  415. #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
  416. #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
  417. #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
  418. #define XMEMSET(b,c,l) memset((b),(c),(l))
  419. #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
  420. #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
  421. #define XSTRLEN(s1) strlen((s1))
  422. #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
  423. #define XSTRSTR(s1,s2) strstr((s1),(s2))
  424. #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
  425. #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
  426. #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
  427. #define XSNPRINTF snprintf
  428. #endif
  429. /* ------------------------------------------------------------------------- */
  430. /* Enable Features */
  431. /* ------------------------------------------------------------------------- */
  432. #undef WOLFSSL_TLS13
  433. #if 0
  434. #define WOLFSSL_TLS13
  435. #endif
  436. #undef WOLFSSL_KEY_GEN
  437. #if 1
  438. #define WOLFSSL_KEY_GEN
  439. #endif
  440. #if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
  441. #define WOLFSSL_OLD_PRIME_CHECK
  442. #endif
  443. #undef KEEP_PEER_CERT
  444. //#define KEEP_PEER_CERT
  445. #undef HAVE_COMP_KEY
  446. //#define HAVE_COMP_KEY
  447. #undef HAVE_TLS_EXTENSIONS
  448. #define HAVE_TLS_EXTENSIONS
  449. #undef HAVE_SUPPORTED_CURVES
  450. #define HAVE_SUPPORTED_CURVES
  451. #undef WOLFSSL_BASE64_ENCODE
  452. #define WOLFSSL_BASE64_ENCODE
  453. /* TLS Session Cache */
  454. #if 1
  455. #define SMALL_SESSION_CACHE
  456. #else
  457. #define NO_SESSION_CACHE
  458. #endif
  459. #undef OPENSSL_EXTRA
  460. #define OPENSSL_EXTRA
  461. #undef WOLFSSL_DER_LOAD
  462. #define WOLFSSL_DER_LOAD
  463. #undef HAVE_SESSION_TICKET
  464. #define HAVE_SESSION_TICKET
  465. #undef HAVE_EX_DATA
  466. #define HAVE_EX_DATA
  467. #undef HAVE_ENCRYPT_THEN_MAC
  468. #define HAVE_ENCRYPT_THEN_MAC
  469. #undef WOLFSSL_CERT_GEN
  470. #define WOLFSSL_CERT_GEN
  471. #undef ATOMIC_USER
  472. #define ATOMIC_USER
  473. #undef HAVE_SECRET_CALLBACK
  474. #define HAVE_SECRET_CALLBACK
  475. /* ------------------------------------------------------------------------- */
  476. /* Disable Features */
  477. /* ------------------------------------------------------------------------- */
  478. #undef NO_WOLFSSL_SERVER
  479. //#define NO_WOLFSSL_SERVER
  480. #undef NO_WOLFSSL_CLIENT
  481. //#define NO_WOLFSSL_CLIENT
  482. #undef NO_CRYPT_TEST
  483. //#define NO_CRYPT_TEST
  484. #undef NO_CRYPT_BENCHMARK
  485. //#define NO_CRYPT_BENCHMARK
  486. #undef WOLFCRYPT_ONLY
  487. //#define WOLFCRYPT_ONLY
  488. /* In-lining of misc.c functions */
  489. /* If defined, must include wolfcrypt/src/misc.c in build */
  490. /* Slower, but about 1k smaller */
  491. #undef NO_INLINE
  492. //#define NO_INLINE
  493. #undef NO_FILESYSTEM
  494. //#define NO_FILESYSTEM
  495. #undef NO_WRITEV
  496. //#define NO_WRITEV
  497. #undef NO_MAIN_DRIVER
  498. #define NO_MAIN_DRIVER
  499. #undef NO_DEV_RANDOM
  500. //#define NO_DEV_RANDOM
  501. #undef NO_DSA
  502. //#define NO_DSA
  503. #undef NO_RC4
  504. #define NO_RC4
  505. #undef NO_OLD_TLS
  506. #define NO_OLD_TLS /* dependency on MD5, enable MD5 if this setting disabled */
  507. #undef NO_PSK
  508. #define NO_PSK
  509. #undef NO_MD4
  510. #define NO_MD4
  511. #undef NO_PWDBASED
  512. //#define NO_PWDBASED
  513. #undef NO_CODING
  514. //#define NO_CODING
  515. #undef NO_ASN_TIME
  516. //#define NO_ASN_TIME
  517. #undef NO_CERTS
  518. //#define NO_CERTS
  519. #undef NO_SIG_WRAPPER
  520. //#define NO_SIG_WRAPPER
  521. /* wolfSSL engineering ACVP algo and operational testing only (Default: Off) */
  522. #if 0 /* Automation Grep Target */
  523. #undef WOLFSSL_PUBLIC_MP
  524. #define WOLFSSL_PUBLIC_MP
  525. #undef HAVE_FORCE_FIPS_FAILURE
  526. #define HAVE_FORCE_FIPS_FAILURE
  527. /* operational test app depends on MD5 */
  528. #undef NO_MD5
  529. #endif
  530. #ifdef __cplusplus
  531. }
  532. #endif
  533. #endif /* WOLFSSL_USER_SETTINGS_H */