@@ -1440,79 +1440,77 @@ ifneq ($(CERT_CHAIN_VERIFY),)
14401440 CERT_CHAIN_GEN_ALGO+ =rsa4096
14411441 endif
14421442
1443- # Per-level algo / hash overrides (default: same algo for CA + leaf,
1444- # SHA256 for cert signatures).
1445- CERT_CHAIN_CA_ALGO ?= $(CERT_CHAIN_GEN_ALGO )
1446- CERT_CHAIN_LEAF_ALGO ?= $(CERT_CHAIN_GEN_ALGO )
1447- CERT_CHAIN_CA_HASH ?= sha256
1448-
1449- # The leaf cert wraps the wolfBoot signing key, so its algo must
1450- # match SIGN. Catch a mismatch here with a clear error rather than
1451- # letting openssl fail later inside the chain-gen helper.
1452- ifneq ($(strip $(CERT_CHAIN_LEAF_ALGO)),$(strip $(CERT_CHAIN_GEN_ALGO)))
1453- $(error CERT_CHAIN_LEAF_ALGO ($(CERT_CHAIN_LEAF_ALGO)) must match the algorithm derived from SIGN=$(SIGN) ($(CERT_CHAIN_GEN_ALGO)))
1454- endif
1443+ # Per-level overrides for the dummy chain generator. Defaults: CA chain
1444+ # uses the same algo as the leaf (SIGN-derived), SHA256 for cert sigs.
1445+ # The leaf algo is fixed by SIGN — the leaf cert wraps the wolfBoot
1446+ # signing key, so it can't diverge.
1447+ CERT_CHAIN_GEN_CA_ALGO ?= $(CERT_CHAIN_GEN_ALGO )
1448+ CERT_CHAIN_GEN_CA_HASH ?= sha256
14551449
14561450 # If any chain component is RSA, the wolfHSM cert buffer must be
14571451 # large enough to hold an RSA4096 cert (~1.5-2 KB).
1458- ifneq ($(filter rsa%,$(CERT_CHAIN_CA_ALGO ) $(CERT_CHAIN_LEAF_ALGO )),)
1452+ ifneq ($(filter rsa%,$(CERT_CHAIN_GEN_CA_ALGO ) $(CERT_CHAIN_GEN_ALGO )),)
14591453 CFLAGS += -DWOLFHSM_CFG_MAX_CERT_SIZE=4096
14601454 endif
14611455
1462- CERT_CHAIN_GEN_FLAGS := --ca-algo $(CERT_CHAIN_CA_ALGO ) \
1463- --leaf-algo $(CERT_CHAIN_LEAF_ALGO ) \
1464- --ca-hash $(CERT_CHAIN_CA_HASH )
1456+ CERT_CHAIN_GEN_FLAGS := --ca-algo $(CERT_CHAIN_GEN_CA_ALGO ) \
1457+ --leaf-algo $(CERT_CHAIN_GEN_ALGO ) \
1458+ --ca-hash $(CERT_CHAIN_GEN_CA_HASH )
1459+
1460+ # Auto-bridge: the verifier in the bootloader must support whatever
1461+ # algo and hash actually sign the dummy chain. Without this, a
1462+ # non-default GEN_CA_ALGO/GEN_CA_HASH builds successfully but fails at
1463+ # runtime when the matching wolfCrypt module is absent.
1464+ AUX_PK_ALGOS += $(CERT_CHAIN_GEN_CA_ALGO )
1465+ AUX_HASH_ALGOS += $(CERT_CHAIN_GEN_CA_HASH )
14651466 endif
14661467 SIGN_OPTIONS += --cert-chain $(CERT_CHAIN_FILE )
1468+ endif
14671469
1468- # Additional algorithms for cert chain verification
1469- # Usage: CERT_CHAIN_HASH=sha384,sha512 CERT_CHAIN_PK=rsa4096,ecc256
1470+ # Auxiliary wolfCrypt algorithms - compile in extra wolfCrypt code beyond
1471+ # what SIGN/HASH already pulls in. Decoupled from any specific feature; the
1472+ # cert chain verifier auto-populates these (see above), but the variables
1473+ # are also available as a generic primitive for any future feature that
1474+ # needs extra algo support compiled in.
1475+ # Usage: AUX_HASH_ALGOS=sha384,sha512 AUX_PK_ALGOS=rsa4096,ecc256
1476+ ifneq ($(strip $(AUX_PK_ALGOS )$(AUX_HASH_ALGOS ) ) ,)
14701477 comma := ,
1471- CERT_CHAIN_HASH_LIST := $(subst $(comma ) , ,$(CERT_CHAIN_HASH ) )
1472- CERT_CHAIN_PK_LIST := $(subst $(comma ) , ,$(CERT_CHAIN_PK ) )
1478+ AUX_HASH_ALGOS_LIST := $(sort $( subst $(comma ) , ,$(AUX_HASH_ALGOS ) ) )
1479+ AUX_PK_ALGOS_LIST := $(sort $( subst $(comma ) , ,$(AUX_PK_ALGOS ) ) )
14731480
1474- # For auto-generated chains, ensure the verifier supports the CA algo
1475- # and CA hash actually used to sign the chain. Without this, a non-
1476- # default CERT_CHAIN_CA_ALGO/CERT_CHAIN_CA_HASH builds successfully
1477- # but fails at runtime when the matching wolfCrypt module is absent.
1478- ifeq ($(USER_CERT_CHAIN),)
1479- CERT_CHAIN_HASH_LIST := $(sort $(CERT_CHAIN_HASH_LIST ) $(CERT_CHAIN_CA_HASH ) )
1480- CERT_CHAIN_PK_LIST := $(sort $(CERT_CHAIN_PK_LIST ) $(CERT_CHAIN_CA_ALGO ) )
1481- endif
1482-
1483- # --- Cert chain hash algorithms ---
1481+ # --- Hash algorithms ---
14841482 # SHA256 is always present in wolfCrypt for wolfBoot, no extra flag needed.
1485- ifneq ($(filter sha384,$(CERT_CHAIN_HASH_LIST )),)
1486- CFLAGS += -DCERT_CHAIN_HASH_SHA384
1483+ ifneq ($(filter sha384,$(AUX_HASH_ALGOS_LIST )),)
1484+ CFLAGS += -DWOLFBOOT_AUX_HASH_SHA384
14871485 ifeq ($(filter %/sha512.o,$(WOLFCRYPT_OBJS)),)
14881486 WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL ) /wolfcrypt/src/sha512.o
14891487 endif
14901488 endif
1491- ifneq ($(filter sha512,$(CERT_CHAIN_HASH_LIST )),)
1492- CFLAGS += -DCERT_CHAIN_HASH_SHA512
1489+ ifneq ($(filter sha512,$(AUX_HASH_ALGOS_LIST )),)
1490+ CFLAGS += -DWOLFBOOT_AUX_HASH_SHA512
14931491 ifeq ($(filter %/sha512.o,$(WOLFCRYPT_OBJS)),)
14941492 WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL ) /wolfcrypt/src/sha512.o
14951493 endif
14961494 endif
1497- ifneq ($(filter sha3,$(CERT_CHAIN_HASH_LIST )),)
1498- CFLAGS += -DCERT_CHAIN_HASH_SHA3
1495+ ifneq ($(filter sha3,$(AUX_HASH_ALGOS_LIST )),)
1496+ CFLAGS += -DWOLFBOOT_AUX_HASH_SHA3
14991497 ifeq ($(filter %/sha3.o,$(WOLFCRYPT_OBJS)),)
15001498 WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL ) /wolfcrypt/src/sha3.o
15011499 endif
15021500 endif
15031501
1504- # --- Cert chain PK algorithms ---
1505- ifneq ($(filter rsa2048,$(CERT_CHAIN_PK_LIST )),)
1506- CFLAGS += -DCERT_CHAIN_PK_RSA2048
1502+ # --- PK algorithms ---
1503+ ifneq ($(filter rsa2048,$(AUX_PK_ALGOS_LIST )),)
1504+ CFLAGS += -DWOLFBOOT_AUX_PK_RSA2048
15071505 endif
1508- ifneq ($(filter rsa3072,$(CERT_CHAIN_PK_LIST )),)
1509- CFLAGS += -DCERT_CHAIN_PK_RSA3072
1506+ ifneq ($(filter rsa3072,$(AUX_PK_ALGOS_LIST )),)
1507+ CFLAGS += -DWOLFBOOT_AUX_PK_RSA3072
15101508 endif
1511- ifneq ($(filter rsa4096,$(CERT_CHAIN_PK_LIST )),)
1512- CFLAGS += -DCERT_CHAIN_PK_RSA4096
1509+ ifneq ($(filter rsa4096,$(AUX_PK_ALGOS_LIST )),)
1510+ CFLAGS += -DWOLFBOOT_AUX_PK_RSA4096
15131511 endif
1514- # Add RSA objects if any RSA cert chain PK is requested
1515- ifneq ($(filter rsa2048 rsa3072 rsa4096,$(CERT_CHAIN_PK_LIST )),)
1512+ # Add RSA objects if any RSA aux PK is requested
1513+ ifneq ($(filter rsa2048 rsa3072 rsa4096,$(AUX_PK_ALGOS_LIST )),)
15161514 ifeq ($(filter %/rsa.o,$(WOLFCRYPT_OBJS)),)
15171515 WOLFCRYPT_OBJS += $(RSA_OBJS )
15181516 endif
@@ -1521,17 +1519,17 @@ ifneq ($(CERT_CHAIN_VERIFY),)
15211519 endif
15221520 endif
15231521
1524- ifneq ($(filter ecc256,$(CERT_CHAIN_PK_LIST )),)
1525- CFLAGS += -DCERT_CHAIN_PK_ECC256
1522+ ifneq ($(filter ecc256,$(AUX_PK_ALGOS_LIST )),)
1523+ CFLAGS += -DWOLFBOOT_AUX_PK_ECC256
15261524 endif
1527- ifneq ($(filter ecc384,$(CERT_CHAIN_PK_LIST )),)
1528- CFLAGS += -DCERT_CHAIN_PK_ECC384
1525+ ifneq ($(filter ecc384,$(AUX_PK_ALGOS_LIST )),)
1526+ CFLAGS += -DWOLFBOOT_AUX_PK_ECC384
15291527 endif
1530- ifneq ($(filter ecc521,$(CERT_CHAIN_PK_LIST )),)
1531- CFLAGS += -DCERT_CHAIN_PK_ECC521
1528+ ifneq ($(filter ecc521,$(AUX_PK_ALGOS_LIST )),)
1529+ CFLAGS += -DWOLFBOOT_AUX_PK_ECC521
15321530 endif
1533- # Add ECC objects if any ECC cert chain PK is requested
1534- ifneq ($(filter ecc256 ecc384 ecc521,$(CERT_CHAIN_PK_LIST )),)
1531+ # Add ECC objects if any ECC aux PK is requested
1532+ ifneq ($(filter ecc256 ecc384 ecc521,$(AUX_PK_ALGOS_LIST )),)
15351533 ifeq ($(filter %/ecc.o,$(WOLFCRYPT_OBJS)),)
15361534 WOLFCRYPT_OBJS += $(ECC_OBJS )
15371535 endif
@@ -1540,23 +1538,22 @@ ifneq ($(CERT_CHAIN_VERIFY),)
15401538 endif
15411539 endif
15421540
1543- ifneq ($(filter ed25519,$(CERT_CHAIN_PK_LIST )),)
1544- CFLAGS += -DCERT_CHAIN_PK_ED25519
1541+ ifneq ($(filter ed25519,$(AUX_PK_ALGOS_LIST )),)
1542+ CFLAGS += -DWOLFBOOT_AUX_PK_ED25519
15451543 ifeq ($(filter %/ed25519.o,$(WOLFCRYPT_OBJS)),)
15461544 WOLFCRYPT_OBJS += $(ED25519_OBJS )
15471545 endif
15481546 endif
15491547
1550- ifneq ($(filter ed448,$(CERT_CHAIN_PK_LIST )),)
1551- CFLAGS += -DCERT_CHAIN_PK_ED448
1548+ ifneq ($(filter ed448,$(AUX_PK_ALGOS_LIST )),)
1549+ CFLAGS += -DWOLFBOOT_AUX_PK_ED448
15521550 ifeq ($(filter %/ed448.o,$(WOLFCRYPT_OBJS)),)
15531551 WOLFCRYPT_OBJS += $(ED448_OBJS )
15541552 endif
15551553 ifeq ($(filter %/sha3.o,$(WOLFCRYPT_OBJS)),)
15561554 WOLFCRYPT_OBJS += $(WOLFBOOT_LIB_WOLFSSL ) /wolfcrypt/src/sha3.o
15571555 endif
15581556 endif
1559-
15601557endif
15611558
15621559# Clock Speed (Hz)
0 commit comments