Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot: Make boot_enc_valid take slot instead of image index #2006

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions boot/bootutil/include/bootutil/enc_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ int boot_enc_set_key(struct enc_key_data *enc_state, uint8_t slot,
int boot_enc_load(struct enc_key_data *enc_state, int slot,
const struct image_header *hdr, const struct flash_area *fap,
struct boot_status *bs);
bool boot_enc_valid(struct enc_key_data *enc_state, int image_index,
const struct flash_area *fap);
bool boot_enc_valid(struct enc_key_data *enc_state, int slot);
void boot_encrypt(struct enc_key_data *enc_state, int slot,
uint32_t off, uint32_t sz, uint32_t blk_off, uint8_t *buf);
void boot_enc_zeroize(struct enc_key_data *enc_state);
Expand Down
14 changes: 2 additions & 12 deletions boot/bootutil/src/encrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,19 +682,9 @@ boot_enc_load(struct enc_key_data *enc_state, int slot,
}

bool
boot_enc_valid(struct enc_key_data *enc_state, int image_index,
const struct flash_area *fap)
boot_enc_valid(struct enc_key_data *enc_state, int slot)
{
int rc;

rc = flash_area_id_to_multi_image_slot(image_index, flash_area_get_id(fap));
if (rc < 0) {
/* can't get proper slot number - skip encryption, */
/* postpone the error for a upper layer */
return false;
}

return enc_state[rc].valid;
return enc_state[slot].valid;
}

void
Expand Down
2 changes: 1 addition & 1 deletion boot/bootutil/src/image_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bootutil_img_hash(struct enc_key_data *enc_state, int image_index,
#ifdef MCUBOOT_ENC_IMAGES
/* Encrypted images only exist in the secondary slot */
if (MUST_DECRYPT(fap, image_index, hdr) &&
!boot_enc_valid(enc_state, image_index, fap)) {
!boot_enc_valid(enc_state, 1)) {
return -1;
}
#endif
Expand Down
Loading