Skip to content

Commit 028d80c

Browse files
committed
bootutil: Move boot_enc_init in boot_swap_image
Encryption context intialization can happen before we read the key. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent 497688b commit 028d80c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

boot/bootutil/src/loader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,9 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
17231723

17241724
#ifdef MCUBOOT_ENC_IMAGES
17251725
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
1726+
1727+
boot_enc_init(BOOT_CURR_ENC(state), slot);
1728+
17261729
rc = boot_read_enc_key(fap, slot, bs);
17271730
assert(rc == 0);
17281731

@@ -1732,8 +1735,6 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
17321735
}
17331736
}
17341737

1735-
boot_enc_init(BOOT_CURR_ENC(state), slot);
1736-
17371738
if (i != BOOT_ENC_KEY_SIZE) {
17381739
boot_enc_set_key(BOOT_CURR_ENC(state), slot, bs);
17391740
}

0 commit comments

Comments
 (0)