Skip to content

Commit 5b56b83

Browse files
committed
bootutil: Small sleanup in image.h
Fixed comments indentation and removed IMAGE_HASH_LEN which is not correct. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 15b8991 commit 5b56b83

File tree

1 file changed

+52
-54
lines changed
  • boot/bootutil/include/bootutil

1 file changed

+52
-54
lines changed

boot/bootutil/include/bootutil/image.h

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ extern "C" {
4646
#define STRUCT_PACKED struct __attribute__((__packed__))
4747
#endif
4848

49-
struct flash_area;
50-
5149
#define IMAGE_MAGIC 0x96f3b83d
5250
#define IMAGE_MAGIC_V1 0x96f3b83c
5351
#define IMAGE_MAGIC_NONE 0xffffffff
5452
#define IMAGE_TLV_INFO_MAGIC 0x6907
5553
#define IMAGE_TLV_PROT_INFO_MAGIC 0x6908
5654

5755
#define IMAGE_HEADER_SIZE 32
58-
#define IMAGE_HASH_LEN 32 /* Size of SHA256 TLV hash */
5956

6057
/*
6158
* Image header flags.
@@ -98,50 +95,50 @@ struct flash_area;
9895
* 1st on identifies the public key which should be used to verify it.
9996
* 2nd one is the actual signature.
10097
*/
101-
#define IMAGE_TLV_KEYHASH 0x01 /* hash of the public key */
102-
#define IMAGE_TLV_PUBKEY 0x02 /* public key */
103-
#define IMAGE_TLV_SHA256 0x10 /* SHA256 of image hdr and body */
104-
#define IMAGE_TLV_SHA384 0x11 /* SHA384 of image hdr and body */
105-
#define IMAGE_TLV_SHA512 0x12 /* SHA512 of image hdr and body */
106-
#define IMAGE_TLV_RSA2048_PSS 0x20 /* RSA2048 of hash output */
107-
#define IMAGE_TLV_ECDSA224 0x21 /* ECDSA of hash output - Not supported anymore */
108-
#define IMAGE_TLV_ECDSA_SIG 0x22 /* ECDSA of hash output */
109-
#define IMAGE_TLV_RSA3072_PSS 0x23 /* RSA3072 of hash output */
110-
#define IMAGE_TLV_ED25519 0x24 /* ed25519 of hash output */
111-
#define IMAGE_TLV_SIG_PURE 0x25 /* Indicator that attached signature has been prepared
112-
* over image rather than its digest.
113-
*/
114-
#define IMAGE_TLV_ENC_RSA2048 0x30 /* Key encrypted with RSA-OAEP-2048 */
115-
#define IMAGE_TLV_ENC_KW 0x31 /* Key encrypted with AES-KW 128 or 256*/
116-
#define IMAGE_TLV_ENC_EC256 0x32 /* Key encrypted with ECIES-EC256 */
117-
#define IMAGE_TLV_ENC_X25519 0x33 /* Key encrypted with ECIES-X25519 */
118-
#define IMAGE_TLV_DEPENDENCY 0x40 /* Image depends on other image */
119-
#define IMAGE_TLV_SEC_CNT 0x50 /* security counter */
120-
#define IMAGE_TLV_BOOT_RECORD 0x60 /* measured boot record */
98+
#define IMAGE_TLV_KEYHASH 0x01 /* hash of the public key */
99+
#define IMAGE_TLV_PUBKEY 0x02 /* public key */
100+
#define IMAGE_TLV_SHA256 0x10 /* SHA256 of image hdr and body */
101+
#define IMAGE_TLV_SHA384 0x11 /* SHA384 of image hdr and body */
102+
#define IMAGE_TLV_SHA512 0x12 /* SHA512 of image hdr and body */
103+
#define IMAGE_TLV_RSA2048_PSS 0x20 /* RSA2048 of hash output */
104+
#define IMAGE_TLV_ECDSA224 0x21 /* ECDSA of hash output - Not supported anymore */
105+
#define IMAGE_TLV_ECDSA_SIG 0x22 /* ECDSA of hash output */
106+
#define IMAGE_TLV_RSA3072_PSS 0x23 /* RSA3072 of hash output */
107+
#define IMAGE_TLV_ED25519 0x24 /* ed25519 of hash output */
108+
#define IMAGE_TLV_SIG_PURE 0x25 /* Indicator that attached signature has been prepared
109+
* over image rather than its digest.
110+
*/
111+
#define IMAGE_TLV_ENC_RSA2048 0x30 /* Key encrypted with RSA-OAEP-2048 */
112+
#define IMAGE_TLV_ENC_KW 0x31 /* Key encrypted with AES-KW 128 or 256*/
113+
#define IMAGE_TLV_ENC_EC256 0x32 /* Key encrypted with ECIES-EC256 */
114+
#define IMAGE_TLV_ENC_X25519 0x33 /* Key encrypted with ECIES-X25519 */
115+
#define IMAGE_TLV_DEPENDENCY 0x40 /* Image depends on other image */
116+
#define IMAGE_TLV_SEC_CNT 0x50 /* security counter */
117+
#define IMAGE_TLV_BOOT_RECORD 0x60 /* measured boot record */
121118
/* The following flags relate to compressed images and are for the decompressed image data */
122-
#define IMAGE_TLV_DECOMP_SIZE 0x70 /* Decompressed image size excluding header/TLVs */
123-
#define IMAGE_TLV_DECOMP_SHA 0x71 /*
124-
* Decompressed image shaX hash, this field must match
125-
* the format and size of the raw slot (compressed)
126-
* shaX hash
127-
*/
128-
#define IMAGE_TLV_DECOMP_SIGNATURE 0x72 /*
129-
* Decompressed image signature, this field must match
130-
* the format and size of the raw slot (compressed)
131-
* signature
132-
*/
133-
#define IMAGE_TLV_COMP_DEC_SIZE 0x73 /* Compressed decrypted image size */
134-
/*
135-
* vendor reserved TLVs at xxA0-xxFF,
136-
* where xx denotes the upper byte
137-
* range. Examples:
138-
* 0x00a0 - 0x00ff
139-
* 0x01a0 - 0x01ff
140-
* 0x02a0 - 0x02ff
141-
* ...
142-
* 0xffa0 - 0xfffe
143-
*/
144-
#define IMAGE_TLV_ANY 0xffff /* Used to iterate over all TLV */
119+
#define IMAGE_TLV_DECOMP_SIZE 0x70 /* Decompressed image size excluding header/TLVs */
120+
#define IMAGE_TLV_DECOMP_SHA 0x71 /*
121+
* Decompressed image shaX hash, this field must match
122+
* the format and size of the raw slot (compressed)
123+
* shaX hash
124+
*/
125+
#define IMAGE_TLV_DECOMP_SIGNATURE 0x72 /*
126+
* Decompressed image signature, this field must match
127+
* the format and size of the raw slot (compressed)
128+
* signature
129+
*/
130+
#define IMAGE_TLV_COMP_DEC_SIZE 0x73 /* Compressed decrypted image size */
131+
/*
132+
* vendor reserved TLVs at xxA0-xxFF,
133+
* where xx denotes the upper byte
134+
* range. Examples:
135+
* 0x00a0 - 0x00ff
136+
* 0x01a0 - 0x01ff
137+
* 0x02a0 - 0x02ff
138+
* ...
139+
* 0xffa0 - 0xfffe
140+
*/
141+
#define IMAGE_TLV_ANY 0xffff /* Used to iterate over all TLV */
145142

146143
STRUCT_PACKED image_version {
147144
uint8_t iv_major;
@@ -164,24 +161,24 @@ struct image_dependency {
164161
STRUCT_PACKED image_header {
165162
uint32_t ih_magic;
166163
uint32_t ih_load_addr;
167-
uint16_t ih_hdr_size; /* Size of image header (bytes). */
168-
uint16_t ih_protect_tlv_size; /* Size of protected TLV area (bytes). */
169-
uint32_t ih_img_size; /* Does not include header. */
170-
uint32_t ih_flags; /* IMAGE_F_[...]. */
164+
uint16_t ih_hdr_size; /* Size of image header (bytes). */
165+
uint16_t ih_protect_tlv_size; /* Size of protected TLV area (bytes). */
166+
uint32_t ih_img_size; /* Does not include header. */
167+
uint32_t ih_flags; /* IMAGE_F_[...]. */
171168
struct image_version ih_ver;
172169
uint32_t _pad1;
173170
};
174171

175172
/** Image TLV header. All fields in little endian. */
176173
STRUCT_PACKED image_tlv_info {
177174
uint16_t it_magic;
178-
uint16_t it_tlv_tot; /* size of TLV area (including tlv_info header) */
175+
uint16_t it_tlv_tot; /* size of TLV area (including tlv_info header) */
179176
};
180177

181178
/** Image trailer TLV format. All fields in little endian. */
182179
STRUCT_PACKED image_tlv {
183-
uint16_t it_type; /* IMAGE_TLV_[...]. */
184-
uint16_t it_len; /* Data length (not including TLV header). */
180+
uint16_t it_type; /* IMAGE_TLV_[...]. */
181+
uint16_t it_len; /* Data length (not including TLV header). */
185182
};
186183

187184
#define ENCRYPTIONFLAGS (IMAGE_F_ENCRYPTED_AES128 | IMAGE_F_ENCRYPTED_AES256)
@@ -199,8 +196,9 @@ STRUCT_PACKED image_tlv {
199196
_Static_assert(sizeof(struct image_header) == IMAGE_HEADER_SIZE,
200197
"struct image_header not required size");
201198

202-
struct enc_key_data;
203199
struct boot_loader_state;
200+
struct flash_area;
201+
204202
fih_ret bootutil_img_validate(struct boot_loader_state *state,
205203
struct image_header *hdr,
206204
const struct flash_area *fap,

0 commit comments

Comments
 (0)