Commit ea1cdfde authored by David Brown's avatar David Brown Committed by Dávid Vincze
Browse files

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: default avatarDavid Brown <david.brown@linaro.org>
parent 8c0e36c8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
                            bool prot);
int bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off,
                           uint16_t *len, uint16_t *type);
int bootutil_tlv_iter_is_prot(struct image_tlv_iter *it, uint32_t off);

int32_t bootutil_get_img_security_cnt(struct image_header *hdr,
                                      const struct flash_area *fap,
+20 −0
Original line number Diff line number Diff line
@@ -132,3 +132,23 @@ bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off, uint16_t *len,

    return 1;
}

/*
 * Return if a TLV entry is in the protected area.
 *
 * @param it The image TLV iterator struct
 * @param off The offset of the entry to check.
 *
 * @return 0 if this TLV iterator entry is not protected.
 *         1 if this TLV iterator entry is in the protected region
 *         -1 if the iterator is invalid.
 */
int
bootutil_tlv_iter_is_prot(struct image_tlv_iter *it, uint32_t off)
{
    if (it == NULL || it->hdr == NULL || it->fap == NULL) {
        return -1;
    }

    return off < it->prot_end;
}