[PATCH 5/6] fit: consistently pass around fit_handle
Sascha Hauer
s.hauer at pengutronix.de
Thu Aug 21 06:18:28 PDT 2025
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 at 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
More information about the barebox
mailing list