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
8 changes: 4 additions & 4 deletions boot/boot_serial/src/boot_serial_encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ boot_image_validate_encrypted(struct boot_loader_state *state,
int rc;

if (MUST_DECRYPT(fa_p, BOOT_CURR_IMG(state), hdr)) {
rc = boot_enc_load(state, 1, hdr, fa_p, bs);
rc = boot_enc_load(state, BOOT_SLOT_SECONDARY, hdr, fa_p, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
rc = boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs);
rc = boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_SECONDARY, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
Expand Down Expand Up @@ -235,11 +235,11 @@ decrypt_image_inplace(const struct flash_area *fa_p,
#endif
memset(&boot_data, 0, sizeof(struct boot_loader_state));
/* Load the encryption keys into cache */
rc = boot_enc_load(state, 0, hdr, fa_p, bs);
rc = boot_enc_load(state, BOOT_SLOT_PRIMARY, hdr, fa_p, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 0, bs)) {
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_PRIMARY, bs)) {
FIH_RET(fih_rc);
}
}
Expand Down
18 changes: 9 additions & 9 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,11 @@ boot_image_check(struct boot_loader_state *state, struct image_header *hdr,
*/
#if defined(MCUBOOT_ENC_IMAGES) && !defined(MCUBOOT_RAM_LOAD)
if (MUST_DECRYPT(fap, BOOT_CURR_IMG(state), hdr)) {
rc = boot_enc_load(state, 1, hdr, fap, bs);
rc = boot_enc_load(state, BOOT_SLOT_SECONDARY, hdr, fap, bs);
if (rc < 0) {
FIH_RET(fih_rc);
}
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs)) {
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_SECONDARY, bs)) {
FIH_RET(fih_rc);
}
}
Expand Down Expand Up @@ -1547,7 +1547,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
if (rc < 0) {
return BOOT_EBADIMAGE;
}
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs)) {
if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_SECONDARY, bs)) {
return BOOT_EBADIMAGE;
}
}
Expand Down Expand Up @@ -1665,17 +1665,17 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
#ifdef MCUBOOT_ENC_IMAGES
if (IS_ENCRYPTED(hdr)) {
fap = BOOT_IMG_AREA(state, BOOT_SLOT_PRIMARY);
rc = boot_enc_load(state, 0, hdr, fap, bs);
rc = boot_enc_load(state, BOOT_SLOT_PRIMARY, hdr, fap, bs);
assert(rc >= 0);

if (rc == 0) {
rc = boot_enc_set_key(BOOT_CURR_ENC(state), 0, bs);
rc = boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_PRIMARY, bs);
assert(rc == 0);
} else {
rc = 0;
}
} else {
memset(bs->enckey[0], 0xff, BOOT_ENC_KEY_ALIGN_SIZE);
memset(bs->enckey[BOOT_SLOT_PRIMARY], 0xff, BOOT_ENC_KEY_ALIGN_SIZE);
}
#endif

Expand All @@ -1689,17 +1689,17 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
hdr = boot_img_hdr(state, BOOT_SLOT_SECONDARY);
if (IS_ENCRYPTED(hdr)) {
fap = BOOT_IMG_AREA(state, BOOT_SLOT_SECONDARY);
rc = boot_enc_load(state, 1, hdr, fap, bs);
rc = boot_enc_load(state, BOOT_SLOT_SECONDARY, hdr, fap, bs);
assert(rc >= 0);

if (rc == 0) {
rc = boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs);
rc = boot_enc_set_key(BOOT_CURR_ENC(state), BOOT_SLOT_SECONDARY, bs);
assert(rc == 0);
} else {
rc = 0;
}
} else {
memset(bs->enckey[1], 0xff, BOOT_ENC_KEY_ALIGN_SIZE);
memset(bs->enckey[BOOT_SLOT_SECONDARY], 0xff, BOOT_ENC_KEY_ALIGN_SIZE);
}
#endif

Expand Down
Loading