All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkimage: Default to adding a crc32 hash with '-f auto'
@ 2020-05-27 13:24 Simon Glass
  2020-05-28  5:33 ` Wolfgang Denk
  2020-06-03 16:26 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Glass @ 2020-05-27 13:24 UTC (permalink / raw)
  To: u-boot

This option currently does not add any sort of hash to the images in the
FIT.

Add a hash node requesting a crc32 checksum, which at least provides some
protection.

The crc32 value is easily ignored (e.g. in SPL) if not needed. and takes
up only about 48 bytes per image, including overhead.

Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/fit_image.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 88ff093d05..a082d9386d 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -111,7 +111,7 @@ static int fit_calc_size(struct image_tool_params *params)
 		if (size < 0)
 			return -1;
 
-		/* Add space for properties */
+		/* Add space for properties and hash node */
 		total_size += size + 300;
 	}
 
@@ -192,6 +192,18 @@ static void get_basename(char *str, int size, const char *fname)
 	str[len] = '\0';
 }
 
+/**
+ * add_crc_node() - Add a hash node to request a CRC checksum for an image
+ *
+ * @fdt: Device tree to add to (in sequential-write mode)
+ */
+static void add_crc_node(void *fdt)
+{
+	fdt_begin_node(fdt, "hash-1");
+	fdt_property_string(fdt, FIT_ALGO_PROP, "crc32");
+	fdt_end_node(fdt);
+}
+
 /**
  * fit_write_images() - Write out a list of images to the FIT
  *
@@ -230,6 +242,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 	ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile);
 	if (ret)
 		return ret;
+	add_crc_node(fdt);
 	fdt_end_node(fdt);
 
 	/* Now the device tree files if available */
@@ -252,6 +265,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 				    genimg_get_arch_short_name(params->arch));
 		fdt_property_string(fdt, FIT_COMP_PROP,
 				    genimg_get_comp_short_name(IH_COMP_NONE));
+		add_crc_node(fdt);
 		fdt_end_node(fdt);
 	}
 
@@ -269,7 +283,7 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 					params->fit_ramdisk);
 		if (ret)
 			return ret;
-
+		add_crc_node(fdt);
 		fdt_end_node(fdt);
 	}
 
-- 
2.27.0.rc0.183.gde8f92d652-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] mkimage: Default to adding a crc32 hash with '-f auto'
  2020-05-27 13:24 [PATCH] mkimage: Default to adding a crc32 hash with '-f auto' Simon Glass
@ 2020-05-28  5:33 ` Wolfgang Denk
  2020-06-03 16:26 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2020-05-28  5:33 UTC (permalink / raw)
  To: u-boot

Dear Simon,

In message <20200527072419.1.I6b204b428d46addbce0f668960df1756a0bd5a0a@changeid> you wrote:
> This option currently does not add any sort of hash to the images in the
> FIT.
>
> Add a hash node requesting a crc32 checksum, which at least provides some
> protection.
>
> The crc32 value is easily ignored (e.g. in SPL) if not needed. and takes
> up only about 48 bytes per image, including overhead.
>
> Suggested-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Thanks a lot!

Reviewed-by: Wolfgang Denk <wd@denx.de>


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I knew then (in 1970) that a 4-kbyte minicomputer would cost as much
as a house. So I reasoned  that  after  college,  I'd  have  to  live
cheaply in an apartment and put all my money into owning a computer."
      - Apple co-founder Steve Wozniak, EE Times, June 6, 1988, pg 45

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] mkimage: Default to adding a crc32 hash with '-f auto'
  2020-05-27 13:24 [PATCH] mkimage: Default to adding a crc32 hash with '-f auto' Simon Glass
  2020-05-28  5:33 ` Wolfgang Denk
@ 2020-06-03 16:26 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2020-06-03 16:26 UTC (permalink / raw)
  To: u-boot

On Wed, May 27, 2020 at 07:24:55AM -0600, Simon Glass wrote:

> This option currently does not add any sort of hash to the images in the
> FIT.
> 
> Add a hash node requesting a crc32 checksum, which at least provides some
> protection.
> 
> The crc32 value is easily ignored (e.g. in SPL) if not needed. and takes
> up only about 48 bytes per image, including overhead.
> 
> Suggested-by: Wolfgang Denk <wd@denx.de>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Wolfgang Denk <wd@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200603/bb40f660/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-03 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 13:24 [PATCH] mkimage: Default to adding a crc32 hash with '-f auto' Simon Glass
2020-05-28  5:33 ` Wolfgang Denk
2020-06-03 16:26 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.