Skip to content

Commit abc6594

Browse files
committed
maybe revert - assert wolfcrypt invariants arent improperly turned on
1 parent 149f10e commit abc6594

2 files changed

Lines changed: 92 additions & 4 deletions

File tree

docs/wolfssl-config.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,21 @@ Recall the polarity rules from [Section 3.1](#31-why-it-exists):
836836
vocabulary.
837837

838838
The tell that you're in this case: you `#define HAVE_X` in your
839-
fragment, build, and find that the wolfCrypt feature is still
840-
stripped from the binary. Look at `finalize.h` — there will be a
841-
`#define NO_X` (or `#define WC_NO_X`) in the always-on disables block.
839+
fragment, build, and either (a) the build fails with the assertion
840+
841+
```
842+
error: "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
843+
```
844+
845+
raised by the `#error` directive in `finalize.h`'s always-on block, or
846+
(b) the build succeeds but the wolfCrypt feature is still stripped
847+
from the binary because `finalize.h` later defines `NO_X` and that
848+
wins. Most always-on disables in `finalize.h` are guarded by an
849+
assertion that catches the polarity-mismatch at compile time and
850+
points the developer at this section. A handful of disables (the ones
851+
without a canonical positive form, like `NO_ASN_TIME`, or the
852+
environment ones, like `NO_FILESYSTEM`) have no assertion; for those
853+
you'll only see case (b).
842854

843855
#### Worked example: adding `WOLFBOOT_NEEDS_DH`
844856

include/user_settings/finalize.h

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,85 @@
9797

9898
/* ------------------------------------------------------------------
9999
* Always-on disables (no fragment opts out today).
100-
* ------------------------------------------------------------------ */
100+
* ------------------------------------------------------------------
101+
* Each entry asserts that no fragment has opted in via the matching
102+
* positive flag, then defines the disable. If one of these assertions
103+
* fires, the right fix is to introduce a WOLFBOOT_NEEDS_* marker and
104+
* gate the disable on its absence (see docs/wolfssl-config.md, Section
105+
* 8 Step 5).
106+
*
107+
* Entries without an assertion either have no canonical positive form
108+
* (NO_ASN_TIME, NO_SIG_WRAPPER) or describe wolfBoot's environment
109+
* rather than a wolfCrypt feature a fragment would plausibly want to
110+
* enable (NO_WRITEV, NO_MAIN_DRIVER, NO_WOLFSSL_DIR, WOLFSSL_NO_SOCK,
111+
* WOLFSSL_IGNORE_FILE_WARN, NO_ERROR_STRINGS, NO_OLD_RNGNAME). */
112+
113+
#if defined(HAVE_DH)
114+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
115+
#endif
101116
#define NO_DH
117+
118+
#if defined(WOLFSSL_PEM)
119+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
120+
#endif
102121
#define WOLFSSL_NO_PEM
122+
103123
#define NO_ASN_TIME
124+
125+
#if defined(HAVE_RC4)
126+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
127+
#endif
104128
#define NO_RC4
129+
130+
#if defined(WOLFSSL_SHA1)
131+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
132+
#endif
105133
#define NO_SHA
134+
135+
#if defined(HAVE_DSA)
136+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
137+
#endif
106138
#define NO_DSA
139+
140+
#if defined(WOLFSSL_MD4)
141+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
142+
#endif
107143
#define NO_MD4
144+
145+
#if defined(HAVE_RABBIT)
146+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
147+
#endif
108148
#define NO_RABBIT
149+
150+
#if defined(WOLFSSL_MD5)
151+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
152+
#endif
109153
#define NO_MD5
154+
110155
#define NO_SIG_WRAPPER
156+
157+
#if defined(WOLFSSL_CERT_GEN)
158+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
159+
#endif
111160
#define NO_CERT
161+
162+
#if defined(HAVE_SESSION_CACHE)
163+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
164+
#endif
112165
#define NO_SESSION_CACHE
166+
167+
#if defined(HAVE_HC128)
168+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
169+
#endif
113170
#define NO_HC128
171+
172+
#if defined(HAVE_DES3)
173+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
174+
#endif
114175
#ifndef NO_DES3
115176
# define NO_DES3
116177
#endif
178+
117179
#define NO_WRITEV
118180
#ifndef WOLFBOOT_PARTITION_FILENAME
119181
# define NO_FILESYSTEM
@@ -124,8 +186,22 @@
124186
#define WOLFSSL_NO_SOCK
125187
#define WOLFSSL_IGNORE_FILE_WARN
126188
#define NO_ERROR_STRINGS
189+
190+
#if defined(HAVE_PKCS12)
191+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
192+
#endif
127193
#define NO_PKCS12
194+
195+
/* NO_PKCS8: no assertion. encrypt.h's SECURE_PKCS11 path defines
196+
* HAVE_PKCS8 vestigially; wolfSSL gates PKCS8 on `#ifndef NO_PKCS8`,
197+
* so the HAVE_PKCS8 define is a no-op. Until that vestigial define is
198+
* cleaned up, we cannot assert here without false-positive on the
199+
* SECURE_PKCS11 build. */
128200
#define NO_PKCS8
201+
202+
#if defined(WOLFSSL_CHECK_PRIVATE_KEY)
203+
# error "user_settings: NEEDS_* marker required; see docs/wolfssl-config.md"
204+
#endif
129205
#define NO_CHECK_PRIVATE_KEY
130206

131207
/* BENCH_EMBEDDED is the default outside explicit test/benchmark mode. */

0 commit comments

Comments
 (0)