Skip to content

Commit 29cd5ac

Browse files
jamin-aspeedrpurdie
authored andcommitted
uboot-sign: Make SPL DTB public key injection optional
Introduce SPL_SIGN_ADD_PUBKEY to control whether the public key is added into the SPL device tree and whether FIT signature verification is performed after signing. Key changes: - Added SPL_SIGN_ADD_PUBKEY variable (default = "1") - Conditionally apply '-K <dtb>' to mkimage only if adding key is enabled - Skip fit_check_sign when public key injection is disabled - Suppress concat_spl_dtb() warnings if key adding is turned off This allows U-Boot FIT images to be signed without modifying the SPL DTB, useful in scenarios where public key management is handled elsewhere or post-processing will be done separately. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1 parent dc267c7 commit 29cd5ac

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

meta/classes-recipe/uboot-sign.bbclass

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ UBOOT_FITIMAGE_ENABLE ?= "0"
3434
# Signature activation - this requires UBOOT_FITIMAGE_ENABLE = "1"
3535
SPL_SIGN_ENABLE ?= "0"
3636

37+
# Whether to add (embed) the public key into the SPL Device Tree (.dtb).
38+
# If set to "1", the key will be inserted into the /signature node of the DTB
39+
# and fit_check_sign will be used to verify the signature.
40+
# If set to "0", only signing will be performed, without modifying the DTB.
41+
SPL_SIGN_ADD_PUBKEY ?= "1"
42+
3743
# Default value for deployment filenames.
3844
UBOOT_DTB_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.dtb"
3945
UBOOT_DTB_BINARY ?= "u-boot.dtb"
@@ -245,7 +251,9 @@ concat_spl_dtb() {
245251
if [ -e "${SPL_DIR}/${SPL_NODTB_BINARY}" -a -e "${SPL_DIR}/${SPL_DTB_BINARY}" ] ; then
246252
cat ${SPL_DIR}/${SPL_NODTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED} > "${SPL_BINARY}"
247253
else
248-
bbwarn "Failure while adding public key to spl binary. Verified U-Boot boot won't be available."
254+
if [ "${SPL_SIGN_ADD_PUBKEY}" = "1" ]; then
255+
bbwarn "Failure while adding public key to spl binary. Verified U-Boot boot won't be available."
256+
fi
249257
fi
250258
}
251259

@@ -474,15 +482,17 @@ EOF
474482
${UBOOT_MKIMAGE_SIGN} \
475483
${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
476484
-F -k "${SPL_SIGN_KEYDIR}" \
477-
-K "${SPL_DIR}/${SPL_DTB_BINARY}" \
485+
${@'-K "${SPL_DIR}/${SPL_DTB_BINARY}"' if d.getVar("SPL_SIGN_ADD_PUBKEY") == "1" else ''} \
478486
-r ${UBOOT_FITIMAGE_BINARY} \
479487
${SPL_MKIMAGE_SIGN_ARGS}
480488
#
481489
# Verify the U-boot FIT image and SPL dtb
482490
#
483-
${UBOOT_FIT_CHECK_SIGN} \
484-
-k "${SPL_DIR}/${SPL_DTB_BINARY}" \
485-
-f ${UBOOT_FITIMAGE_BINARY}
491+
if [ "${SPL_SIGN_ADD_PUBKEY}" = "1" ]; then
492+
${UBOOT_FIT_CHECK_SIGN} \
493+
-k "${SPL_DIR}/${SPL_DTB_BINARY}" \
494+
-f ${UBOOT_FITIMAGE_BINARY}
495+
fi
486496
fi
487497

488498
if [ -e "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then

0 commit comments

Comments
 (0)