Skip to content

Commit ea1cdfd

Browse files
d3zd3zdavidvincze
authored andcommitted
boot: Add tlv query for protected region
Add a query to the TLV iterator that will indicate if the currently iterated TLV entry was found in the protected region or not. Signed-off-by: David Brown <david.brown@linaro.org>
1 parent 8c0e36c commit ea1cdfd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

boot/bootutil/include/bootutil/image.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
186186
bool prot);
187187
int bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off,
188188
uint16_t *len, uint16_t *type);
189+
int bootutil_tlv_iter_is_prot(struct image_tlv_iter *it, uint32_t off);
189190

190191
int32_t bootutil_get_img_security_cnt(struct image_header *hdr,
191192
const struct flash_area *fap,

boot/bootutil/src/tlv.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,23 @@ bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off, uint16_t *len,
132132

133133
return 1;
134134
}
135+
136+
/*
137+
* Return if a TLV entry is in the protected area.
138+
*
139+
* @param it The image TLV iterator struct
140+
* @param off The offset of the entry to check.
141+
*
142+
* @return 0 if this TLV iterator entry is not protected.
143+
* 1 if this TLV iterator entry is in the protected region
144+
* -1 if the iterator is invalid.
145+
*/
146+
int
147+
bootutil_tlv_iter_is_prot(struct image_tlv_iter *it, uint32_t off)
148+
{
149+
if (it == NULL || it->hdr == NULL || it->fap == NULL) {
150+
return -1;
151+
}
152+
153+
return off < it->prot_end;
154+
}

0 commit comments

Comments
 (0)