Skip to content

Commit 53922ef

Browse files
committed
review: copilot cleanups
1 parent d26048a commit 53922ef

4 files changed

Lines changed: 26 additions & 28 deletions

File tree

include/user_settings/cascade.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@
5151
# endif
5252
#endif
5353

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. */
54+
/* Single source of truth for "this build links wolfCrypt's RSA code".
55+
* Tested by sign_rsa.h's outer #if and by the WOLFBOOT_NEEDS_RSA marker
56+
* below; finalize.h reads the marker to skip NO_RSA / NO_ASN. */
5857
#if defined(WOLFBOOT_SIGN_RSA2048) || \
5958
defined(WOLFBOOT_SIGN_RSA3072) || \
6059
defined(WOLFBOOT_SIGN_RSA4096) || \
@@ -68,6 +67,12 @@
6867
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \
6968
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096) || \
7069
(defined(WOLFCRYPT_SECURE_MODE) && !defined(PKCS11_SMALL))
70+
# ifndef WOLFBOOT_RSA_ENABLED
71+
# define WOLFBOOT_RSA_ENABLED
72+
# endif
73+
#endif
74+
75+
#ifdef WOLFBOOT_RSA_ENABLED
7176
# ifndef WOLFBOOT_NEEDS_RSA
7277
# define WOLFBOOT_NEEDS_RSA
7378
# endif

include/user_settings/sign_ecc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@
8383
# define HAVE_ECC_KEY_IMPORT
8484
#endif
8585

86-
/* SP MATH */
87-
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH_ALL)
86+
/* SP MATH default for builds that did not go through the secure-mode/
87+
* test/bench/wolfHSM #else branch above (which already sets these). */
88+
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH_ALL) && \
89+
!defined(WOLFSSL_SP_MATH)
8890
# define WOLFSSL_SP_MATH
8991
# define WOLFSSL_SP_SMALL
9092
# define WOLFSSL_HAVE_SP_ECC

include/user_settings/sign_rsa.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* wolfCrypt configuration for RSA (PKCS#1 v1.5 and PSS) signature
44
* verification.
55
*
6-
* Active when any WOLFBOOT_SIGN_RSA{2048,3072,4096} (or RSAPSS, or
7-
* SECONDARY) is defined, or when WOLFCRYPT_SECURE_MODE && !PKCS11_SMALL.
6+
* Active when WOLFBOOT_RSA_ENABLED is set by cascade.h (any RSA SIGN
7+
* flag, or WOLFCRYPT_SECURE_MODE && !PKCS11_SMALL).
88
*
99
* The companion `NO_RSA` fallback (when RSA isn't enabled) is also in
1010
* this file, in the #else branch -- so the fragment is included
@@ -32,24 +32,13 @@
3232
#ifndef _WOLFBOOT_USER_SETTINGS_SIGN_RSA_H_
3333
#define _WOLFBOOT_USER_SETTINGS_SIGN_RSA_H_
3434

35-
/* This fragment is included unconditionally by user_settings.h: the trigger
36-
* condition is here in the outer #if, and the #else branch defines NO_RSA
37-
* so downstream blocks that test `#if defined(NO_RSA)` (e.g. the NO_ASN
38-
* carve-out) keep seeing the same value. */
35+
/* This fragment is included unconditionally by user_settings.h. The opt-in
36+
* condition lives in cascade.h as WOLFBOOT_RSA_ENABLED (single source of
37+
* truth shared with the WOLFBOOT_NEEDS_RSA marker). The #else branch
38+
* defines NO_RSA so downstream blocks that test `#if defined(NO_RSA)`
39+
* (e.g. the hash_sha*.h NO_ASN carve-outs) keep seeing the same value. */
3940

40-
#if defined(WOLFBOOT_SIGN_RSA2048) || \
41-
defined(WOLFBOOT_SIGN_RSA3072) || \
42-
defined(WOLFBOOT_SIGN_RSA4096) || \
43-
defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \
44-
defined(WOLFBOOT_SIGN_SECONDARY_RSA3072) || \
45-
defined(WOLFBOOT_SIGN_SECONDARY_RSA4096) || \
46-
defined(WOLFBOOT_SIGN_RSAPSS2048) || \
47-
defined(WOLFBOOT_SIGN_RSAPSS3072) || \
48-
defined(WOLFBOOT_SIGN_RSAPSS4096) || \
49-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048) || \
50-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \
51-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096) || \
52-
(defined(WOLFCRYPT_SECURE_MODE) && !defined(PKCS11_SMALL))
41+
#ifdef WOLFBOOT_RSA_ENABLED
5342

5443
#define WC_RSA_BLINDING
5544
#define WC_RSA_DIRECT
@@ -132,7 +121,7 @@
132121
# define RSA_MAX_SIZE 4096
133122
#endif
134123

135-
#else /* No RSA SIGN flag, no SECURE_MODE without PKCS11_SMALL */
124+
#else /* !WOLFBOOT_RSA_ENABLED */
136125
# define NO_RSA
137126
#endif
138127

include/user_settings/trustzone.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040
#endif
4141

4242
#if defined(WOLFCRYPT_TZ_PSA)
43+
/* WOLFSSL_AES_CFB is set by the SECURE_MODE block above (TZ_PSA implies
44+
* SECURE_MODE in options.mk). */
4345
# define WOLFSSL_AES_COUNTER
4446
# define WOLFSSL_AES_GCM
4547
# define HAVE_AESGCM
4648
# define HAVE_AESCCM
4749
# define HAVE_AES_ECB
48-
# define WOLFSSL_AES_CFB
4950
# define WOLFSSL_AES_OFB
5051
# ifndef NO_DES3
5152
# define NO_DES3
@@ -70,7 +71,8 @@
7071
#endif
7172

7273
#if defined(WOLFBOOT_TZ_FWTPM)
73-
# define WOLFSSL_AES_CFB
74+
/* WOLFSSL_AES_CFB is set by the SECURE_MODE block above (TZ_FWTPM
75+
* implies SECURE_MODE in options.mk). */
7476
# define WOLFSSL_SHA384
7577
#endif
7678

0 commit comments

Comments
 (0)