U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Schulz <foss+uboot@0leil.net>
To: u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>,
	Aristo Chen <jj251510319013@gmail.com>,
	 Rasmus Villemoes <ravi@prevas.dk>,
	 Marek Vasut <marek.vasut+renesas@mailbox.org>,
	 Simon Glass <sjg@chromium.org>,
	 Paul HENRYS <paul.henrys_ext@softathome.com>,
	 Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Shiji Yang <yangshiji66@outlook.com>,
	 Anton Moryakov <ant.v.moryakov@gmail.com>,
	 Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	Alice Guo <alice.guo@nxp.com>,  Bryan Brattlof <bb@ti.com>,
	Quentin Schulz <quentin.schulz@cherry.de>
Subject: [PATCH 1/3] fit: support signing with only an engine_id
Date: Fri, 31 Oct 2025 16:22:58 +0100	[thread overview]
Message-ID: <20251031-binman-engine-v1-1-c13c1b5dac43@cherry.de> (raw)
In-Reply-To: <20251031-binman-engine-v1-0-c13c1b5dac43@cherry.de>

From: Quentin Schulz <quentin.schulz@cherry.de>

Currently, when one wants to use an OpenSSL engine to sign a FIT image,
one needs to pass a keydir (via -k) to mkimage which will then be
prepended to the value of the key-name-hint before being passed as
key_id argument to the OpenSSL Engine API, or pass a keyfile (via -G) to
mkimage.

My OpenSSL engine only has "slots" which are not mapped like
directories, so using keydir is not proper, though I could simply have
-k '' I guess but this won't work currently with binman anyway.

Additionally, passing a keyfile when using an engine doesn't make sense
as the key is stored in the engine.

Let simply allow FIT images be signed if both keydir and keyfile are
missing but an engine is to be used.

The keyname member is already filled by looking at key-name-hint
property in the FIT and passed verbatim to the engine, which is exactly
what is needed here.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
 tools/fit_image.c  | 3 ++-
 tools/image-host.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 0306333141e..694bb927c7d 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -26,7 +26,8 @@ static struct legacy_img_hdr header;
 
 static int fit_estimate_hash_sig_size(struct image_tool_params *params, const char *fname)
 {
-	bool signing = IMAGE_ENABLE_SIGN && (params->keydir || params->keyfile);
+	bool signing = IMAGE_ENABLE_SIGN &&
+		(params->keydir || params->keyfile || params->engine_id);
 	struct stat sbuf;
 	void *fdt;
 	int fd;
diff --git a/tools/image-host.c b/tools/image-host.c
index 21dd7f2d922..54df86316ae 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -696,7 +696,7 @@ int fit_image_add_verification_data(const char *keydir, const char *keyfile,
 			     strlen(FIT_HASH_NODENAME))) {
 			ret = fit_image_process_hash(fit, image_name, noffset,
 						data, size);
-		} else if (IMAGE_ENABLE_SIGN && (keydir || keyfile) &&
+		} else if (IMAGE_ENABLE_SIGN && (keydir || keyfile || engine_id) &&
 			   !strncmp(node_name, FIT_SIG_NODENAME,
 				strlen(FIT_SIG_NODENAME))) {
 			ret = fit_image_process_sig(keydir, keyfile, keydest,
@@ -1366,7 +1366,7 @@ int fit_add_verification_data(const char *keydir, const char *keyfile,
 	}
 
 	/* If there are no keys, we can't sign configurations */
-	if (!IMAGE_ENABLE_SIGN || !(keydir || keyfile))
+	if (!IMAGE_ENABLE_SIGN || !(keydir || keyfile || engine_id))
 		return 0;
 
 	/* Find configurations parent node offset */

-- 
2.51.0


  reply	other threads:[~2025-10-31 15:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 15:22 [PATCH 0/3] fit: allow signing with only an engine_id Quentin Schulz
2025-10-31 15:22 ` Quentin Schulz [this message]
2025-11-02 19:53   ` [PATCH 1/3] fit: support " Simon Glass
2025-11-11 10:10   ` Wolfgang Wallner
2025-10-31 15:22 ` [PATCH 2/3] tools: binman: mkimage: add support for passing the engine Quentin Schulz
2025-11-02 19:53   ` Simon Glass
2025-11-03 12:13     ` Quentin Schulz
2025-11-03 14:17       ` Tom Rini
2025-11-03 14:21         ` Quentin Schulz
2025-11-03 14:52       ` Simon Glass
2025-11-11 10:11   ` Wolfgang Wallner
2025-10-31 15:23 ` [PATCH 3/3] tools: binman: fit: add support for OpenSSL engines Quentin Schulz
2025-11-02 19:53   ` Simon Glass
2025-11-03 16:21   ` Peter Robinson
2025-11-03 16:47     ` Quentin Schulz
2025-11-11 10:14     ` Wolfgang Wallner
2025-11-17 15:18       ` Peter Robinson
2025-11-17 15:38         ` Tom Rini
2025-11-17 16:09           ` Quentin Schulz
2025-11-11 10:12   ` Wolfgang Wallner
2025-11-11 10:10 ` [PATCH 0/3] fit: allow signing with only an engine_id Wolfgang Wallner
2025-11-11 11:22   ` Quentin Schulz
2025-11-11 14:49     ` Wolfgang Wallner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251031-binman-engine-v1-1-c13c1b5dac43@cherry.de \
    --to=foss+uboot@0leil.net \
    --cc=alice.guo@nxp.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=ant.v.moryakov@gmail.com \
    --cc=bb@ti.com \
    --cc=jj251510319013@gmail.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=paul.henrys_ext@softathome.com \
    --cc=quentin.schulz@cherry.de \
    --cc=ravi@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=yangshiji66@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox