Skip to content
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
10 changes: 7 additions & 3 deletions boot/bootutil/src/bootutil_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ boot_read_unprotected_tlv_sizes(const struct flash_area *fap, uint16_t *tlv_size
#endif

#ifdef MCUBOOT_ENC_IMAGES
int
bool
boot_read_enc_key(const struct flash_area *fap, uint8_t slot, struct boot_status *bs)
{
uint32_t off;
Expand Down Expand Up @@ -274,19 +274,23 @@ boot_read_enc_key(const struct flash_area *fap, uint8_t slot, struct boot_status

if (i == read_size) {
BOOT_LOG_ERR("boot_read_enc_key: No key, read all 0xFF");
rc = 1;
return false;
}
#if MCUBOOT_SWAP_SAVE_ENCTLV
else {
/* read_dst is the same as bs->enctlv[slot], and serves as a source
* of the encrypted key.
*/
rc = boot_decrypt_key(bs->enctlv[slot], bs->enckey[slot]);
if (rc != 0) {
return false;
}
}
#endif
return true;
}

return rc;
return false;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions boot/bootutil/src/bootutil_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ bool boot_status_is_reset(const struct boot_status *bs);

#ifdef MCUBOOT_ENC_IMAGES
int boot_write_enc_keys(const struct flash_area *fap, const struct boot_status *bs);
int boot_read_enc_key(const struct flash_area *fap, uint8_t slot,
struct boot_status *bs);
bool boot_read_enc_key(const struct flash_area *fap, uint8_t slot,
struct boot_status *bs);
#endif

/**
Expand Down
3 changes: 1 addition & 2 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,7 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)

boot_enc_init(BOOT_CURR_ENC_SLOT(state, slot));

rc = boot_read_enc_key(fap, slot, bs);
if (rc) {
if (!boot_read_enc_key(fap, slot, bs)) {
BOOT_LOG_DBG("boot_swap_image: Failed loading key (%d, %d)",
image_index, slot);
} else {
Expand Down
Loading