Skip to content

Commit 956311d

Browse files
de-nordicnordicjm
authored andcommitted
boot: Make boot_enc_valid take slot instead of image index
There is no point for boot_enc_valid to take image index and flash area and use these to figure out slot number. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 4619da5 commit 956311d

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

boot/bootutil/include/bootutil/enc_key.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ int boot_enc_set_key(struct enc_key_data *enc_state, uint8_t slot,
6969
int boot_enc_load(struct enc_key_data *enc_state, int slot,
7070
const struct image_header *hdr, const struct flash_area *fap,
7171
struct boot_status *bs);
72-
bool boot_enc_valid(struct enc_key_data *enc_state, int image_index,
73-
const struct flash_area *fap);
72+
bool boot_enc_valid(struct enc_key_data *enc_state, int slot);
7473
void boot_encrypt(struct enc_key_data *enc_state, int slot,
7574
uint32_t off, uint32_t sz, uint32_t blk_off, uint8_t *buf);
7675
void boot_enc_zeroize(struct enc_key_data *enc_state);

boot/bootutil/src/encrypted.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -682,19 +682,9 @@ boot_enc_load(struct enc_key_data *enc_state, int slot,
682682
}
683683

684684
bool
685-
boot_enc_valid(struct enc_key_data *enc_state, int image_index,
686-
const struct flash_area *fap)
685+
boot_enc_valid(struct enc_key_data *enc_state, int slot)
687686
{
688-
int rc;
689-
690-
rc = flash_area_id_to_multi_image_slot(image_index, flash_area_get_id(fap));
691-
if (rc < 0) {
692-
/* can't get proper slot number - skip encryption, */
693-
/* postpone the error for a upper layer */
694-
return false;
695-
}
696-
697-
return enc_state[rc].valid;
687+
return enc_state[slot].valid;
698688
}
699689

700690
void

boot/bootutil/src/image_validate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bootutil_img_hash(struct enc_key_data *enc_state, int image_index,
9696
#ifdef MCUBOOT_ENC_IMAGES
9797
/* Encrypted images only exist in the secondary slot */
9898
if (MUST_DECRYPT(fap, image_index, hdr) &&
99-
!boot_enc_valid(enc_state, image_index, fap)) {
99+
!boot_enc_valid(enc_state, 1)) {
100100
return -1;
101101
}
102102
#endif

0 commit comments

Comments
 (0)