Skip to content

Commit a46f5b8

Browse files
committed
add generic RSA_ANY macro to reduce clutter
1 parent 6a432e8 commit a46f5b8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

include/loader.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ extern "C" {
5151
#define WOLFBOOT_SIGN_RSAPSS_ANY
5252
#endif
5353

54+
/* Consolidated RSA flag: set when any RSA variant is enabled (PKCS#1 v1.5 or
55+
* PSS, primary or secondary). Used to guard the unified RSA verify function
56+
* and related RSA code paths. */
57+
#if defined(WOLFBOOT_SIGN_RSA2048) || defined(WOLFBOOT_SIGN_RSA3072) || \
58+
defined(WOLFBOOT_SIGN_RSA4096) || \
59+
defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \
60+
defined(WOLFBOOT_SIGN_SECONDARY_RSA3072) || \
61+
defined(WOLFBOOT_SIGN_SECONDARY_RSA4096) || \
62+
defined(WOLFBOOT_SIGN_RSAPSS2048) || defined(WOLFBOOT_SIGN_RSAPSS3072) || \
63+
defined(WOLFBOOT_SIGN_RSAPSS4096) || \
64+
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048) || \
65+
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \
66+
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096)
67+
#define WOLFBOOT_SIGN_RSA_ANY
68+
#endif
69+
5470
#if defined(WOLFBOOT_SIGN_RSA2048) || defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \
5571
defined(WOLFBOOT_SIGN_RSAPSS2048) || defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048)
5672
#define RSA_IMAGE_SIGNATURE_SIZE (256)

src/image.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,7 @@ static void wolfBoot_verify_signature_ecc(uint8_t key_slot,
359359
* WOLFBOOT_SIGN_SECONDARY_ECC521 */
360360

361361

362-
#if defined(WOLFBOOT_SIGN_RSA2048) || \
363-
defined(WOLFBOOT_SIGN_RSA3072) || \
364-
defined(WOLFBOOT_SIGN_RSA4096) || \
365-
defined(WOLFBOOT_SIGN_SECONDARY_RSA2048) || \
366-
defined(WOLFBOOT_SIGN_SECONDARY_RSA3072) || \
367-
defined(WOLFBOOT_SIGN_SECONDARY_RSA4096) || \
368-
defined(WOLFBOOT_SIGN_RSAPSS2048) || \
369-
defined(WOLFBOOT_SIGN_RSAPSS3072) || \
370-
defined(WOLFBOOT_SIGN_RSAPSS4096) || \
371-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS2048) || \
372-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS3072) || \
373-
defined(WOLFBOOT_SIGN_SECONDARY_RSAPSS4096)
362+
#ifdef WOLFBOOT_SIGN_RSA_ANY
374363

375364
#include <wolfssl/wolfcrypt/asn.h>
376365
#include <wolfssl/wolfcrypt/rsa.h>
@@ -610,12 +599,7 @@ static void wolfBoot_verify_signature_rsa_common(uint8_t key_slot,
610599
}
611600
}
612601

613-
#endif /* WOLFBOOT_SIGN_RSA2048 || WOLFBOOT_SIGN_RSA3072 || \
614-
* WOLFBOOT_SIGN_RSA4096 || WOLFBOOT_SIGN_SECONDARY_RSA2048 ||
615-
* WOLFBOOT_SIGN_SECONDARY_RSA3072 || WOLFBOOT_SIGN_SECONDARY_RSA4096 ||
616-
* WOLFBOOT_SIGN_RSAPSS2048 || WOLFBOOT_SIGN_RSAPSS3072 ||
617-
* WOLFBOOT_SIGN_RSAPSS4096 || WOLFBOOT_SIGN_SECONDARY_RSAPSS2048 ||
618-
* WOLFBOOT_SIGN_SECONDARY_RSAPSS3072 || WOLFBOOT_SIGN_SECONDARY_RSAPSS4096 */
602+
#endif /* WOLFBOOT_SIGN_RSA_ANY */
619603

620604
#ifdef WOLFBOOT_SIGN_LMS
621605
#include <wolfssl/wolfcrypt/lms.h>

0 commit comments

Comments
 (0)