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