From 25caa7a1377cb11d4841688a4fa1060a7f70ad42 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 31 Jul 2024 08:58:15 +0100 Subject: [PATCH] bootutil: Add compressed image flags and TLV Adds some flags to indicate if the data of an image is compressed (lzma1 and lzma2) and adds new TLVs for compressed images relating to the hash, signature and size of the decompressed image data, this allows the image to be validated before decompressing, then validated after decompression to ensure an image is always valid for a device Signed-off-by: Jamie McCrae --- boot/bootutil/include/bootutil/image.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/boot/bootutil/include/bootutil/image.h b/boot/bootutil/include/bootutil/image.h index 1f12d9512..2a07dc127 100644 --- a/boot/bootutil/include/bootutil/image.h +++ b/boot/bootutil/include/bootutil/image.h @@ -71,6 +71,12 @@ struct flash_area; */ #define IMAGE_F_ROM_FIXED 0x00000100 +/* + * Flags that indicate if the image data is compressed + */ +#define IMAGE_F_COMPRESSED_LZMA1 0x00000200 +#define IMAGE_F_COMPRESSED_LZMA2 0x00000400 + /* * ECSDA224 is with NIST P-224 * ECSDA256 is with NIST P-256 @@ -101,6 +107,18 @@ struct flash_area; #define IMAGE_TLV_DEPENDENCY 0x40 /* Image depends on other image */ #define IMAGE_TLV_SEC_CNT 0x50 /* security counter */ #define IMAGE_TLV_BOOT_RECORD 0x60 /* measured boot record */ +/* The following flags relate to compressed images and are for the decompressed image data */ +#define IMAGE_TLV_COMP_SIZE 0x70 /* Decompressed image size */ +#define IMAGE_TLV_COMP_SHA 0x71 /* + * Decompressed image shaX hash, this field must match + * the format and size of the raw slot (compressed) + * shaX hash + */ +#define IMAGE_TLV_COMP_SIGNATURE 0x72 /* + * Decompressed image signature, this field must match + * the format and size of the raw slot (compressed) + * signature + */ /* * vendor reserved TLVs at xxA0-xxFF, * where xx denotes the upper byte