diff --git a/boot/bootutil/src/loader_manifest_xip.c b/boot/bootutil/src/loader_manifest_xip.c index 4a3bfea6d..abd60fcb1 100644 --- a/boot/bootutil/src/loader_manifest_xip.c +++ b/boot/bootutil/src/loader_manifest_xip.c @@ -202,6 +202,20 @@ boot_validate_slot(struct boot_loader_state *state, int slot, FIH_RET(fih_rc); } +#ifdef MCUBOOT_HW_ROLLBACK_PROT +/** + * Checks if the specified image should have a security counter present on it or not + * + * @param image_index Index of the image to check. + * + * @return true if security counter should be present; false if otherwise + */ +fih_ret boot_nv_image_should_have_security_counter(uint32_t image_index) +{ + return FIH_SUCCESS; +} +#endif /* MCUBOOT_HW_ROLLBACK_PROT */ + /** * Opens all flash areas and checks which contain an image with a valid header. * diff --git a/boot/zephyr/ironside_counters/ironside_counters.c b/boot/zephyr/ironside_counters/ironside_counters.c index bf0056ba6..e79b94e52 100644 --- a/boot/zephyr/ironside_counters/ironside_counters.c +++ b/boot/zephyr/ironside_counters/ironside_counters.c @@ -30,7 +30,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt) FIH_RET(FIH_FAILURE); } - if (image_id > IRONSIDE_COUNTER_MAX) { + if (image_id > IRONSIDE_COUNTER_NUM) { FIH_RET(FIH_FAILURE); } @@ -49,7 +49,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt) } } - if (cur_sec_cnt[0] > IRONSIDE_COUNTER_MAX_VALUE) { + if (cur_sec_cnt[0] <= IRONSIDE_COUNTER_MAX_VALUE) { *security_cnt = fih_int_encode(cur_sec_cnt[0]); FIH_RET(FIH_SUCCESS); } @@ -59,7 +59,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt) int32_t boot_nv_security_counter_update(uint32_t image_id, uint32_t img_security_cnt) { - if ((img_security_cnt > IRONSIDE_COUNTER_MAX_VALUE) || (image_id > IRONSIDE_COUNTER_MAX)) { + if ((img_security_cnt > IRONSIDE_COUNTER_MAX_VALUE) || (image_id > IRONSIDE_COUNTER_NUM)) { return -BOOT_EBADARGS; } @@ -72,7 +72,7 @@ int32_t boot_nv_security_counter_update(uint32_t image_id, uint32_t img_security fih_int boot_nv_security_counter_is_update_possible(uint32_t image_id, uint32_t img_security_cnt) { - fih_int security_cnt; + fih_int security_cnt = FIH_FAILURE; fih_int fih_err; FIH_CALL(boot_nv_security_counter_get, fih_err, image_id, &security_cnt); @@ -89,7 +89,7 @@ fih_int boot_nv_security_counter_is_update_possible(uint32_t image_id, uint32_t int32_t boot_nv_security_counter_lock(uint32_t image_id) { - if (image_id > IRONSIDE_COUNTER_MAX) { + if (image_id > IRONSIDE_COUNTER_NUM) { return -BOOT_EBADARGS; }