|
1 | 1 | /* user_settings/cascade.h |
2 | 2 | * |
3 | | - * Lift Make-side feature implications into preprocessor cascades so an |
4 | | - * IDE/CMake-only build (which sets only the high-level WOLFBOOT_* flags) |
5 | | - * sees the same derived flags that options.mk would set. |
| 3 | + * Lift Make-side feature implications into preprocessor cascades, and |
| 4 | + * declare WOLFBOOT_NEEDS_* positive intent markers used by the rest |
| 5 | + * of the user_settings/ fragments and reconciled in finalize.h. |
6 | 6 | * |
7 | 7 | * Idempotent: every #define is #ifndef-guarded, so it's a no-op when |
8 | 8 | * options.mk has already emitted the same -D flag. |
|
29 | 29 | #ifndef _WOLFBOOT_USER_SETTINGS_CASCADE_H_ |
30 | 30 | #define _WOLFBOOT_USER_SETTINGS_CASCADE_H_ |
31 | 31 |
|
| 32 | +/* ------------------------------------------------------------------ |
| 33 | + * Feature-flag cascades |
| 34 | + * ------------------------------------------------------------------ */ |
| 35 | + |
32 | 36 | /* Any feature that requires a hardware TPM 2.0 implies WOLFBOOT_TPM. |
33 | 37 | * Mirrors options.mk:34-92 where the same Make variables force WOLFTPM:=1. */ |
34 | 38 | #if defined(WOLFBOOT_TPM_VERIFY) || \ |
|
40 | 44 | # endif |
41 | 45 | #endif |
42 | 46 |
|
43 | | -/* WOLFBOOT_NEEDS_* declarations -- positive intent markers reconciled by |
44 | | - * user_settings/finalize.h. Fragments may also set these from their own |
45 | | - * headers; cascade.h handles the cases that today live as #undef blocks |
46 | | - * scattered through user_settings.h. */ |
| 47 | +/* TPM keystore and seal both require TPM session parameter encryption. */ |
| 48 | +#if defined(WOLFBOOT_TPM_KEYSTORE) || defined(WOLFBOOT_TPM_SEAL) |
| 49 | +# ifndef WOLFBOOT_TPM_PARMENC |
| 50 | +# define WOLFBOOT_TPM_PARMENC |
| 51 | +# endif |
| 52 | +#endif |
| 53 | + |
| 54 | +/* Any RSA SIGN flag (or WOLFCRYPT_SECURE_MODE without PKCS11_SMALL) means |
| 55 | + * the build links wolfCrypt's RSA code. sign_rsa.h handles the actual |
| 56 | + * configuration; the marker is set here so finalize.h can see it ahead |
| 57 | + * of finalize-time and skip NO_ASN. */ |
| 58 | +#if defined(WOLFBOOT_SIGN_RSA2048) || \ |
| 59 | + defined(WOLFBOOT_SIGN_RSA3072) || \ |
| 60 | + defined(WOLFBOOT_SIGN_RSA4096) || \ |
| 61 | + defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \ |
| 62 | + defined(WOLFBOOT_SIGN_SECONDARY_RSA3072) || \ |
| 63 | + defined(WOLFBOOT_SIGN_SECONDARY_RSA4096) || \ |
| 64 | + defined(WOLFBOOT_SIGN_RSAPSS2048) || \ |
| 65 | + defined(WOLFBOOT_SIGN_RSAPSS3072) || \ |
| 66 | + defined(WOLFBOOT_SIGN_RSAPSS4096) || \ |
| 67 | + defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048) || \ |
| 68 | + defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \ |
| 69 | + defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096) || \ |
| 70 | + (defined(WOLFCRYPT_SECURE_MODE) && !defined(PKCS11_SMALL)) |
| 71 | +# ifndef WOLFBOOT_NEEDS_RSA |
| 72 | +# define WOLFBOOT_NEEDS_RSA |
| 73 | +# endif |
| 74 | +#endif |
| 75 | + |
| 76 | +/* ------------------------------------------------------------------ |
| 77 | + * WOLFBOOT_NEEDS_* declarations |
| 78 | + * ------------------------------------------------------------------ |
| 79 | + * Positive intent markers. user_settings/finalize.h tests them and |
| 80 | + * applies the corresponding wolfCrypt negative flag (NO_*, WC_NO_*) to |
| 81 | + * builds that did NOT opt in. Fragments may also set additional markers |
| 82 | + * from their own headers. */ |
| 83 | + |
| 84 | +/* NEEDS_RNG: any feature that uses wolfCrypt's RNG. |
| 85 | + * Driven by: TPM parm-enc, secure-mode (TZ-PSA / TZ-FWTPM), test/bench, |
| 86 | + * wolfHSM server, and wolfHSM client + ML-DSA. */ |
| 87 | +#if defined(WOLFBOOT_TPM_PARMENC) || \ |
| 88 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 89 | + defined(WOLFCRYPT_TEST) || \ |
| 90 | + defined(WOLFCRYPT_BENCHMARK) || \ |
| 91 | + defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) || \ |
| 92 | + (defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) && \ |
| 93 | + defined(WOLFBOOT_SIGN_ML_DSA)) |
| 94 | +# ifndef WOLFBOOT_NEEDS_RNG |
| 95 | +# define WOLFBOOT_NEEDS_RNG |
| 96 | +# endif |
| 97 | +#endif |
| 98 | + |
| 99 | +/* NEEDS_HASHDRBG: features that use wolfCrypt's HASHDRBG specifically. |
| 100 | + * Note: TEST/BENCH non-LPC55S69 builds use a custom RNG and do NOT |
| 101 | + * declare this marker; their explicit `#define WC_NO_HASHDRBG` lives |
| 102 | + * in test_bench.h. */ |
| 103 | +#if defined(WOLFBOOT_TPM_PARMENC) || \ |
| 104 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 105 | + ((defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)) && \ |
| 106 | + (defined(WOLFSSL_NXP_LPC55S69_WITH_HWACCEL) || \ |
| 107 | + defined(WOLFSSL_NXP_LPC55S69_NO_HWACCEL))) |
| 108 | +# ifndef WOLFBOOT_NEEDS_HASHDRBG |
| 109 | +# define WOLFBOOT_NEEDS_HASHDRBG |
| 110 | +# endif |
| 111 | +#endif |
| 112 | + |
| 113 | +/* NEEDS_AES_CBC: features that use AES-CBC (entropy-using paths). */ |
| 114 | +#if defined(WOLFBOOT_TPM_PARMENC) || \ |
| 115 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 116 | + defined(WOLFCRYPT_TEST) || \ |
| 117 | + defined(WOLFCRYPT_BENCHMARK) |
| 118 | +# ifndef WOLFBOOT_NEEDS_AES_CBC |
| 119 | +# define WOLFBOOT_NEEDS_AES_CBC |
| 120 | +# endif |
| 121 | +#endif |
| 122 | + |
| 123 | +/* NEEDS_AES: features that use AES core. */ |
| 124 | +#if defined(ENCRYPT_WITH_AES128) || \ |
| 125 | + defined(ENCRYPT_WITH_AES256) || \ |
| 126 | + defined(WOLFBOOT_TPM_PARMENC) || \ |
| 127 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 128 | + defined(SECURE_PKCS11) || \ |
| 129 | + defined(WOLFCRYPT_TZ_PSA) || \ |
| 130 | + defined(WOLFCRYPT_TEST) || \ |
| 131 | + defined(WOLFCRYPT_BENCHMARK) |
| 132 | +# ifndef WOLFBOOT_NEEDS_AES |
| 133 | +# define WOLFBOOT_NEEDS_AES |
| 134 | +# endif |
| 135 | +#endif |
47 | 136 |
|
48 | | -/* WOLFCRYPT_TZ_PSA and WOLFBOOT_TZ_FWTPM both keep CMAC and KDF enabled |
49 | | - * (today by `#undef NO_CMAC` / `#undef NO_KDF` after the always-on block). |
50 | | - * Lift those to positive intent so finalize.h can simply skip the |
51 | | - * `#define NO_CMAC` / `#define NO_KDF`. */ |
| 137 | +/* NEEDS_HMAC: features that use HMAC. */ |
| 138 | +#if defined(WOLFBOOT_TPM) || \ |
| 139 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 140 | + defined(WOLFCRYPT_TEST) || \ |
| 141 | + defined(WOLFCRYPT_BENCHMARK) |
| 142 | +# ifndef WOLFBOOT_NEEDS_HMAC |
| 143 | +# define WOLFBOOT_NEEDS_HMAC |
| 144 | +# endif |
| 145 | +#endif |
| 146 | + |
| 147 | +/* NEEDS_DEV_RANDOM: features that may want OS /dev/random as entropy. */ |
| 148 | +#if defined(WOLFBOOT_TPM) || \ |
| 149 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 150 | + defined(WOLFCRYPT_TEST) || \ |
| 151 | + defined(WOLFCRYPT_BENCHMARK) |
| 152 | +# ifndef WOLFBOOT_NEEDS_DEV_RANDOM |
| 153 | +# define WOLFBOOT_NEEDS_DEV_RANDOM |
| 154 | +# endif |
| 155 | +#endif |
| 156 | + |
| 157 | +/* NEEDS_ECC_KEY_EXPORT: features that need to export ECC keys. */ |
| 158 | +#if defined(WOLFBOOT_TPM) || \ |
| 159 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 160 | + defined(WOLFCRYPT_TEST) || \ |
| 161 | + defined(WOLFCRYPT_BENCHMARK) || \ |
| 162 | + defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \ |
| 163 | + defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) |
| 164 | +# ifndef WOLFBOOT_NEEDS_ECC_KEY_EXPORT |
| 165 | +# define WOLFBOOT_NEEDS_ECC_KEY_EXPORT |
| 166 | +# endif |
| 167 | +#endif |
| 168 | + |
| 169 | +/* NEEDS_ASN: features that need ASN.1 parsing. NEEDS_RSA also implies |
| 170 | + * this (RSA always parses ASN.1). */ |
| 171 | +#if defined(WOLFBOOT_NEEDS_RSA) || \ |
| 172 | + defined(WOLFBOOT_TPM) || \ |
| 173 | + defined(WOLFCRYPT_SECURE_MODE) || \ |
| 174 | + defined(WOLFCRYPT_TEST) || \ |
| 175 | + defined(WOLFCRYPT_BENCHMARK) || \ |
| 176 | + defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \ |
| 177 | + defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) |
| 178 | +# ifndef WOLFBOOT_NEEDS_ASN |
| 179 | +# define WOLFBOOT_NEEDS_ASN |
| 180 | +# endif |
| 181 | +#endif |
| 182 | + |
| 183 | +/* NEEDS_BASE64: features that use base64 encoding. */ |
| 184 | +#if (defined(WOLFBOOT_TPM_SEAL) && defined(WOLFBOOT_ATA_DISK_LOCK)) || \ |
| 185 | + defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) || \ |
| 186 | + defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) |
| 187 | +# ifndef WOLFBOOT_NEEDS_BASE64 |
| 188 | +# define WOLFBOOT_NEEDS_BASE64 |
| 189 | +# endif |
| 190 | +#endif |
| 191 | + |
| 192 | +/* NEEDS_CMAC and NEEDS_KDF: TZ_PSA and TZ_FWTPM need both. */ |
52 | 193 | #if defined(WOLFCRYPT_TZ_PSA) || defined(WOLFBOOT_TZ_FWTPM) |
53 | 194 | # ifndef WOLFBOOT_NEEDS_CMAC |
54 | 195 | # define WOLFBOOT_NEEDS_CMAC |
|
58 | 199 | # endif |
59 | 200 | #endif |
60 | 201 |
|
| 202 | +/* NEEDS_MALLOC: features whose code-paths use heap allocation. |
| 203 | + * SECURE_PKCS11, WOLFCRYPT_TZ_PSA, the wolfHSM server, and the |
| 204 | + * test/bench harnesses all expect a working malloc. Default builds |
| 205 | + * (no marker) get NO_WOLFSSL_MEMORY + WOLFSSL_NO_MALLOC instead. */ |
| 206 | +#if defined(SECURE_PKCS11) || \ |
| 207 | + defined(WOLFCRYPT_TZ_PSA) || \ |
| 208 | + defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER) || \ |
| 209 | + defined(WOLFCRYPT_TEST) || \ |
| 210 | + defined(WOLFCRYPT_BENCHMARK) |
| 211 | +# ifndef WOLFBOOT_NEEDS_MALLOC |
| 212 | +# define WOLFBOOT_NEEDS_MALLOC |
| 213 | +# endif |
| 214 | +#endif |
| 215 | + |
61 | 216 | #endif /* _WOLFBOOT_USER_SETTINGS_CASCADE_H_ */ |
0 commit comments