Skip to content

Commit 9ca379f

Browse files
Merge pull request wolfSSL#9719 from dgarske/usersettings_expand
Improve user_settings.h examples and add validation rules
2 parents a631611 + 7077a7b commit 9ca379f

26 files changed

+2155
-159
lines changed

.github/workflows/os-check.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,24 @@ jobs:
122122
matrix:
123123
os: [ ubuntu-24.04, macos-latest ]
124124
user-settings: [
125-
# Add new user_settings.h here
125+
# Add new user_settings.h here (alphabetical order)
126+
'examples/configs/user_settings_ca.h',
127+
'examples/configs/user_settings_dtls13.h',
128+
'examples/configs/user_settings_EBSnet.h',
126129
'examples/configs/user_settings_eccnonblock.h',
127130
'examples/configs/user_settings_min_ecc.h',
131+
'examples/configs/user_settings_openssl_compat.h',
132+
'examples/configs/user_settings_pkcs7.h',
133+
'examples/configs/user_settings_rsa_only.h',
134+
'examples/configs/user_settings_template.h',
135+
'examples/configs/user_settings_tls12.h',
136+
'examples/configs/user_settings_tls13.h',
128137
'examples/configs/user_settings_wolfboot_keytools.h',
129-
'examples/configs/user_settings_wolftpm.h',
130138
'examples/configs/user_settings_wolfssh.h',
131-
'examples/configs/user_settings_tls12.h',
139+
'examples/configs/user_settings_wolftpm.h',
140+
# Not included (require special setup):
141+
# - user_settings_pq.h: Requires --enable-experimental
142+
# - user_settings_baremetal.h: Requires static memory, custom platform
132143
]
133144
name: make user_setting.h (testwolfcrypt only)
134145
if: github.repository_owner == 'wolfssl'

.wolfssl_known_macro_extras

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ WOLFSSL_BIGINT_TYPES
695695
WOLFSSL_BIO_NO_FLOW_STATS
696696
WOLFSSL_BLAKE2B_INIT_EACH_FIELD
697697
WOLFSSL_BLAKE2S_INIT_EACH_FIELD
698-
WOLFSSL_BLIND_PRIVATE_KEY
699698
WOLFSSL_BYTESWAP32_ASM
700699
WOLFSSL_CAAM_BLACK_KEY_AESCCM
701700
WOLFSSL_CAAM_BLACK_KEY_SM
@@ -708,18 +707,15 @@ WOLFSSL_CLIENT_EXAMPLE
708707
WOLFSSL_CONTIKI
709708
WOLFSSL_CRL_ALLOW_MISSING_CDP
710709
WOLFSSL_DILITHIUM_ASSIGN_KEY
711-
WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM
712710
WOLFSSL_DILITHIUM_NO_ASN1
713711
WOLFSSL_DILITHIUM_NO_CHECK_KEY
714-
WOLFSSL_DILITHIUM_NO_LARGE_CODE
715712
WOLFSSL_DILITHIUM_NO_MAKE
716713
WOLFSSL_DILITHIUM_REVERSE_HASH_OID
717714
WOLFSSL_DILITHIUM_SIGN_CHECK_W0
718715
WOLFSSL_DILITHIUM_SIGN_CHECK_Y
719716
WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC
720717
WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A
721718
WOLFSSL_DILITHIUM_SMALL_MEM_POLY64
722-
WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM
723719
WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
724720
WOLFSSL_DTLS_DISALLOW_FUTURE
725721
WOLFSSL_DTLS_RECORDS_CAN_SPAN_DATAGRAMS
@@ -785,10 +781,7 @@ WOLFSSL_MAKE_SYSTEM_NAME_LINUX
785781
WOLFSSL_MAKE_SYSTEM_NAME_WSL
786782
WOLFSSL_MDK5
787783
WOLFSSL_MEM_FAIL_COUNT
788-
WOLFSSL_MLKEM_ENCAPSULATE_SMALL_MEM
789784
WOLFSSL_MLKEM_INVNTT_UNROLL
790-
WOLFSSL_MLKEM_MAKEKEY_SMALL_MEM
791-
WOLFSSL_MLKEM_NO_LARGE_CODE
792785
WOLFSSL_MLKEM_NO_MALLOC
793786
WOLFSSL_MLKEM_NTT_UNROLL
794787
WOLFSSL_MONT_RED_CT

examples/configs/README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ Example wolfSSL configuration file templates for use when autoconf is not availa
44

55
## Files
66

7-
* `user_settings_template.h`: Template that allows modular algorithm and feature selection using `#if 0` logic.
7+
* `user_settings_template.h`: Template that allows modular algorithm and feature selection using `#if 0`/`#if 1` gates.
88
* `user_settings_all.h`: This is wolfSSL with all features enabled. Equivalent to `./configure --enable-all`.
99
* `user_settings_arduino.h`: An example Arduino file. See also [wolfSSL/Arduino-wolfSSL](https://github.com/wolfSSL/Arduino-wolfSSL).
10-
*.`user_settings_EBSnet.h`: Example configuration file for use with EBSnet ports.
10+
* `user_settings_EBSnet.h`: Example configuration file for use with EBSnet ports.
11+
* `user_settings_eccnonblock.h`: Example for non-blocking ECC crypto only. See comment at top for test results.
12+
* `user_settings_espressif.h`: Example configuration for Espressif ESP32. See also [wolfSSL/IDE/Espressif](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif).
1113
* `user_settings_fipsv2.h`: The FIPS v2 (3389) 140-2 certificate build options.
1214
* `user_settings_fipsv5.h`: The FIPS v5 (ready) 140-3 build options. Equivalent to `./configure --enable-fips=v5-dev`.
13-
* `user_settings_min_ecc.h`: This is ECC and SHA-256 only. For ECC verify only add `BUILD_VERIFY_ONLY`.
14-
* `user_settings_platformio.h`: An example for PlatformIO library. See also [platformio/wolfssl](https://registry.platformio.org/libraries/wolfssl/wolfssl)
15+
* `user_settings_min_ecc.h`: Minimal ECC and SHA-256 only (no TLS). For ECC verify only add `NO_ECC_SIGN`.
16+
* `user_settings_platformio.h`: An example for PlatformIO library. See also [platformio/wolfssl](https://registry.platformio.org/libraries/wolfssl/wolfssl).
1517
* `user_settings_stm32.h`: Example configuration file generated from the wolfSSL STM32 Cube pack.
16-
* `user_settings_tls12`: Example for TLS v1.2 client only, ECC only, AES GCM only, SHA2-256 only.
17-
* `user_settings_wolfboot_keytools.h`: This from wolfBoot tools/keytools and is ECC, RSA, ED25519 and ChaCha20.
18+
* `user_settings_tls12.h`: Example for TLS v1.2 client only, ECC only, AES-GCM only, SHA2-256 only.
19+
* `user_settings_tls13.h`: TLS 1.3 only configuration (no TLS 1.2). Modern cipher suites with X25519/X448 key exchange.
20+
* `user_settings_dtls13.h`: DTLS 1.3 for IoT and embedded. Includes connection ID support and smaller MTU options.
21+
* `user_settings_pq.h`: Post-quantum TLS with ML-KEM (Kyber) key exchange and ML-DSA (Dilithium) certificates.
22+
* `user_settings_openssl_compat.h`: OpenSSL compatibility layer for drop-in replacement. Enables OPENSSL_ALL and related APIs.
23+
* `user_settings_baremetal.h`: Bare metal configuration. No filesystem, static memory only, minimal footprint.
24+
* `user_settings_rsa_only.h`: RSA-only configuration (no ECC). For legacy systems requiring RSA cipher suites.
25+
* `user_settings_pkcs7.h`: PKCS#7/CMS configuration for signing and encryption. S/MIME, firmware signing.
26+
* `user_settings_ca.h`: Certificate Authority / PKI operations. Certificate generation, signing, CRL, OCSP.
27+
* `user_settings_wolfboot_keytools.h`: wolfBoot key generation and signing tool. Supports ECC, RSA, ED25519, ED448, and post-quantum (ML-DSA/Dilithium, LMS, XMSS).
1828
* `user_settings_wolfssh.h`: Minimum options for building wolfSSH. See comment at top for ./configure used to generate.
1929
* `user_settings_wolftpm.h`: Minimum options for building wolfTPM. See comment at top for ./configure used to generate.
2030

examples/configs/include.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@
44
EXTRA_DIST += examples/configs/README.md
55
EXTRA_DIST += examples/configs/user_settings_all.h
66
EXTRA_DIST += examples/configs/user_settings_arduino.h
7+
EXTRA_DIST += examples/configs/user_settings_baremetal.h
8+
EXTRA_DIST += examples/configs/user_settings_ca.h
9+
EXTRA_DIST += examples/configs/user_settings_dtls13.h
710
EXTRA_DIST += examples/configs/user_settings_EBSnet.h
811
EXTRA_DIST += examples/configs/user_settings_eccnonblock.h
912
EXTRA_DIST += examples/configs/user_settings_espressif.h
1013
EXTRA_DIST += examples/configs/user_settings_fipsv2.h
1114
EXTRA_DIST += examples/configs/user_settings_fipsv5.h
1215
EXTRA_DIST += examples/configs/user_settings_min_ecc.h
16+
EXTRA_DIST += examples/configs/user_settings_openssl_compat.h
17+
EXTRA_DIST += examples/configs/user_settings_pkcs7.h
1318
EXTRA_DIST += examples/configs/user_settings_platformio.h
19+
EXTRA_DIST += examples/configs/user_settings_pq.h
20+
EXTRA_DIST += examples/configs/user_settings_rsa_only.h
1421
EXTRA_DIST += examples/configs/user_settings_stm32.h
1522
EXTRA_DIST += examples/configs/user_settings_template.h
1623
EXTRA_DIST += examples/configs/user_settings_tls12.h
24+
EXTRA_DIST += examples/configs/user_settings_tls13.h
1725
EXTRA_DIST += examples/configs/user_settings_wolfboot_keytools.h
1826
EXTRA_DIST += examples/configs/user_settings_wolfssh.h
1927
EXTRA_DIST += examples/configs/user_settings_wolftpm.h

examples/configs/user_settings_EBSnet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extern "C" {
4747
#define NO_MD4
4848
#define NO_MD5
4949
#define NO_DES3
50+
#define NO_DES3_TLS_SUITES
51+
#define NO_OLD_TLS
5052

5153
#ifdef __cplusplus
5254
}

examples/configs/user_settings_all.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ extern "C" {
210210
#define WOLFSSL_SHAKE256
211211
#define WOLFSSL_SHA3
212212
#define WOLFSSL_HASH_FLAGS /* enable hash flag API's */
213-
#define WOLFSSL_SHAKE256
214213

215214
/* Additional Algorithms */
216215
#define HAVE_HASHDRBG
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
/* user_settings_baremetal.h
2+
*
3+
* Copyright (C) 2006-2025 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 3 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+
/* Bare metal configuration for systems without an OS.
23+
* No filesystem, no malloc, static memory, minimal footprint.
24+
* Suitable for deeply embedded systems and bootloaders.
25+
*
26+
* Build and test:
27+
* cp ./examples/configs/user_settings_baremetal.h user_settings.h
28+
* ./configure --enable-usersettings --disable-examples
29+
* make
30+
* ./wolfcrypt/test/testwolfcrypt
31+
*/
32+
33+
#ifndef WOLFSSL_USER_SETTINGS_H
34+
#define WOLFSSL_USER_SETTINGS_H
35+
36+
#ifdef __cplusplus
37+
extern "C" {
38+
#endif
39+
40+
/* ------------------------------------------------- */
41+
/* Platform - Bare Metal */
42+
/* ------------------------------------------------- */
43+
#define SINGLE_THREADED
44+
#define NO_FILESYSTEM
45+
#define NO_WRITEV
46+
#define WOLFSSL_NO_SOCK
47+
#define WOLFSSL_IGNORE_FILE_WARN
48+
#define WOLFSSL_GENERAL_ALIGNMENT 4
49+
#define SIZEOF_LONG_LONG 8
50+
51+
/* TLS transport requires setting IO callbacks */
52+
#define WOLFSSL_USER_IO
53+
54+
/* ------------------------------------------------- */
55+
/* Memory */
56+
/* ------------------------------------------------- */
57+
#if 1 /* stack memory */
58+
59+
#elif 1 /* small stack */
60+
/* Small stack - allocate large variables from static pool */
61+
#define WOLFSSL_SMALL_STACK
62+
#else /* static memory */
63+
#define WOLFSSL_STATIC_MEMORY
64+
#define WOLFSSL_NO_MALLOC
65+
#define WOLFSSL_SP_NO_MALLOC
66+
#define WOLFSSL_MALLOC_CHECK
67+
#define NO_WOLFSSL_MEMORY
68+
#endif
69+
70+
/* ------------------------------------------------- */
71+
/* Math - Single Precision (smallest) */
72+
/* ------------------------------------------------- */
73+
#define WOLFSSL_SP_MATH
74+
#define WOLFSSL_SP_SMALL
75+
#define TFM_TIMING_RESISTANT
76+
77+
/* ------------------------------------------------- */
78+
/* TLS (optional - disable for crypto-only) */
79+
/* ------------------------------------------------- */
80+
#if 0 /* TLS support */
81+
#define WOLFSSL_TLS13
82+
#define WOLFSSL_NO_TLS12
83+
#define NO_OLD_TLS
84+
#define HAVE_TLS_EXTENSIONS
85+
#define HAVE_SUPPORTED_CURVES
86+
#define HAVE_HKDF
87+
#else
88+
#define WOLFCRYPT_ONLY
89+
#endif
90+
91+
/* ------------------------------------------------- */
92+
/* ECC (smallest asymmetric option) */
93+
/* ------------------------------------------------- */
94+
#if 1 /* ECC support */
95+
#define HAVE_ECC
96+
#define WOLFSSL_HAVE_SP_ECC
97+
98+
#define ECC_USER_CURVES /* P-256 only */
99+
#undef NO_ECC256
100+
#define ECC_TIMING_RESISTANT
101+
/* Disable for smaller size */
102+
#if 0 /* ECC Shamir (faster, more code) */
103+
#define ECC_SHAMIR
104+
#endif
105+
#endif
106+
107+
/* ECC Feature Reduction */
108+
#if 0 /* Verify only (no signing/keygen) */
109+
#define NO_ECC_SIGN
110+
#define NO_ECC_DHE
111+
#define NO_ECC_KEY_EXPORT
112+
#endif
113+
114+
/* ------------------------------------------------- */
115+
/* RSA (disable for smallest size) */
116+
/* ------------------------------------------------- */
117+
#if 0 /* RSA support */
118+
#undef NO_RSA
119+
#define WOLFSSL_HAVE_SP_RSA
120+
#define WC_RSA_BLINDING
121+
#define RSA_LOW_MEM
122+
#if 0 /* Verify only */
123+
#define WOLFSSL_RSA_PUBLIC_ONLY
124+
#define WOLFSSL_RSA_VERIFY_INLINE
125+
#define NO_CHECK_PRIVATE_KEY
126+
#endif
127+
#else
128+
#define NO_RSA
129+
#endif
130+
131+
/* ------------------------------------------------- */
132+
/* Symmetric Ciphers */
133+
/* ------------------------------------------------- */
134+
#if 1 /* AES */
135+
#define HAVE_AESGCM
136+
#define GCM_SMALL
137+
#define WOLFSSL_AES_SMALL_TABLES
138+
#define WOLFSSL_AES_NO_UNROLL
139+
#define NO_AES_192
140+
#define NO_AES_256
141+
#if 0 /* AES-CBC */
142+
#undef NO_AES_CBC
143+
#else
144+
#define NO_AES_CBC
145+
#endif
146+
#else
147+
#define NO_AES
148+
#endif
149+
150+
#if 0 /* ChaCha20-Poly1305 */
151+
#define HAVE_CHACHA
152+
#define HAVE_POLY1305
153+
#endif
154+
155+
/* ------------------------------------------------- */
156+
/* Hashing */
157+
/* ------------------------------------------------- */
158+
/* SHA-256 only (required) */
159+
#define USE_SLOW_SHA256
160+
161+
#if 0 /* SHA-1 (legacy) */
162+
#undef NO_SHA
163+
#else
164+
#define NO_SHA
165+
#endif
166+
167+
/* ------------------------------------------------- */
168+
/* RNG */
169+
/* ------------------------------------------------- */
170+
#if 1 /* Hash-based DRBG */
171+
#define HAVE_HASHDRBG
172+
#else
173+
/* Use hardware RNG directly */
174+
#define WC_NO_HASHDRBG
175+
extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
176+
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
177+
#endif
178+
179+
/* ------------------------------------------------- */
180+
/* ASN / Certificates */
181+
/* ------------------------------------------------- */
182+
#define WOLFSSL_ASN_TEMPLATE
183+
184+
#if 0 /* Disable certificates for smallest size */
185+
#define NO_ASN
186+
#define NO_CERTS
187+
#define NO_CODING
188+
#endif
189+
190+
/* ------------------------------------------------- */
191+
/* Disabled Algorithms */
192+
/* ------------------------------------------------- */
193+
#define NO_DH
194+
#define NO_DSA
195+
#define NO_RC4
196+
#define NO_MD4
197+
#define NO_MD5
198+
#define NO_DES3
199+
#define NO_DES3_TLS_SUITES
200+
#define NO_PSK
201+
#define NO_PWDBASED
202+
#define NO_PKCS8
203+
#define NO_PKCS12
204+
205+
/* ------------------------------------------------- */
206+
/* Disabled Features */
207+
/* ------------------------------------------------- */
208+
#define NO_SIG_WRAPPER
209+
#define NO_SESSION_CACHE
210+
#define NO_ERROR_STRINGS
211+
#define NO_OLD_RNGNAME
212+
#define NO_WOLFSSL_DIR
213+
#define BENCH_EMBEDDED
214+
215+
/* ------------------------------------------------- */
216+
/* Custom Time (bare metal has no RTC typically) */
217+
/* ------------------------------------------------- */
218+
#if 1 /* Custom time function */
219+
#define NO_ASN_TIME
220+
/* Or provide custom time:
221+
* #define USER_TIME
222+
* extern unsigned long my_time(unsigned long* timer);
223+
* #define XTIME my_time
224+
*/
225+
#endif
226+
227+
#ifdef __cplusplus
228+
}
229+
#endif
230+
231+
#endif /* WOLFSSL_USER_SETTINGS_H */

0 commit comments

Comments
 (0)