-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathcascade.h
More file actions
216 lines (199 loc) · 7.93 KB
/
cascade.h
File metadata and controls
216 lines (199 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/* user_settings/cascade.h
*
* Lift Make-side feature implications into preprocessor cascades, and
* declare WOLFBOOT_NEEDS_* positive intent markers used by the rest
* of the user_settings/ fragments and reconciled in finalize.h.
*
* Idempotent: every #define is #ifndef-guarded, so it's a no-op when
* options.mk has already emitted the same -D flag.
*
*
* Copyright (C) 2026 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef _WOLFBOOT_USER_SETTINGS_CASCADE_H_
#define _WOLFBOOT_USER_SETTINGS_CASCADE_H_
/* ------------------------------------------------------------------
* Feature-flag cascades
* ------------------------------------------------------------------ */
/* Any feature that requires a hardware TPM 2.0 implies WOLFBOOT_TPM.
* Mirrors options.mk:34-92 where the same Make variables force WOLFTPM:=1. */
#if defined(WOLFBOOT_TPM_VERIFY) || \
defined(WOLFBOOT_MEASURED_BOOT) || \
defined(WOLFBOOT_TPM_KEYSTORE) || \
defined(WOLFBOOT_TPM_SEAL)
# ifndef WOLFBOOT_TPM
# define WOLFBOOT_TPM
# endif
#endif
/* TPM keystore and seal both require TPM session parameter encryption. */
#if defined(WOLFBOOT_TPM_KEYSTORE) || defined(WOLFBOOT_TPM_SEAL)
# ifndef WOLFBOOT_TPM_PARMENC
# define WOLFBOOT_TPM_PARMENC
# endif
#endif
/* Any RSA SIGN flag (or WOLFCRYPT_SECURE_MODE without PKCS11_SMALL) means
* the build links wolfCrypt's RSA code. sign_rsa.h handles the actual
* configuration; the marker is set here so finalize.h can see it ahead
* of finalize-time and skip NO_ASN. */
#if defined(WOLFBOOT_SIGN_RSA2048) || \
defined(WOLFBOOT_SIGN_RSA3072) || \
defined(WOLFBOOT_SIGN_RSA4096) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSA3072) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSA4096) || \
defined(WOLFBOOT_SIGN_RSAPSS2048) || \
defined(WOLFBOOT_SIGN_RSAPSS3072) || \
defined(WOLFBOOT_SIGN_RSAPSS4096) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096) || \
(defined(WOLFCRYPT_SECURE_MODE) && !defined(PKCS11_SMALL))
# ifndef WOLFBOOT_NEEDS_RSA
# define WOLFBOOT_NEEDS_RSA
# endif
#endif
/* ------------------------------------------------------------------
* WOLFBOOT_NEEDS_* declarations
* ------------------------------------------------------------------
* Positive intent markers. user_settings/finalize.h tests them and
* applies the corresponding wolfCrypt negative flag (NO_*, WC_NO_*) to
* builds that did NOT opt in. Fragments may also set additional markers
* from their own headers. */
/* NEEDS_RNG: any feature that uses wolfCrypt's RNG.
* Driven by: TPM parm-enc, secure-mode (TZ-PSA / TZ-FWTPM), test/bench,
* wolfHSM server, and wolfHSM client + ML-DSA. */
#if defined(WOLFBOOT_TPM_PARMENC) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) || \
(defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) && \
defined(WOLFBOOT_SIGN_ML_DSA))
# ifndef WOLFBOOT_NEEDS_RNG
# define WOLFBOOT_NEEDS_RNG
# endif
#endif
/* NEEDS_HASHDRBG: features that use wolfCrypt's HASHDRBG specifically.
* Note: TEST/BENCH non-LPC55S69 builds use a custom RNG and do NOT
* declare this marker; their explicit `#define WC_NO_HASHDRBG` lives
* in test_bench.h. */
#if defined(WOLFBOOT_TPM_PARMENC) || \
defined(WOLFCRYPT_SECURE_MODE) || \
((defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)) && \
(defined(WOLFSSL_NXP_LPC55S69_WITH_HWACCEL) || \
defined(WOLFSSL_NXP_LPC55S69_NO_HWACCEL)))
# ifndef WOLFBOOT_NEEDS_HASHDRBG
# define WOLFBOOT_NEEDS_HASHDRBG
# endif
#endif
/* NEEDS_AES_CBC: features that use AES-CBC (entropy-using paths). */
#if defined(WOLFBOOT_TPM_PARMENC) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK)
# ifndef WOLFBOOT_NEEDS_AES_CBC
# define WOLFBOOT_NEEDS_AES_CBC
# endif
#endif
/* NEEDS_AES: features that use AES core. */
#if defined(ENCRYPT_WITH_AES128) || \
defined(ENCRYPT_WITH_AES256) || \
defined(WOLFBOOT_TPM_PARMENC) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(SECURE_PKCS11) || \
defined(WOLFCRYPT_TZ_PSA) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK)
# ifndef WOLFBOOT_NEEDS_AES
# define WOLFBOOT_NEEDS_AES
# endif
#endif
/* NEEDS_HMAC: features that use HMAC. */
#if defined(WOLFBOOT_TPM) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK)
# ifndef WOLFBOOT_NEEDS_HMAC
# define WOLFBOOT_NEEDS_HMAC
# endif
#endif
/* NEEDS_DEV_RANDOM: features that may want OS /dev/random as entropy. */
#if defined(WOLFBOOT_TPM) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK)
# ifndef WOLFBOOT_NEEDS_DEV_RANDOM
# define WOLFBOOT_NEEDS_DEV_RANDOM
# endif
#endif
/* NEEDS_ECC_KEY_EXPORT: features that need to export ECC keys. */
#if defined(WOLFBOOT_TPM) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
# ifndef WOLFBOOT_NEEDS_ECC_KEY_EXPORT
# define WOLFBOOT_NEEDS_ECC_KEY_EXPORT
# endif
#endif
/* NEEDS_ASN: features that need ASN.1 parsing. NEEDS_RSA also implies
* this (RSA always parses ASN.1). */
#if defined(WOLFBOOT_NEEDS_RSA) || \
defined(WOLFBOOT_TPM) || \
defined(WOLFCRYPT_SECURE_MODE) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
# ifndef WOLFBOOT_NEEDS_ASN
# define WOLFBOOT_NEEDS_ASN
# endif
#endif
/* NEEDS_BASE64: features that use base64 encoding. */
#if (defined(WOLFBOOT_TPM_SEAL) && defined(WOLFBOOT_ATA_DISK_LOCK)) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
# ifndef WOLFBOOT_NEEDS_BASE64
# define WOLFBOOT_NEEDS_BASE64
# endif
#endif
/* NEEDS_CMAC and NEEDS_KDF: TZ_PSA and TZ_FWTPM need both. */
#if defined(WOLFCRYPT_TZ_PSA) || defined(WOLFBOOT_TZ_FWTPM)
# ifndef WOLFBOOT_NEEDS_CMAC
# define WOLFBOOT_NEEDS_CMAC
# endif
# ifndef WOLFBOOT_NEEDS_KDF
# define WOLFBOOT_NEEDS_KDF
# endif
#endif
/* NEEDS_MALLOC: features whose code-paths use heap allocation.
* SECURE_PKCS11, WOLFCRYPT_TZ_PSA, the wolfHSM server, and the
* test/bench harnesses all expect a working malloc. Default builds
* (no marker) get NO_WOLFSSL_MEMORY + WOLFSSL_NO_MALLOC instead. */
#if defined(SECURE_PKCS11) || \
defined(WOLFCRYPT_TZ_PSA) || \
defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) || \
defined(WOLFCRYPT_TEST) || \
defined(WOLFCRYPT_BENCHMARK)
# ifndef WOLFBOOT_NEEDS_MALLOC
# define WOLFBOOT_NEEDS_MALLOC
# endif
#endif
#endif /* _WOLFBOOT_USER_SETTINGS_CASCADE_H_ */