Skip to contentSkip to conversation

fitimage.bbclass: document provider-based PKCS#11 signing

PATCH New Bastian Krause 1 participant 2 messages Oct 2

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fitimage.bbclass: document provider-based PKCS#11 signing

Now that oe-core moved to OpenSSL 4.0, the engine API is gone. As a result uboot-mkimage's -N/--engine no longer work:

Failed to sign 'signature-1' signature node in 'conf-imx6dl-riotboard.dtb' conf node uboot-mkimage Can't add hashes to FIT blob: -1
Error: Bad parameters for FIT image type
Usage: uboot-mkimage [-T type] -l image

            -l ==> list image header information
            -T ==> parse image file as 'type'
            -q ==> quiet

Document the provider-based setup instead: signing_create_uri_pem() wraps the role's PKCS#11 URI in a PEM file that OpenSSL loads like a key file and resolves through the PKCS#11 provider configured by signing_prepare().

mkimage looks for a key in ${FITIMAGE_SIGN_KEYDIR}/${FITIMAGE_SIGN_KEYNAME}.key, so store it there. This way the existing mkimage invocations do not need to be touched.

---
 meta-oe/classes/fitimage.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta-oe/classes/fitimage.bbclass +4 -2
index 109b3b421b..69e1c5c7b2 100644
@@ -58,11 +58,13 @@
 #    do_fitimage:prepend() {
 #        signing_prepare
 #        signing_use_role "${FITIMAGE_SIGNING_KEY_ROLE}"
+#        mkdir -p "${FITIMAGE_SIGN_KEYDIR}"
+#        signing_create_uri_pem "${FITIMAGE_SIGNING_KEY_ROLE}" "${FITIMAGE_SIGN_KEYDIR}/${FITIMAGE_SIGN_KEYNAME}.key"
 #    }
 #
 #    FITIMAGE_SIGN = "1"
-#    FITIMAGE_MKIMAGE_EXTRA_ARGS = "--engine pkcs11"
-#    FITIMAGE_SIGN_KEYDIR = "${PKCS11_URI#pkcs11:}"
+#    FITIMAGE_SIGN_KEYDIR = "${B}/keys"
+#    FITIMAGE_SIGN_KEYNAME = "fit"
 
 
 LICENSE ?= "MIT"
Signature · 1 line
2.47.3
#1 lore raw

PATCH 2/2 fitimage.bbclass: make engine parameters in FITIMAGE_MKIMAGE_EXTRA_ARGS fail early

Now that oe-core moved to OpenSSL 4.0, the engine API is gone. As a result uboot-mkimage's -N/--engine no longer work:

Failed to sign 'signature-1' signature node in 'conf-imx6dl-riotboard.dtb' conf node uboot-mkimage Can't add hashes to FIT blob: -1
Error: Bad parameters for FIT image type
Usage: uboot-mkimage [-T type] -l image

            -l ==> list image header information
            -T ==> parse image file as 'type'
            -q ==> quiet

A previous patch documented how provider-based PKCS#11 signing works. Now make an engine option in FITIMAGE_MKIMAGE_EXTRA_ARGS a fatal error. It has no effect anymore, so a recipe still setting it has not been migrated; failing with a clear message beats mkimage's generic error messages above.

---
 meta-oe/classes/fitimage.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta-oe/classes/fitimage.bbclass +5 -0
index 69e1c5c7b2..4bacdbdb9e 100644
@@ -519,6 +519,11 @@ do_configure[postfuncs] += "write_manifest"
 
 do_fitimage () {
     if [ "${FITIMAGE_SIGN}" = "1" ]; then
+        case " ${FITIMAGE_MKIMAGE_EXTRA_ARGS} " in
+        *" --engine "*|*" --engine="*|*" -N "*)
+            bbfatal "OpenSSL engines are no longer supported, see updated usage in fitimage.bbclass."
+            ;;
+        esac
         uboot-mkimage ${FITIMAGE_MKIMAGE_EXTRA_ARGS} \
             -k "${FITIMAGE_SIGN_KEYDIR}" -r \
             -f "${B}/manifest.its" \
Signature · 1 line
2.47.3