summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Golle <[email protected]>2026-05-16 00:38:07 +0100
committerTom Rini <[email protected]>2026-05-27 13:41:33 -0600
commit1e4829855234d8dc91c2840a79e9a64a2e8bf3a6 (patch)
treed1bdd6510852aebcbfc48b293567e165c916fc8c /include
parent96e180d354de563ce6dc68cbcac26d67f326940d (diff)
tools: mkimage: add dm-verity Merkle-tree generation
When mkimage encounters a dm-verity subnode inside a component image node it now automatically invokes veritysetup(8) with --no-superblock to generate the Merkle hash tree, screen-scrapes the Root hash and Salt from the tool output, and writes the computed properties back into the FIT blob. The user only needs to specify algorithm, data-block-size, and hash-block-size in the ITS; mkimage fills in digest, salt, num-data-blocks, and hash-start-block. Because --no-superblock is used, hash-start-block equals num-data-blocks with no off-by-one. The image data property is replaced with the expanded content (original data followed directly by the hash tree) so that subsequent hash and signature subnodes operate on the complete image. fit_image_add_verification_data() is restructured into two passes: dm-verity first (may grow data), then hashes and signatures. Signed-off-by: Daniel Golle <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/image.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/image.h b/include/image.h
index fe2361a667e..7b16284257a 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1427,6 +1427,24 @@ int fit_add_verification_data(const char *keydir, const char *keyfile,
const char *cmdname, const char *algo_name,
struct image_summary *summary);
+#ifdef USE_HOSTCC
+/**
+ * fit_verity_get_expanded() - look up the cached dm-verity expanded buffer
+ *
+ * After mkimage has run veritysetup on a FILESYSTEM image, the original
+ * data concatenated with the Merkle hash tree is cached in memory keyed
+ * by image name. fit_extract_data() retrieves it to write the external
+ * data section without having to re-read a temporary file from disk.
+ *
+ * @name: image unit name (FDT node name under /images)
+ * @data: output -- pointer to cached buffer (do NOT free; lifetime
+ * ends when mkimage exits)
+ * @size: output -- size of @data in bytes
+ * Return: 0 if a cache entry exists for @name, -ENOENT otherwise
+ */
+int fit_verity_get_expanded(const char *name, const void **data, size_t *size);
+#endif /* USE_HOSTCC */
+
/**
* fit_image_verify_with_data() - Verify an image with given data
*