From patchwork Thu Dec 3 14:30:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AdrianF X-Patchwork-Id: 107213 Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15052.1796308258693565343 for ; Thu, 03 Dec 2026 06:30:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=adrian.freihofer@siemens.com header.s=fm1 header.b=hcQ054+8; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.64.225, mailfrom: fm-1329275-20261203143056d271f1baaa00020798-utxz_d@rts-flowmailer.siemens.com) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20261203143056d271f1baaa00020798 for ; Thu, 03 Dec 2026 15:30:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=adrian.freihofer@siemens.com; h=from:from:sender:to:to:cc:cc:subject:subject:content-type:content-transfer-encoding:content-transfer-encoding:References:In-Reply-To:Date:Message-ID:MIME-Version; bh=NdkhV6B1T3Nosw2ZlmLwymnIedIK+FSSIBq5/p9qWyo=; b=hcQ054+8afLR/7weRhopQPf/pFAB/v9ofQHZHes7r1IILGHLTACs7INLdMU+wqBMd66hmm YyCjoAabO7FSPFYt4E4jEeO/SRK2Qbe9kYREFagPZVISdAuLTdKP26MBVMvxB1FfSYjGTAlI w5HTAStkCp2ZPL4HnYS8Xk9RdcsudaIItUcChBRKK0P9WxwSojr9K6KzPDMsP2lbw2xZBrg0 SnH/ncrXmmplBLRJlvQtSn7GmnjJqfXNNHTebcbmIWH4aqZYi17/A+j1oDqkg7Q+j/Q+rIok XVWKc5y3zZLQwwZ+VKUwh8cKdfDfEq2eooxD1YSbtUgZ4OkVH1cCrH9g==; From: AdrianF To: openembedded-core@lists.openembedded.org Cc: marex@nabladev.com, Adrian Freihofer Subject: [PATCH 7/8] uboot-sign: add public keys to the U-Boot DTB with fdt_add_pubkey Date: Thu, 3 Dec 2026 15:30:10 +0100 Message-ID: <20261203143044.592073-8-adrian.freihofer@siemens.com> In-Reply-To: <20261203143044.592073-1-adrian.freihofer@siemens.com> References: <20261203143044.592073-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1329275:519-21489:flowmailer List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 03 Dec 2026 14:31:05 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251900 From: Adrian Freihofer concat_dtb signed a dummy FIT image with mkimage only to get the public keys written into the U-Boot DTB. This required the private keys in the U-Boot build, although only the certificates are needed. With keys held in an HSM, the U-Boot build would also need access to the HSM. Use fdt_add_pubkey instead, which only reads .crt and sets the same required and algo properties. The dummy unused.itb and the fit_check_sign self-test against it are dropped. UBOOT_MKIMAGE_SIGN_ARGS and UBOOT_MKIMAGE_DTCOPTS no longer apply to concat_dtb. The oe-selftest fitimage tests check the keys in the U-Boot DTB and verify the signed kernel FIT image against it. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/uboot-sign.bbclass | 61 ++++++-------------------- meta/conf/uboot.conf | 3 ++ 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/meta/classes-recipe/uboot-sign.bbclass b/meta/classes-recipe/uboot-sign.bbclass index c46a0d5f04..1aa7e04f4d 100644 --- a/meta/classes-recipe/uboot-sign.bbclass +++ b/meta/classes-recipe/uboot-sign.bbclass @@ -11,8 +11,7 @@ # certificate in a directory and to define the following variable: # # UBOOT_SIGN_KEYDIR = "/keys/directory" -# UBOOT_SIGN_KEYNAME = "dev" # keys name in keydir (eg. "dev.crt", "dev.key") -# UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" +# UBOOT_SIGN_KEYNAME = "dev" # key name in keydir (eg. "dev.crt") # UBOOT_SIGN_ENABLE = "1" # # As verified boot depends on fitImage generation, following is also required: @@ -200,58 +199,24 @@ concat_dtb() { # support is kept to avoid breakage of existing layers, but # it is highly recommended to avoid FIT_SIGN_INDIVIDUAL = "1", # i.e. set FIT_SIGN_INDIVIDUAL = "0" . + # Add the public keys of the kernel FIT signing keys to the + # U-Boot DTB. Only the certificates (.crt) are needed. if [ "${FIT_SIGN_INDIVIDUAL}" = "1" ] ; then - # Sign dummy image images in order to - # add the image signing keys to our dtb - ${UBOOT_MKIMAGE_SIGN} \ - ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ - -f auto \ + ${UBOOT_FDT_ADD_PUBKEY} \ + -a "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \ -k "${UBOOT_SIGN_KEYDIR}" \ - -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \ - -g "${UBOOT_SIGN_IMG_KEYNAME}" \ - -K "${UBOOT_DTB_BINARY}" \ - -d /dev/null \ - -r ${B}/unused.itb \ - ${UBOOT_MKIMAGE_SIGN_ARGS} + -n "${UBOOT_SIGN_IMG_KEYNAME}" \ + -r image \ + "${UBOOT_DTB_BINARY}" fi - # Sign dummy image configurations in order to - # add the configuration signing keys to our dtb - ${UBOOT_MKIMAGE_SIGN} \ - ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ - -f auto-conf \ + ${UBOOT_FDT_ADD_PUBKEY} \ + -a "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \ -k "${UBOOT_SIGN_KEYDIR}" \ - -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \ - -g "${UBOOT_SIGN_KEYNAME}" \ - -K "${UBOOT_DTB_BINARY}" \ - -d /dev/null \ - -r ${B}/unused.itb \ - ${UBOOT_MKIMAGE_SIGN_ARGS} + -n "${UBOOT_SIGN_KEYNAME}" \ + -r conf \ + "${UBOOT_DTB_BINARY}" - # Verify the dummy fitImage signature against u-boot.dtb - # augmented using public key material. - # - # This only works for FIT_SIGN_INDIVIDUAL = "0", because - # mkimage -f auto-conf does not support -F to extend the - # existing unused.itb , and instead rewrites unused.itb - # from scratch. - # - # Using two separate unused.itb for mkimage -f auto and - # mkimage -f auto-conf invocation above would not help, as - # the signature verification process below checks whether - # all keys inserted into u-boot.dtb /signature node pass - # the verification. Separate unused.itb would each miss one - # of the signatures. - # - # The FIT_SIGN_INDIVIDUAL = "1" support is kept to avoid - # breakage of existing layers, but it is highly recommended - # to not use FIT_SIGN_INDIVIDUAL = "1", i.e. set - # FIT_SIGN_INDIVIDUAL = "0" . - if [ "${FIT_SIGN_INDIVIDUAL}" != "1" ] ; then - ${UBOOT_FIT_CHECK_SIGN} \ - -k "${UBOOT_DTB_BINARY}" \ - -f ${B}/unused.itb - fi cp ${UBOOT_DTB_BINARY} ${UBOOT_DTB_SIGNED} fi diff --git a/meta/conf/uboot.conf b/meta/conf/uboot.conf index 01e0b6cc7e..e08a3c46bb 100644 --- a/meta/conf/uboot.conf +++ b/meta/conf/uboot.conf @@ -32,3 +32,6 @@ SPL_MKIMAGE_SIGN_ARGS ?= "" # uboot-fit_check_sign command UBOOT_FIT_CHECK_SIGN ?= "uboot-fit_check_sign" + +# uboot-fdt_add_pubkey command, adds the public keys (.crt) to the U-Boot DTB +UBOOT_FDT_ADD_PUBKEY ?= "uboot-fdt_add_pubkey"