mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 5/6] fit: consistently pass around fit_handle
Date: Thu, 21 Aug 2025 15:18:28 +0200	[thread overview]
Message-ID: <20250821-keynames-v1-5-8144af76d0ab@pengutronix.de> (raw)
In-Reply-To: <20250821-keynames-v1-0-8144af76d0ab@pengutronix.de>

Some functions in the FIT code use the image buffer as context pointer,
other do not have any context pointer at all. Consistently pass around
the struct fit_handle * as context pointer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/image-fit.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 5006394eb7bbd0873a37a0102d5a0d89ea7c6b9f..1fe5aaf9bb186ae2407818b7824deea3f182e3e0 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -64,11 +64,12 @@ static int of_read_string_list(struct device_node *np, const char *name, struct
 	return prop ? 0 : -EINVAL;
 }
 
-static int fit_digest(const void *fit, struct digest *digest,
+static int fit_digest(struct fit_handle *handle, struct digest *digest,
 		      struct string_list *inc_nodes, struct string_list *exc_props,
 		      uint32_t hashed_strings_start, uint32_t hashed_strings_size)
 {
-	const struct fdt_header *fdt = fit;
+	const struct fdt_header *fdt = handle->fit;
+	const void *fit = handle->fit;
 	uint32_t dt_struct;
 	void *dt_strings;
 	struct fdt_header f = {};
@@ -254,7 +255,7 @@ static struct digest *fit_alloc_digest(struct device_node *sig_node,
 	return digest;
 }
 
-static int fit_check_signature(struct device_node *sig_node,
+static int fit_check_signature(struct fit_handle *handle, struct device_node *sig_node,
 			       enum hash_algo algo, void *hash)
 {
 	const struct public_key *key;
@@ -300,7 +301,7 @@ static int fit_check_signature(struct device_node *sig_node,
 /*
  * The consistency of the FTD structure was already checked by of_unflatten_dtb()
  */
-static int fit_verify_signature(struct device_node *sig_node, const void *fit)
+static int fit_verify_signature(struct fit_handle *handle, struct device_node *sig_node)
 {
 	uint32_t hashed_strings_start, hashed_strings_size;
 	struct string_list inc_nodes, exc_props;
@@ -337,7 +338,7 @@ static int fit_verify_signature(struct device_node *sig_node, const void *fit)
 		goto out_sl;
 	}
 
-	ret = fit_digest(fit, digest, &inc_nodes, &exc_props, hashed_strings_start,
+	ret = fit_digest(handle, digest, &inc_nodes, &exc_props, hashed_strings_start,
 			 hashed_strings_size);
 	if (ret)
 		goto out_sl;
@@ -345,7 +346,7 @@ static int fit_verify_signature(struct device_node *sig_node, const void *fit)
 	hash = xzalloc(digest_length(digest));
 	digest_final(digest, hash);
 
-	ret = fit_check_signature(sig_node, algo, hash);
+	ret = fit_check_signature(handle, sig_node, algo, hash);
 	if (ret)
 		goto out_free_hash;
 
@@ -468,7 +469,7 @@ static int fit_image_verify_signature(struct fit_handle *handle,
 	hash = xzalloc(digest_length(digest));
 	digest_final(digest, hash);
 
-	ret = fit_check_signature(sig_node, algo, hash);
+	ret = fit_check_signature(handle, sig_node, algo, hash);
 
 	free(hash);
 
@@ -721,7 +722,7 @@ static int fit_config_verify_signature(struct fit_handle *handle, struct device_
 		if (handle->verbose)
 			of_print_nodes(sig_node, 0, ~0);
 
-		ret = fit_verify_signature(sig_node, handle->fit);
+		ret = fit_verify_signature(handle, sig_node);
 		if (ret < 0)
 			return ret;
 	}

-- 
2.39.5




  parent reply	other threads:[~2025-08-21 17:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21 13:18 [PATCH 0/6] crypto: keys: Some work for public keys Sascha Hauer
2025-08-21 13:18 ` [PATCH 1/6] crypto: drop BOOTM_FITIMAGE_PUBKEY Sascha Hauer
2025-08-21 13:18 ` [PATCH 2/6] crypto: Allow to include development keys in build Sascha Hauer
2025-08-21 13:18 ` [PATCH 3/6] crypto: include public key hashes Sascha Hauer
2025-08-21 13:18 ` [PATCH 4/6] commands: add keys command Sascha Hauer
2025-08-21 13:18 ` Sascha Hauer [this message]
2025-08-21 13:18 ` [PATCH 6/6] fit: improve diagnostics Sascha Hauer

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=20250821-keynames-v1-5-8144af76d0ab@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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