@@ -46,16 +46,13 @@ extern "C" {
46
46
#define STRUCT_PACKED struct __attribute__((__packed__))
47
47
#endif
48
48
49
- struct flash_area ;
50
-
51
49
#define IMAGE_MAGIC 0x96f3b83d
52
50
#define IMAGE_MAGIC_V1 0x96f3b83c
53
51
#define IMAGE_MAGIC_NONE 0xffffffff
54
52
#define IMAGE_TLV_INFO_MAGIC 0x6907
55
53
#define IMAGE_TLV_PROT_INFO_MAGIC 0x6908
56
54
57
55
#define IMAGE_HEADER_SIZE 32
58
- #define IMAGE_HASH_LEN 32 /* Size of SHA256 TLV hash */
59
56
60
57
/*
61
58
* Image header flags.
@@ -98,50 +95,50 @@ struct flash_area;
98
95
* 1st on identifies the public key which should be used to verify it.
99
96
* 2nd one is the actual signature.
100
97
*/
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 */
121
118
/* 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 */
145
142
146
143
STRUCT_PACKED image_version {
147
144
uint8_t iv_major ;
@@ -164,24 +161,24 @@ struct image_dependency {
164
161
STRUCT_PACKED image_header {
165
162
uint32_t ih_magic ;
166
163
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_[...]. */
171
168
struct image_version ih_ver ;
172
169
uint32_t _pad1 ;
173
170
};
174
171
175
172
/** Image TLV header. All fields in little endian. */
176
173
STRUCT_PACKED image_tlv_info {
177
174
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) */
179
176
};
180
177
181
178
/** Image trailer TLV format. All fields in little endian. */
182
179
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). */
185
182
};
186
183
187
184
#define ENCRYPTIONFLAGS (IMAGE_F_ENCRYPTED_AES128 | IMAGE_F_ENCRYPTED_AES256)
@@ -199,8 +196,9 @@ STRUCT_PACKED image_tlv {
199
196
_Static_assert (sizeof (struct image_header ) == IMAGE_HEADER_SIZE ,
200
197
"struct image_header not required size" );
201
198
202
- struct enc_key_data ;
203
199
struct boot_loader_state ;
200
+ struct flash_area ;
201
+
204
202
fih_ret bootutil_img_validate (struct boot_loader_state * state ,
205
203
struct image_header * hdr ,
206
204
const struct flash_area * fap ,
0 commit comments