user_settings.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. #ifndef USER_SETTINGS_H
  22. #define USER_SETTINGS_H
  23. #ifdef CONFIG_WOLFSSL
  24. /* If a custom user_settings file is provided use it instead */
  25. #ifdef WOLFSSL_SETTINGS_FILE
  26. #include WOLFSSL_SETTINGS_FILE
  27. #else
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* ------------------------------------------------------------------------- */
  32. /* Platform */
  33. /* ------------------------------------------------------------------------- */
  34. #define WOLFSSL_GENERAL_ALIGNMENT 4 /* platform requires 32-bit alignment on uint32_t */
  35. #define SIZEOF_LONG_LONG 8 /* long long is 8 bytes / 64-bit */
  36. //#define WOLFSSL_NO_ASM /* optionally disable inline assembly support */
  37. #define WOLFSSL_IGNORE_FILE_WARN /* ignore file includes not required */
  38. //#define WOLFSSL_SMALL_STACK /* option to reduce stack size, offload to heap */
  39. #define BENCH_EMBEDDED /* use smaller buffers in benchmark / tests */
  40. /* Network stack */
  41. /* Default is POSIX sockets */
  42. //#define WOLFSSL_USER_IO /* Use the SetIO callbacks, not the internal wolfio.c socket code */
  43. //#define WOLFSSL_LWIP
  44. //#define WOLFSSL_LWIP_NATIVE
  45. //#define FREERTOS_TCP
  46. /* RTOS */
  47. /* Default is POSIX mutex and pthreads*/
  48. //#define SINGLE_THREADED
  49. //#define FREERTOS
  50. #define NO_FILESYSTEM
  51. #define NO_WRITEV
  52. /* ------------------------------------------------------------------------- */
  53. /* Hardware */
  54. /* ------------------------------------------------------------------------- */
  55. /* CryptoCell support */
  56. #if 0
  57. //#define WOLFSSL_CRYPTOCELL
  58. //#define WOLFSSL_CRYPTOCELL_AES
  59. #endif
  60. /* PSA support */
  61. #ifdef CONFIG_MBEDTLS_PSA_CRYPTO_C
  62. #define WOLFSSL_HAVE_PSA
  63. #ifndef SINGLE_THREADED
  64. #define WOLFSSL_PSA_GLOBAL_LOCK
  65. #endif
  66. #define WC_NO_HASHDRBG /* use PSA RNG directly via wc_psa_get_random */
  67. #endif
  68. /* ------------------------------------------------------------------------- */
  69. /* FIPS */
  70. /* ------------------------------------------------------------------------- */
  71. #ifdef CONFIG_WOLFCRYPT_FIPS
  72. /* FIPS Ready */
  73. #define HAVE_FIPS_VERSION 5
  74. #define HAVE_FIPS_VERSION_MINOR 3
  75. #endif
  76. /* ------------------------------------------------------------------------- */
  77. /* TLS */
  78. /* ------------------------------------------------------------------------- */
  79. /* TLS v1.2 (on by default) */
  80. #ifdef CONFIG_WOLFSSL_TLS_VERSION_1_2
  81. #undef WOLFSSL_NO_TLS12
  82. #else
  83. #define WOLFSSL_NO_TLS12
  84. #endif
  85. //#define NO_WOLFSSL_SERVER /* Optionally disable TLS server code */
  86. //#define NO_WOLFSSL_CLIENT /* Optionally disable TLS client code */
  87. /* TLS v1.3 */
  88. #if defined(CONFIG_WOLFSSL_TLS_VERSION_1_3) || defined(CONFIG_WOLFSSL_TLS13_ENABLED)
  89. #define WOLFSSL_TLS13
  90. #endif
  91. /* Disable older TLS version prior to 1.2 */
  92. #define NO_OLD_TLS
  93. /* Enable default TLS extensions */
  94. #define HAVE_TLS_EXTENSIONS
  95. #define HAVE_SUPPORTED_CURVES
  96. #define HAVE_EXTENDED_MASTER
  97. #define HAVE_ENCRYPT_THEN_MAC
  98. #define HAVE_SERVER_RENEGOTIATION_INFO
  99. #define HAVE_SNI /* optional Server Name Indicator (SNI) */
  100. /* ASN */
  101. #define WOLFSSL_ASN_TEMPLATE /* use newer ASN template asn.c code (default) */
  102. #if 0 /* optional space reductions */
  103. #define WOLFSSL_NO_ASN_STRICT
  104. #define IGNORE_NAME_CONSTRAINTS
  105. #endif
  106. /* Session Cache */
  107. #if 1
  108. #define SMALL_SESSION_CACHE
  109. #ifdef WOLFSSL_TLS13
  110. #define HAVE_SESSION_TICKET /* session tickets required for resumption in TLS v1.3 */
  111. #endif
  112. #else
  113. #define NO_SESSION_CACHE /* disable session resumption */
  114. #endif
  115. /* PSK */
  116. #define NO_PSK /* disable pre-shared-key support */
  117. /* ------------------------------------------------------------------------- */
  118. /* Algorithms */
  119. /* ------------------------------------------------------------------------- */
  120. /* RNG */
  121. #ifndef WC_NO_HASHDRBG
  122. #define HAVE_HASHDRBG /* Use DRBG SHA2-256 and seed */
  123. #endif
  124. /* ECC */
  125. #if 1
  126. #define HAVE_ECC
  127. #define ECC_USER_CURVES /* Enable only ECC curves specific */
  128. #undef NO_ECC256 /* Enable SECP256R1 only (on by default) */
  129. #define ECC_TIMING_RESISTANT /* Enable Timing Resistance */
  130. //#define ECC_SHAMIR /* Optional ECC calculation speed improvement if not using SP implementation */
  131. //#define WOLFSSL_CUSTOM_CURVES /* enable other curves (not just prime) */
  132. //#define HAVE_ECC_SECPR2
  133. //#define HAVE_ECC_SECPR3
  134. //#define HAVE_ECC_BRAINPOOL
  135. //#define HAVE_ECC_KOBLITZ
  136. //#define HAVE_ECC_CDH /* Co-factor */
  137. //#define HAVE_COMP_KEY /* Compressed key support */
  138. //#define FP_ECC /* Fixed point caching - speed repeated operations against same key */
  139. //#define HAVE_ECC_ENCRYPT
  140. //#define WOLFCRYPT_HAVE_ECCSI
  141. //#define WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT
  142. #endif
  143. #define WOLFSSL_OLD_PRIME_CHECK /* Use faster DH prime checking */
  144. /* RSA */
  145. #if 1
  146. #undef NO_RSA
  147. #define WC_RSA_BLINDING
  148. //#define WC_RSA_NO_PADDING
  149. //#define RSA_LOW_MEM
  150. #if 0
  151. #define WOLFSSL_KEY_GEN /* For RSA Key gen only */
  152. #endif
  153. #if defined(WOLFSSL_TLS13) || defined(CONFIG_WOLFSSL_RSA_PSS)
  154. /* TLS v1.3 requires RSA PSS padding */
  155. #define WC_RSA_PSS
  156. //#define WOLFSSL_PSS_LONG_SALT
  157. #endif
  158. #else
  159. #define NO_RSA
  160. #endif
  161. /* DH */
  162. #if 0
  163. #undef NO_DH /* on by default */
  164. #define WOLFSSL_DH_CONST /* don't rely on pow/log */
  165. #define HAVE_FFDHE_2048
  166. #define HAVE_FFDHE_3072
  167. #define HAVE_DH_DEFAULT_PARAMS
  168. //#define WOLFSSL_DH_EXTRA /* Enable additional DH key import/export */
  169. #else
  170. #define NO_DH
  171. #endif
  172. /* ChaCha20 / Poly1305 */
  173. #if 1
  174. #define HAVE_CHACHA
  175. #define HAVE_POLY1305
  176. /* Needed for Poly1305 */
  177. #define HAVE_ONE_TIME_AUTH
  178. #endif
  179. /* Ed25519 / Curve25519 */
  180. #if 0
  181. #define HAVE_CURVE25519
  182. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  183. /* Optionally use small math (less flash usage, but much slower) */
  184. //#define CURVED25519_SMALL
  185. #endif
  186. /* SHA-1 */
  187. #if 0
  188. #undef NO_SHA /* on by default */
  189. //#define USE_SLOW_SHA /* 1k smaller, but 25% slower */
  190. #else
  191. #define NO_SHA
  192. #endif
  193. /* SHA2-256 */
  194. #if 1
  195. #undef NO_SHA256 /* on by default */
  196. //#define USE_SLOW_SHA256 /* ~2k smaller and about 25% slower */
  197. #define WOLFSSL_SHA224
  198. #else
  199. #define NO_SHA256
  200. #endif
  201. /* SHA2-384/512 */
  202. #if 1
  203. #define WOLFSSL_SHA384
  204. #define WOLFSSL_SHA512
  205. //#define USE_SLOW_SHA512 /* Over twice as small, but 50% slower */
  206. #endif
  207. /* SHA-3 */
  208. #if 1
  209. #define WOLFSSL_SHA3
  210. #endif
  211. /* AES */
  212. #define HAVE_AES_ECB
  213. /* AES-CBC */
  214. #if 1
  215. #define HAVE_AES_CBC
  216. #else
  217. #define NO_AES_CBC
  218. #endif
  219. /* AES-GCM */
  220. #if 1
  221. #define HAVE_AESGCM
  222. #define GCM_SMALL /* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  223. //#define WOLFSSL_AESGCM_STREAM
  224. #endif
  225. //#define HAVE_AES_DECRYPT
  226. //#define WOLFSSL_AES_COUNTER
  227. //#define WOLFSSL_AES_CFB
  228. //#define WOLFSSL_AES_OFB
  229. //#define HAVE_AESCCM
  230. //#define WOLFSSL_AES_XTS
  231. //#define NO_AES_128
  232. //#define NO_AES_192
  233. //#define NO_AES_256
  234. //#define WOLFSSL_AES_SMALL_TABLES
  235. //#define WOLFSSL_AES_NO_UNROLL
  236. /* HKDF */
  237. #if defined(WOLFSSL_TLS13) || defined(CONFIG_WOLFSSL_HKDF)
  238. #define HAVE_HKDF
  239. #endif
  240. /* CMAC - Zephyr nRF BTLE needs CMAC */
  241. #if 1
  242. #define WOLFSSL_AES_DIRECT
  243. #define WOLFSSL_CMAC
  244. #endif
  245. /* Optional Features */
  246. #define WOLFSSL_BASE64_ENCODE /* Enable Base64 encoding */
  247. //#define WC_NO_CACHE_RESISTANT /* systems with cache should enable this for AES, ECC, RSA and DH */
  248. //#define WOLFSSL_CERT_GEN
  249. //#define WOLFSSL_CERT_REQ
  250. //#define WOLFSSL_CERT_EXT
  251. //#define NO_PWDBASED
  252. /* Disable Algorithms */
  253. #define NO_DSA
  254. #define NO_RC4
  255. #define NO_MD4
  256. #define NO_MD5
  257. #define NO_DES3
  258. #define WOLFSSL_NO_SHAKE128
  259. #define WOLFSSL_NO_SHAKE256
  260. /* ------------------------------------------------------------------------- */
  261. /* Math */
  262. /* ------------------------------------------------------------------------- */
  263. /* Math Options */
  264. /* Multi-precision - generic math for all keys sizes and curves */
  265. #if 1
  266. #define WOLFSSL_SP_MATH /* no multi-precision math, only single */
  267. #elif 1
  268. /* wolf mp math (sp_int.c) */
  269. #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */
  270. //#define WOLFSSL_SP_NO_MALLOC
  271. /* use smaller version of code */
  272. #define WOLFSSL_SP_SMALL
  273. /* Define the maximum math bits used */
  274. #if !defined(NO_RSA) || !defined(NO_DH)
  275. #define SP_INT_BITS 2048
  276. #elif defined(HAVE_ECC)
  277. #define SP_INT_BITS 256
  278. #endif
  279. #elif 1
  280. /* Fast Math (tfm.c) (stack based and timing resistant) */
  281. #define USE_FAST_MATH
  282. #define TFM_TIMING_RESISTANT
  283. /* Define the maximum math bits used (2 * max) */
  284. #if !defined(NO_RSA) || !defined(NO_DH)
  285. #define FP_MAX_BITS (2*2048)
  286. #ifdef HAVE_ECC
  287. #define ALT_ECC_SIZE /* use heap allocation for ECC point */
  288. #endif
  289. #elif defined(HAVE_ECC)
  290. #define FP_MAX_BITS (2*256)
  291. #endif
  292. #ifdef HAVE_ECC
  293. //#define TFM_ECC256 /* optional speedup for ECC-256 bit */
  294. #endif
  295. #else
  296. /* Normal (integer.c) (heap based, not timing resistant) - not recommended */
  297. #define USE_INTEGER_HEAP_MATH
  298. #endif
  299. /* Single Precision (optional) */
  300. /* Math written for specific curves and key sizes */
  301. #if 1
  302. #ifdef HAVE_ECC
  303. #define WOLFSSL_HAVE_SP_ECC
  304. //#define WOLFSSL_SP_NO_256
  305. //#define WOLFSSL_SP_384
  306. //#define WOLFSSL_SP_521
  307. #endif
  308. #ifndef NO_RSA
  309. #define WOLFSSL_HAVE_SP_RSA
  310. //#define WOLFSSL_SP_NO_2048
  311. //#define WOLFSSL_SP_NO_3072
  312. //#define WOLFSSL_SP_4096
  313. #endif
  314. #ifndef NO_DH
  315. #define WOLFSSL_HAVE_SP_DH
  316. #endif
  317. #define WOLFSSL_SP_SMALL /* use smaller version of code */
  318. //#define WOLFSSL_SP_NO_MALLOC /* disable heap in wolf/SP math */
  319. //#define SP_DIV_WORD_USE_DIV /* no div64 */
  320. #if 0
  321. /* optional speedup with inline assembly */
  322. //#define WOLFSSL_SP_ARM_CORTEX_M_ASM /* Cortex-M3+ */
  323. //#define WOLFSSL_SP_ARM_THUMB_ASM /* Cortex-M0+ thumb */
  324. //#define WOLFSSL_SP_ARM32_ASM /* Cortex-R */
  325. //#define WOLFSSL_SP_ARM64_ASM /* Cortex-A */
  326. //#define WOLFSSL_SP_USE_UDIV
  327. #endif
  328. #endif
  329. /* ------------------------------------------------------------------------- */
  330. /* Assembly Speedups for Symmetric Algorithms */
  331. /* ------------------------------------------------------------------------- */
  332. #ifdef CONFIG_WOLFCRYPT_ARMASM
  333. #define WOLFSSL_ARMASM
  334. #define WOLFSSL_NO_HASH_RAW
  335. #define WOLFSSL_ARMASM_INLINE /* use inline .c versions */
  336. #define WOLFSSL_ARMASM_NO_NEON
  337. /* Default is ARMv8 */
  338. #if 0 /* ARMv7 */
  339. #define WOLFSSL_ARM_ARCH 7
  340. #define WOLFSSL_ARMASM_NO_HW_CRYPTO /* enable if processor does not support aes/sha instructions */
  341. #endif
  342. #endif
  343. #ifdef CONFIG_WOLFCRYPT_INTELASM
  344. #define USE_INTEL_SPEEDUP
  345. #define WOLFSSL_X86_64_BUILD /* 64-bit */
  346. //#define WOLFSSL_X86_BUILD /* 32-bit */
  347. /* Issues with building AESNI "_mm_aesimc_si128" always_inline */
  348. //#define WOLFSSL_AESNI
  349. #endif
  350. /* ------------------------------------------------------------------------- */
  351. /* Debugging */
  352. /* ------------------------------------------------------------------------- */
  353. #undef DEBUG_WOLFSSL
  354. #undef NO_ERROR_STRINGS
  355. #ifdef CONFIG_WOLFSSL_DEBUG
  356. #define DEBUG_WOLFSSL
  357. #else
  358. #if 1
  359. #define NO_ERROR_STRINGS
  360. #endif
  361. #endif
  362. #ifdef __cplusplus
  363. }
  364. #endif
  365. #endif /* CONFIG_WOLFSSL_SETTINGS_FILE */
  366. #endif /* CONFIG_WOLFSSL */
  367. #endif /* USER_SETTINGS_H */