NetBurner 3.5.8
PDF Version
Toggle main menu visibility
IC_D20/user_settings.h
1
/* user_settings_template.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
22
#ifndef WOLFSSL_USER_SETTINGS_H
23
#define WOLFSSL_USER_SETTINGS_H
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
#include <predef.h>
30
31
#define TARGET_EMBEDDED
32
33
/* ------------------------------------------------------------------------- */
34
/* Platform */
35
/* ------------------------------------------------------------------------- */
36
#define WOLFSSL_GENERAL_ALIGNMENT 4
37
38
/* Enable SSH KDF / extKeyUsage SSH bits used by the NetBurner SSH library */
39
#define WOLFSSL_WOLFSSH
40
41
/* Keep PQ off by default until size/perf measured */
42
#define NO_MLKEM
43
#define SIZEOF_LONG_LONG 8
44
#if 0
45
#define NO_64BIT
/* disable use of 64-bit variables */
46
#endif
47
48
#ifdef TARGET_EMBEDDED
49
/* disable mutex locking */
50
// #define SINGLE_THREADED
51
52
/* reduce stack use. For variables over 100 bytes allocate from heap */
53
#define WOLFSSL_SMALL_STACK
54
55
/* disable the built-in socket support and use the IO callbacks.
56
* Set with wolfSSL_CTX_SetIORecv/wolfSSL_CTX_SetIOSend
57
*/
58
#define WOLFSSL_USER_IO
59
#endif
60
61
#define WOLFSSL_32BIT_MILLI_TIME
62
63
/* ------------------------------------------------------------------------- */
64
/* Math Configuration */
65
/* ------------------------------------------------------------------------- */
66
#define ULLONG_MAX 18446744073709551615ULL
67
#define SP_WORD_SIZE 32
68
69
#undef USE_FAST_MATH
70
#if 0
71
/* fast math (tfmc.) (stack based and timing resistant) */
72
#define USE_FAST_MATH
73
#define TFM_TIMING_RESISTANT
74
#else
75
/* normal heap based integer.c (not timing resistant) */
76
#endif
77
78
/* Wolf Single Precision Math */
79
#undef WOLFSSL_SP
80
#if 1
81
#define WOLFSSL_SP
82
#define WOLFSSL_HAVE_SP_RSA
83
#define WOLFSSL_HAVE_SP_DH
84
#define WOLFSSL_HAVE_SP_ECC
85
//#define WOLFSSL_SP_4096 /* Enable RSA/RH 4096-bit support */
86
#define WOLFSSL_SP_384
/* Enable ECC 384-bit SECP384R1 support */
87
88
#define WOLFSSL_SP_CACHE_RESISTANT
89
// #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */
90
#define WOLFSSL_SP_MATH_ALL
/* use SP math for all key sizes and curves */
91
92
//#define WOLFSSL_SP_NO_MALLOC
93
//#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */
94
95
#ifdef TARGET_EMBEDDED
96
/* use smaller version of code */
97
#define WOLFSSL_SP_SMALL
98
#else
99
/* SP Assembly Speedups - specific to chip type */
100
#define WOLFSSL_SP_ASM
101
#endif
102
//#define WOLFSSL_SP_X86_64
103
//#define WOLFSSL_SP_X86
104
//#define WOLFSSL_SP_ARM32_ASM
105
//#define WOLFSSL_SP_ARM64_ASM
106
//#define WOLFSSL_SP_ARM_THUMB_ASM
107
#define WOLFSSL_SP_ARM_CORTEX_M_ASM
108
#endif
109
110
/* ------------------------------------------------------------------------- */
111
/* Crypto */
112
/* ------------------------------------------------------------------------- */
113
/* RSA */
114
#undef NO_RSA
115
#if 1
116
#ifdef USE_FAST_MATH
117
/* Maximum math bits (Max RSA key bits * 2) */
118
#define FP_MAX_BITS 4096
119
#endif
120
121
/* half as much memory but twice as slow */
122
//#define RSA_LOW_MEM
123
124
/* Enables blinding mode, to prevent timing attacks */
125
#define WC_RSA_BLINDING
126
127
/* RSA PSS Support */
128
#define WC_RSA_PSS
129
#else
130
#define NO_RSA
131
#endif
132
133
/* DH */
134
#undef NO_DH
135
#if 1
136
/* Use table for DH instead of -lm (math) lib dependency */
137
#if 1
138
#define WOLFSSL_DH_CONST
139
#define HAVE_FFDHE_2048
140
//#define HAVE_FFDHE_4096
141
//#define HAVE_FFDHE_6144
142
//#define HAVE_FFDHE_8192
143
#endif
144
#else
145
#define NO_DH
146
#endif
147
148
/* ECC */
149
#undef HAVE_ECC
150
#if 1
151
#define HAVE_ECC
152
153
/* Manually define enabled curves */
154
#define ECC_USER_CURVES
155
156
#ifdef ECC_USER_CURVES
157
/* Manual Curve Selection */
158
// #define HAVE_ECC192
159
// #define HAVE_ECC224
160
#undef NO_ECC256
161
#ifdef ENABLE_ECC384
162
#define HAVE_ECC384
163
#else
164
/* wolfSSL 5.9.1 preferredGroup[] in tls.c gates SECP384R1 on
165
* !NO_ECC384 (not on HAVE_ECC384), but TLSX_KeyShare_GenEccKey gates
166
* its switch arm on HAVE_ECC384. Without explicit NO_ECC384, TLS 1.3
167
* client advertises SECP384R1 then key gen returns BAD_FUNC_ARG. */
168
#define NO_ECC384
169
#endif
170
#ifdef ENABLE_ECC521
171
// #define HAVE_ECC521
172
#else
173
/* Same preferredGroup vs. TLSX_KeyShare_GenEccKey asymmetry as
174
* NO_ECC384 above, but for SECP521R1. */
175
#define NO_ECC521
176
#endif
177
#endif
178
179
/* Fixed point cache (speeds repeated operations against same private key) */
180
#define FP_ECC
181
#ifdef FP_ECC
182
/* Bits / Entries */
183
#define FP_ENTRIES 15
184
#define FP_LUT 4
185
#endif
186
187
/* Optional ECC calculation method */
188
/* Note: doubles heap usage, but slightly faster */
189
#define ECC_SHAMIR
190
191
/* Reduces heap usage, but slower */
192
// #define ECC_TIMING_RESISTANT
193
194
/* Compressed ECC Key Support */
195
//#define HAVE_COMP_KEY
196
197
/* Use alternate ECC size for ECC math */
198
#ifdef USE_FAST_MATH
199
/* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
200
#if defined(NO_RSA) && defined(NO_DH)
201
/* Custom fastmath size if not using RSA/DH */
202
#define FP_MAX_BITS (256 * 2)
203
#else
204
/* use heap allocation for ECC points */
205
#define ALT_ECC_SIZE
206
207
/* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overriden */
208
//#define FP_MAX_BITS_ECC (256 * 2)
209
#endif
210
211
/* Speedups specific to curve */
212
#ifndef NO_ECC256
213
#define TFM_ECC256
214
#endif
215
#endif
216
#endif
217
218
219
/* AES */
220
#undef NO_AES
221
#if 1
222
#define HAVE_AES_CBC
223
224
#define HAVE_AESGCM
225
226
/* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */
227
// Listed in order of speed and memory usage
228
// #define GCM_TABLE
229
#define GCM_WORD32
230
// #define GCM_TABLE_4BIT
231
// #define GCM_SMALL
232
233
//#define WOLFSSL_AES_DIRECT
234
//#define HAVE_AES_ECB
235
//#define WOLFSSL_AES_COUNTER
236
#define HAVE_AESCCM
237
#else
238
#define NO_AES
239
#endif
240
241
242
/* DES3 */
243
#undef NO_DES3
244
#if 1
245
#else
246
#define NO_DES3
247
#endif
248
249
/* ChaCha20 / Poly1305 */
250
#undef HAVE_CHACHA
251
#undef HAVE_POLY1305
252
#if 1
253
#define HAVE_CHACHA
254
#define HAVE_POLY1305
255
256
/* Needed for Poly1305 */
257
#define HAVE_ONE_TIME_AUTH
258
#endif
259
260
/* Ed25519 / Curve25519 */
261
#undef HAVE_CURVE25519
262
#undef HAVE_ED25519
263
#if 1
264
#define HAVE_CURVE25519
265
#define HAVE_ED25519
/* ED25519 Requires SHA512 */
266
267
/* Optionally use small math (less flash usage, but much slower) */
268
#if 0
269
#define CURVED25519_SMALL
270
#endif
271
#endif
272
273
274
/* ------------------------------------------------------------------------- */
275
/* Hashing */
276
/* ------------------------------------------------------------------------- */
277
/* Sha */
278
#undef NO_SHA
279
#if 1
280
/* 1k smaller, but 25% slower */
281
//#define USE_SLOW_SHA
282
#else
283
#define NO_SHA
284
#endif
285
286
/* Sha256 */
287
#undef NO_SHA256
288
#if 1
289
/* not unrolled - ~2k smaller and ~25% slower */
290
//#define USE_SLOW_SHA256
291
292
/* Sha224 */
293
#if 0
294
#define WOLFSSL_SHA224
295
#endif
296
#else
297
#define NO_SHA256
298
#endif
299
300
/* Sha512 */
301
#undef WOLFSSL_SHA512
302
#if 1
303
#define WOLFSSL_SHA512
304
305
/* Sha384 */
306
#undef WOLFSSL_SHA384
307
#if 1
308
#define WOLFSSL_SHA384
309
#endif
310
311
/* over twice as small, but 50% slower */
312
//#define USE_SLOW_SHA512
313
#endif
314
315
/* Sha3 */
316
#undef WOLFSSL_SHA3
317
#if 0
318
#define WOLFSSL_SHA3
319
#endif
320
321
/* MD5 */
322
#undef NO_MD5
323
#if 0
324
325
#else
326
#define NO_MD5
327
#endif
328
329
/* HKDF */
330
#undef HAVE_HKDF
331
#if 1
332
#define HAVE_HKDF
333
#endif
334
335
/* CMAC */
336
#undef WOLFSSL_CMAC
337
#if 0
338
#define WOLFSSL_CMAC
339
#endif
340
341
342
/* ------------------------------------------------------------------------- */
343
/* Benchmark / Test */
344
/* ------------------------------------------------------------------------- */
345
#ifdef TARGET_EMBEDDED
346
/* Use reduced benchmark / test sizes */
347
#define BENCH_EMBEDDED
348
#endif
349
350
/* Use test buffers from array (not filesystem) */
351
#ifndef NO_FILESYSTEM
352
#define USE_CERT_BUFFERS_256
353
#define USE_CERT_BUFFERS_2048
354
#endif
355
356
/* ------------------------------------------------------------------------- */
357
/* Debugging */
358
/* To enable, call wolfSSL_Debugging_ON(); where debug output is wanted */
359
/* ------------------------------------------------------------------------- */
360
361
#undef DEBUG_WOLFSSL
362
#undef NO_ERROR_STRINGS
363
#if 0
364
#define DEBUG_WOLFSSL
365
#else
366
#if 0
367
#define NO_ERROR_STRINGS
368
#endif
369
#endif
370
371
// Prints out the TLS secrets to the console, allowing for decryption of the TLS stream
372
// #define SHOW_SECRETS
373
// #define HAVE_SECRET_CALLBACK
374
375
/* ------------------------------------------------------------------------- */
376
/* Memory */
377
/* ------------------------------------------------------------------------- */
378
379
/* TLS SRAM pool size in KB for NBMalloc allocator */
380
#define WOLFSSL_TLS_SRAM_KB 32
381
382
/* Override Memory API's */
383
#ifdef SSL_CUSTOM_MALLOC
384
#define XMALLOC_OVERRIDE
385
386
/* prototypes for user heap override functions */
387
/* Note: Realloc only required for normal math */
388
#include <stddef.h>
/* for size_t */
389
390
extern
void
* NBMalloc(
size_t
n);
391
extern
void
NBFree(
void
*p);
392
extern
void
* NBRealloc(
void
*p,
size_t
n);
393
394
#define XMALLOC(n, h, t) NBMalloc(n)
395
#define XFREE(p, h, t) NBFree(p)
396
#define XREALLOC(p, n, h, t) NBRealloc(p, n)
397
398
// Platform specific fastest memory location
399
#if SSL_CUSTOM_MALLOC == 1
// Fastest memory on platform
400
#define CREATE_MEMORY_ALLOCATOR(name,size) CREATE_MEMORY_ALLOCATOR_SRAM(name,size)
401
#define CREATE_MEMORY_BUFFER(name,size) CREATE_MEMORY_BUFFER_SRAM(name,size)
402
#elif SSL_CUSTOM_MALLOC == 2
403
#define CREATE_MEMORY_ALLOCATOR(name,size) CREATE_MEMORY_ALLOCATOR_TCM(name,size)
404
#define CREATE_MEMORY_BUFFER(name,size) CREATE_MEMORY_BUFFER_TCM(name,size)
405
#elif SSL_CUSTOM_MALLOC == 3
406
#define CREATE_MEMORY_ALLOCATOR(name,size) CREATE_MEMORY_ALLOCATOR_SRAM(name,size)
407
#define CREATE_MEMORY_BUFFER(name,size) CREATE_MEMORY_BUFFER_SRAM(name,size)
408
#elif SSL_CUSTOM_MALLOC == 4
409
#define CREATE_MEMORY_ALLOCATOR(name,size) CREATE_MEMORY_ALLOCATOR_SDRAM(name,size)
410
#define CREATE_MEMORY_BUFFER(name,size) CREATE_MEMORY_BUFFER_SDRAM(name,size)
411
#endif
412
#endif
413
414
#if 0
415
/* Static memory requires fast math */
416
#define WOLFSSL_STATIC_MEMORY
417
418
/* Disable fallback malloc/free */
419
#define WOLFSSL_NO_MALLOC
420
#if 1
421
#define WOLFSSL_MALLOC_CHECK
/* trap malloc failure */
422
#endif
423
#endif
424
425
/* Memory callbacks */
426
#if 1
427
#undef USE_WOLFSSL_MEMORY
428
#define USE_WOLFSSL_MEMORY
429
430
/* Use this to measure / print heap usage */
431
#if 0
432
#define WOLFSSL_TRACK_MEMORY
433
#define WOLFSSL_DEBUG_MEMORY
434
#endif
435
#else
436
#ifndef WOLFSSL_STATIC_MEMORY
437
#define NO_WOLFSSL_MEMORY
438
/* Otherwise we will use stdlib malloc, free and realloc */
439
#endif
440
#endif
441
442
443
/* ------------------------------------------------------------------------- */
444
/* Port */
445
/* ------------------------------------------------------------------------- */
446
447
/* Override Current Time */
448
#if 1
449
/* Allows custom "custom_time()" function to be used for benchmark */
450
#define WOLFSSL_USER_CURRTIME
451
// #define WOLFSSL_GMTIME
452
#define USER_TICKS
453
#include <time.h>
454
extern
unsigned
long
my_time(time_t *timer);
455
#define XTIME my_time
456
#endif
457
458
459
/* ------------------------------------------------------------------------- */
460
/* RNG */
461
/* ------------------------------------------------------------------------- */
462
463
/* Choose RNG method */
464
#if 1
465
/* Custom Seed Source */
466
#if 1
467
/* Size of returned HW RNG value */
468
#define CUSTOM_RAND_TYPE unsigned int
469
extern
unsigned
int
my_rng_seed_gen(
void
);
470
#undef CUSTOM_RAND_GENERATE
471
#define CUSTOM_RAND_GENERATE my_rng_seed_gen
472
#endif
473
474
// NetBurner specific define for enabling hardware random number generation for M7
475
#define GATHER_RANDOM_USE_HW
476
477
/* Use built-in P-RNG (SHA256 based) with HW RNG */
478
/* P-RNG + HW RNG (P-RNG is ~8K) */
479
#undef HAVE_HASHDRBG
480
#define HAVE_HASHDRBG
481
#else
482
#undef WC_NO_HASHDRBG
483
#define WC_NO_HASHDRBG
484
485
/* Bypass P-RNG and use only HW RNG */
486
extern
int
my_rng_gen_block(
unsigned
char
* output,
unsigned
int
sz);
487
#undef CUSTOM_RAND_GENERATE_BLOCK
488
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
489
#endif
490
491
492
/* ------------------------------------------------------------------------- */
493
/* Custom Standard Lib */
494
/* ------------------------------------------------------------------------- */
495
/* Allows override of all standard library functions */
496
#undef STRING_USER
497
#if 0
498
#define STRING_USER
499
500
#include <string.h>
501
502
#define USE_WOLF_STRSEP
503
#define XSTRSEP(s1,d) wc_strsep((s1),(d))
504
505
#define USE_WOLF_STRTOK
506
#define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
507
508
#define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
509
510
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
511
#define XMEMSET(b,c,l) memset((b),(c),(l))
512
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
513
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
514
515
#define XSTRLEN(s1) strlen((s1))
516
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
517
#define XSTRSTR(s1,s2) strstr((s1),(s2))
518
519
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
520
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
521
#define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
522
523
#define XSNPRINTF snprintf
524
#endif
525
526
527
528
/* ------------------------------------------------------------------------- */
529
/* Enable Features */
530
/* ------------------------------------------------------------------------- */
531
532
#ifdef SSL_TLS_1_3_SUPPORT
// defined in predef.h
533
#define WOLFSSL_TLS13
534
#endif
535
#define WOLFSSL_OLD_PRIME_CHECK
/* Use faster DH prime checking */
536
#define HAVE_TLS_EXTENSIONS
537
#define HAVE_SUPPORTED_CURVES
538
#define WOLFSSL_BASE64_ENCODE
539
540
541
#define WOLFSSL_KEY_GEN
/* For RSA Key gen only */
542
#define KEEP_PEER_CERT
543
//#define HAVE_COMP_KEY
544
545
/* TLS Session Cache */
546
#if 1
547
#define SMALL_SESSION_CACHE
548
#define NO_SESSION_CACHE_REF
549
#else
550
#define NO_SESSION_CACHE
551
#endif
552
553
#define HAVE_ONE_TIME_AUTH
554
#define HAVE_SNI
555
#define HAVE_SESSION_TICKET
556
557
// Allows WolfSSL to malloc the tls 1.3 ticket nonce, instead of using a static buffer. This supports large ticket nonces
558
#define WOLFSSL_TICKET_NONCE_MALLOC
559
560
/* ------------------------------------------------------------------------- */
561
/* Disable Features */
562
/* ------------------------------------------------------------------------- */
563
//#define NO_WOLFSSL_SERVER
564
//#define NO_WOLFSSL_CLIENT
565
//#define NO_CRYPT_TEST
566
//#define NO_CRYPT_BENCHMARK
567
//#define WOLFCRYPT_ONLY
568
569
/* In-lining of misc.c functions */
570
/* If defined, must include wolfcrypt/src/misc.c in build */
571
/* Slower, but about 1k smaller */
572
//#define NO_INLINE
573
574
#define WOLFSSL_NO_SOCK
575
#define NO_WOLFSSL_DIR
576
577
#ifdef TARGET_EMBEDDED
578
#define NO_FILESYSTEM
579
#define NO_WRITEV
580
#define NO_MAIN_DRIVER
581
#define NO_DEV_RANDOM
582
#endif
583
584
#define NO_OLD_TLS
585
#define NO_PSK
586
587
#define NO_DSA
588
// #define NO_RC4
589
#define NO_MD4
590
#define NO_PWDBASED
591
//#define NO_CODING
592
//#define NO_ASN_TIME
593
//#define NO_CERTS
594
//#define NO_SIG_WRAPPER
595
596
#define NO_HC128
597
#define NO_RABBIT
598
599
#define WOLFSSL_IGNORE_FILE_WARN
600
601
#undef NO_TLS
602
603
// Settings made for compatibility
604
#define WOLFSSL_STATIC_RSA
// Needed to support TLS_RSA_WITH_AES_128_CBC_SHA
605
#define WOLFSSL_AES_128
// Needed to support TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256
606
#define WOLFSSL_AES_256
// Needed to support TLS_RSA_WITH_AES_256_CBC_SHA256
607
#define WOLFSSL_STATIC_DH
// Needed to support TLS_ECDH_ECDSA_WITH_RC4_128_SHA
608
609
#define WOLFSSL_CERT_REQ
610
#define WOLFSSL_CERT_GEN
611
#define WOLFSSL_ALT_NAMES
612
#define WOLFSSL_DER_TO_PEM
613
#define WOLFSSL_KEY_GEN
614
#define WOLFSSL_EITHER_SIDE
615
616
#define ENABLE_ECCKEY_CREATE
// Custom define, maybe should move to predef?
617
#define ENABLE_RSAKEY_CREATE
// Custom define, maybe should move to predef?
618
619
// For wolfSSH
620
//#undef WOLFSSH_SFTP
621
//#define WOLFSSH_SFTP
622
623
//#undef WOLFSSH_SCP
624
//#define WOLFSSH_SCP
625
626
#undef WOLFSSH_USER_IO
627
#define WOLFSSH_USER_IO
628
629
#ifdef __cplusplus
630
}
631
#endif
632
633
#endif
/* WOLFSSL_USER_SETTINGS_H */
libraries
include
crypto
platform
IC_D20
user_settings.h
Generated by
1.18.0