@@ -46,8 +46,6 @@ 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
@@ -98,50 +96,50 @@ struct flash_area;
98
96
* 1st on identifies the public key which should be used to verify it.
99
97
* 2nd one is the actual signature.
100
98
*/
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 */
99
+ #define IMAGE_TLV_KEYHASH 0x01 /* hash of the public key */
100
+ #define IMAGE_TLV_PUBKEY 0x02 /* public key */
101
+ #define IMAGE_TLV_SHA256 0x10 /* SHA256 of image hdr and body */
102
+ #define IMAGE_TLV_SHA384 0x11 /* SHA384 of image hdr and body */
103
+ #define IMAGE_TLV_SHA512 0x12 /* SHA512 of image hdr and body */
104
+ #define IMAGE_TLV_RSA2048_PSS 0x20 /* RSA2048 of hash output */
105
+ #define IMAGE_TLV_ECDSA224 0x21 /* ECDSA of hash output - Not supported anymore */
106
+ #define IMAGE_TLV_ECDSA_SIG 0x22 /* ECDSA of hash output */
107
+ #define IMAGE_TLV_RSA3072_PSS 0x23 /* RSA3072 of hash output */
108
+ #define IMAGE_TLV_ED25519 0x24 /* ed25519 of hash output */
109
+ #define IMAGE_TLV_SIG_PURE 0x25 /* Indicator that attached signature has been prepared
110
+ * over image rather than its digest.
111
+ */
112
+ #define IMAGE_TLV_ENC_RSA2048 0x30 /* Key encrypted with RSA-OAEP-2048 */
113
+ #define IMAGE_TLV_ENC_KW 0x31 /* Key encrypted with AES-KW 128 or 256*/
114
+ #define IMAGE_TLV_ENC_EC256 0x32 /* Key encrypted with ECIES-EC256 */
115
+ #define IMAGE_TLV_ENC_X25519 0x33 /* Key encrypted with ECIES-X25519 */
116
+ #define IMAGE_TLV_DEPENDENCY 0x40 /* Image depends on other image */
117
+ #define IMAGE_TLV_SEC_CNT 0x50 /* security counter */
118
+ #define IMAGE_TLV_BOOT_RECORD 0x60 /* measured boot record */
121
119
/* 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 */
120
+ #define IMAGE_TLV_DECOMP_SIZE 0x70 /* Decompressed image size excluding header/TLVs */
121
+ #define IMAGE_TLV_DECOMP_SHA 0x71 /*
122
+ * Decompressed image shaX hash, this field must match
123
+ * the format and size of the raw slot (compressed)
124
+ * shaX hash
125
+ */
126
+ #define IMAGE_TLV_DECOMP_SIGNATURE 0x72 /*
127
+ * Decompressed image signature, this field must match
128
+ * the format and size of the raw slot (compressed)
129
+ * signature
130
+ */
131
+ #define IMAGE_TLV_COMP_DEC_SIZE 0x73 /* Compressed decrypted image size */
132
+ /*
133
+ * vendor reserved TLVs at xxA0-xxFF,
134
+ * where xx denotes the upper byte
135
+ * range. Examples:
136
+ * 0x00a0 - 0x00ff
137
+ * 0x01a0 - 0x01ff
138
+ * 0x02a0 - 0x02ff
139
+ * ...
140
+ * 0xffa0 - 0xfffe
141
+ */
142
+ #define IMAGE_TLV_ANY 0xffff /* Used to iterate over all TLV */
145
143
146
144
STRUCT_PACKED image_version {
147
145
uint8_t iv_major ;
@@ -164,24 +162,24 @@ struct image_dependency {
164
162
STRUCT_PACKED image_header {
165
163
uint32_t ih_magic ;
166
164
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_[...]. */
165
+ uint16_t ih_hdr_size ; /* Size of image header (bytes). */
166
+ uint16_t ih_protect_tlv_size ; /* Size of protected TLV area (bytes). */
167
+ uint32_t ih_img_size ; /* Does not include header. */
168
+ uint32_t ih_flags ; /* IMAGE_F_[...]. */
171
169
struct image_version ih_ver ;
172
170
uint32_t _pad1 ;
173
171
};
174
172
175
173
/** Image TLV header. All fields in little endian. */
176
174
STRUCT_PACKED image_tlv_info {
177
175
uint16_t it_magic ;
178
- uint16_t it_tlv_tot ; /* size of TLV area (including tlv_info header) */
176
+ uint16_t it_tlv_tot ; /* size of TLV area (including tlv_info header) */
179
177
};
180
178
181
179
/** Image trailer TLV format. All fields in little endian. */
182
180
STRUCT_PACKED image_tlv {
183
- uint16_t it_type ; /* IMAGE_TLV_[...]. */
184
- uint16_t it_len ; /* Data length (not including TLV header). */
181
+ uint16_t it_type ; /* IMAGE_TLV_[...]. */
182
+ uint16_t it_len ; /* Data length (not including TLV header). */
185
183
};
186
184
187
185
#define ENCRYPTIONFLAGS (IMAGE_F_ENCRYPTED_AES128 | IMAGE_F_ENCRYPTED_AES256)
@@ -199,8 +197,9 @@ STRUCT_PACKED image_tlv {
199
197
_Static_assert (sizeof (struct image_header ) == IMAGE_HEADER_SIZE ,
200
198
"struct image_header not required size" );
201
199
202
- struct enc_key_data ;
203
200
struct boot_loader_state ;
201
+ struct flash_area ;
202
+
204
203
fih_ret bootutil_img_validate (struct boot_loader_state * state ,
205
204
struct image_header * hdr ,
206
205
const struct flash_area * fap ,
0 commit comments