2
0

user_settings.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /* Example custom user settings for wolfSSL */
  2. #ifndef WOLFSSL_USER_SETTINGS_H
  3. #define WOLFSSL_USER_SETTINGS_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stddef.h> /* for size_t */
  8. /* ------------------------------------------------------------------------- */
  9. /* Platform */
  10. /* ------------------------------------------------------------------------- */
  11. #undef WOLFSSL_GENERAL_ALIGNMENT
  12. #define WOLFSSL_GENERAL_ALIGNMENT 4
  13. #undef SINGLE_THREADED
  14. #define SINGLE_THREADED
  15. #undef WOLFSSL_SMALL_STACK
  16. //#define WOLFSSL_SMALL_STACK
  17. #undef WOLFSSL_SMALL_STACK_CACHE
  18. //#define WOLFSSL_SMALL_STACK_CACHE
  19. #define WOLFSSL_IGNORE_FILE_WARN
  20. /* ------------------------------------------------------------------------- */
  21. /* Math Configuration */
  22. /* ------------------------------------------------------------------------- */
  23. #undef USE_FAST_MATH
  24. #define USE_FAST_MATH
  25. #ifdef USE_FAST_MATH
  26. #undef TFM_TIMING_RESISTANT
  27. #define TFM_TIMING_RESISTANT
  28. /* Optimizations (TFM_ARM, TFM_ASM or none) */
  29. #define TFM_ARM
  30. //#define TFM_ASM
  31. #endif
  32. /* Math debugging (adds support for mp_dump) */
  33. #undef WOLFSSL_DEBUG_MATH
  34. //#define WOLFSSL_DEBUG_MATH
  35. /* Wolf Single Precision Math */
  36. #undef WOLFSSL_SP
  37. #if 0
  38. #define WOLFSSL_SP
  39. #define WOLFSSL_SP_SMALL /* use smaller version of code */
  40. #define WOLFSSL_HAVE_SP_RSA
  41. #define WOLFSSL_HAVE_SP_DH
  42. #define WOLFSSL_HAVE_SP_ECC
  43. #define WOLFSSL_SP_MATH /* only SP math - eliminates fast math code */
  44. /* SP Assembly Speedups */
  45. #define WOLFSSL_SP_ASM /* required if using the ASM versions */
  46. //#define WOLFSSL_SP_ARM32_ASM
  47. //#define WOLFSSL_SP_ARM64_ASM
  48. //#define WOLFSSL_SP_ARM_THUMB_ASM
  49. #define WOLFSSL_SP_ARM_CORTEX_M_ASM
  50. #endif
  51. /* ------------------------------------------------------------------------- */
  52. /* Crypto */
  53. /* ------------------------------------------------------------------------- */
  54. /* ECC */
  55. #if 1
  56. #undef HAVE_ECC
  57. #define HAVE_ECC
  58. /* Manually define enabled curves */
  59. #undef ECC_USER_CURVES
  60. #define ECC_USER_CURVES
  61. #define HAVE_ECC192
  62. #define HAVE_ECC224
  63. #undef NO_ECC256
  64. #define HAVE_ECC384
  65. #ifndef USE_NXP_LTC /* NXP LTC HW supports up to 384 */
  66. #define HAVE_ECC521
  67. #endif
  68. /* Fixed point cache (speeds repeated operations against same private key) */
  69. #undef FP_ECC
  70. //#define FP_ECC
  71. #ifdef FP_ECC
  72. /* Bits / Entries */
  73. #undef FP_ENTRIES
  74. #define FP_ENTRIES 2
  75. #undef FP_LUT
  76. #define FP_LUT 4
  77. #endif
  78. /* Optional ECC calculation method */
  79. /* Note: doubles heap usage, but slightly faster */
  80. #undef ECC_SHAMIR
  81. #ifndef USE_NXP_LTC /* Don't enable Shamir code for HW ECC */
  82. #define ECC_SHAMIR
  83. #endif
  84. /* Reduces heap usage, but slower */
  85. #undef ECC_TIMING_RESISTANT
  86. #define ECC_TIMING_RESISTANT
  87. #ifdef USE_FAST_MATH
  88. /* use reduced size math buffers for ecc points */
  89. #undef ALT_ECC_SIZE
  90. #define ALT_ECC_SIZE
  91. /* Enable TFM optimizations for ECC */
  92. #if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
  93. #define TFM_ECC192
  94. #endif
  95. #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
  96. #define TFM_ECC224
  97. #endif
  98. #if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
  99. #define TFM_ECC256
  100. #endif
  101. #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
  102. #define TFM_ECC384
  103. #endif
  104. #if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
  105. #define TFM_ECC521
  106. #endif
  107. #endif
  108. #endif
  109. /* RSA */
  110. #undef NO_RSA
  111. #if 1
  112. #ifdef USE_FAST_MATH
  113. /* Maximum math bits (Max RSA key bits * 2) */
  114. #undef FP_MAX_BITS
  115. #define FP_MAX_BITS 4096
  116. #endif
  117. /* half as much memory but twice as slow */
  118. #undef RSA_LOW_MEM
  119. //#define RSA_LOW_MEM
  120. /* Enables blinding mode, to prevent timing attacks */
  121. #undef WC_RSA_BLINDING
  122. #define WC_RSA_BLINDING
  123. #else
  124. #define NO_RSA
  125. #endif
  126. /* AES */
  127. #undef NO_AES
  128. #if 1
  129. #undef HAVE_AESGCM
  130. #define HAVE_AESGCM
  131. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  132. #undef GCM_SMALL
  133. #define GCM_SMALL
  134. #else
  135. #define NO_AES
  136. #endif
  137. /* ChaCha20 / Poly1305 */
  138. #undef HAVE_CHACHA
  139. #undef HAVE_POLY1305
  140. #if 1
  141. #define HAVE_CHACHA
  142. #define HAVE_POLY1305
  143. /* Needed for Poly1305 */
  144. #undef HAVE_ONE_TIME_AUTH
  145. #define HAVE_ONE_TIME_AUTH
  146. #endif
  147. /* Ed25519 / Curve25519 */
  148. #undef HAVE_CURVE25519
  149. #undef HAVE_ED25519
  150. #if 1
  151. #define HAVE_CURVE25519
  152. #define HAVE_ED25519
  153. /* Optionally use small math (less flash usage, but much slower) */
  154. #if 0
  155. #define CURVED25519_SMALL
  156. #endif
  157. #endif
  158. /* ------------------------------------------------------------------------- */
  159. /* Hashing */
  160. /* ------------------------------------------------------------------------- */
  161. /* Sha */
  162. #undef NO_SHA
  163. #if 1
  164. /* 1k smaller, but 25% slower */
  165. //#define USE_SLOW_SHA
  166. #else
  167. #define NO_SHA
  168. #endif
  169. /* Sha256 */
  170. #undef NO_SHA256
  171. #if 1
  172. #else
  173. #define NO_SHA256
  174. #endif
  175. /* Sha512 */
  176. #undef WOLFSSL_SHA512
  177. #if 1
  178. #define WOLFSSL_SHA512
  179. /* Sha384 */
  180. #undef WOLFSSL_SHA384
  181. #if 1
  182. #define WOLFSSL_SHA384
  183. #endif
  184. /* over twice as small, but 50% slower */
  185. //#define USE_SLOW_SHA2
  186. #endif
  187. /* MD5 */
  188. #undef NO_MD5
  189. #if 1
  190. #else
  191. #define NO_MD5
  192. #endif
  193. /* ------------------------------------------------------------------------- */
  194. /* HW Crypto Acceleration */
  195. /* ------------------------------------------------------------------------- */
  196. #define FSL_HW_CRYPTO_MANUAL_SELECTION
  197. #if 1
  198. /* NXP MMCAU / LTC Support (See README.md for instructions) */
  199. #if defined(USE_NXP_MMCAU) || defined(USE_NXP_LTC)
  200. #ifdef USE_NXP_MMCAU
  201. #define FREESCALE_USE_MMCAU
  202. #endif
  203. #ifdef USE_NXP_LTC
  204. #define FREESCALE_USE_LTC
  205. #define LTC_MAX_ECC_BITS (384)
  206. #define LTC_MAX_INT_BYTES (256)
  207. //#define FREESCALE_LTC_TFM_RSA_4096_ENABLE
  208. #endif
  209. #endif
  210. #endif
  211. /* ------------------------------------------------------------------------- */
  212. /* Benchmark / Test */
  213. /* ------------------------------------------------------------------------- */
  214. /* Use reduced benchmark / test sizes */
  215. #undef BENCH_EMBEDDED
  216. #define BENCH_EMBEDDED
  217. #undef USE_CERT_BUFFERS_2048
  218. #define USE_CERT_BUFFERS_2048
  219. #undef USE_CERT_BUFFERS_256
  220. #define USE_CERT_BUFFERS_256
  221. /* ------------------------------------------------------------------------- */
  222. /* Debugging */
  223. /* ------------------------------------------------------------------------- */
  224. #undef DEBUG_WOLFSSL
  225. //#define DEBUG_WOLFSSL
  226. #ifdef DEBUG_WOLFSSL
  227. #define fprintf(file, format, ...) printf(format, ##__VA_ARGS__)
  228. /* Use this to measure / print heap usage */
  229. #if 0
  230. #undef USE_WOLFSSL_MEMORY
  231. #define USE_WOLFSSL_MEMORY
  232. #undef WOLFSSL_TRACK_MEMORY
  233. #define WOLFSSL_TRACK_MEMORY
  234. #endif
  235. #else
  236. #undef NO_WOLFSSL_MEMORY
  237. #define NO_WOLFSSL_MEMORY
  238. #undef NO_ERROR_STRINGS
  239. //#define NO_ERROR_STRINGS
  240. #endif
  241. /* ------------------------------------------------------------------------- */
  242. /* Port */
  243. /* ------------------------------------------------------------------------- */
  244. /* Override Current Time */
  245. /* Allows custom "custom_time()" function to be used for benchmark */
  246. #define WOLFSSL_USER_CURRTIME
  247. #define USER_TICKS
  248. extern unsigned long ksdk_time(unsigned long* timer);
  249. #define XTIME ksdk_time
  250. /* ------------------------------------------------------------------------- */
  251. /* RNG */
  252. /* ------------------------------------------------------------------------- */
  253. /* Size of returned HW RNG value */
  254. #define CUSTOM_RAND_TYPE unsigned int
  255. /* Seed source */
  256. extern unsigned int custom_rand_generate(void);
  257. #undef CUSTOM_RAND_GENERATE
  258. #define CUSTOM_RAND_GENERATE custom_rand_generate
  259. /* Choose RNG method */
  260. #if 1
  261. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  262. /* P-RNG + HW RNG (P-RNG is ~8K) */
  263. #undef HAVE_HASHDRBG
  264. #define HAVE_HASHDRBG
  265. #else
  266. #undef WC_NO_HASHDRBG
  267. #define WC_NO_HASHDRBG
  268. /* Bypass P-RNG and use only HW RNG */
  269. extern int custom_rand_generate_block(unsigned char* output, unsigned int sz);
  270. #undef CUSTOM_RAND_GENERATE_BLOCK
  271. #define CUSTOM_RAND_GENERATE_BLOCK custom_rand_generate_block
  272. #endif
  273. /* ------------------------------------------------------------------------- */
  274. /* Enable Features */
  275. /* ------------------------------------------------------------------------- */
  276. #undef KEEP_PEER_CERT
  277. //#define KEEP_PEER_CERT
  278. #undef HAVE_COMP_KEY
  279. //#define HAVE_COMP_KEY
  280. #undef HAVE_TLS_EXTENSIONS
  281. //#define HAVE_TLS_EXTENSIONS
  282. #undef HAVE_SUPPORTED_CURVES
  283. //#define HAVE_SUPPORTED_CURVES
  284. #undef WOLFSSL_BASE64_ENCODE
  285. //#define WOLFSSL_BASE64_ENCODE
  286. /* TLS Session Cache */
  287. #if 0
  288. #define SMALL_SESSION_CACHE
  289. #else
  290. #define NO_SESSION_CACHE
  291. #endif
  292. /* ------------------------------------------------------------------------- */
  293. /* Disable Features */
  294. /* ------------------------------------------------------------------------- */
  295. #undef NO_WOLFSSL_SERVER
  296. //#define NO_WOLFSSL_SERVER
  297. #undef NO_WOLFSSL_CLIENT
  298. //#define NO_WOLFSSL_CLIENT
  299. #undef NO_CRYPT_TEST
  300. //#define NO_CRYPT_TEST
  301. #undef NO_CRYPT_BENCHMARK
  302. //#define NO_CRYPT_BENCHMARK
  303. /* In-lining of misc.c functions */
  304. /* If defined, must include wolfcrypt/src/misc.c in build */
  305. /* Slower, but about 1k smaller */
  306. #undef NO_INLINE
  307. //#define NO_INLINE
  308. #undef NO_FILESYSTEM
  309. #define NO_FILESYSTEM
  310. #undef NO_WRITEV
  311. #define NO_WRITEV
  312. #undef NO_MAIN_DRIVER
  313. #define NO_MAIN_DRIVER
  314. #undef NO_DEV_RANDOM
  315. #define NO_DEV_RANDOM
  316. #undef NO_DSA
  317. #define NO_DSA
  318. #undef NO_DH
  319. #define NO_DH
  320. #undef NO_DES3
  321. #define NO_DES3
  322. #undef NO_RC4
  323. #define NO_RC4
  324. #undef NO_OLD_TLS
  325. #define NO_OLD_TLS
  326. #undef NO_PSK
  327. #define NO_PSK
  328. #undef NO_MD4
  329. #define NO_MD4
  330. #undef NO_PWDBASED
  331. #define NO_PWDBASED
  332. #undef NO_CODING
  333. #define NO_CODING
  334. #ifdef __cplusplus
  335. }
  336. #endif
  337. #endif /* WOLFSSL_USER_SETTINGS_H */