Skip to content

Commit d391e70

Browse files
committed
bootutil: Fix encryption context de initialization in boot_state_clear
Call boot_enc_deinit before memset to 0. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent 99ed9fa commit d391e70

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

boot/bootutil/src/bootutil_misc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,5 +647,18 @@ const struct image_max_size *boot_get_max_app_size(void)
647647
*/
648648
void boot_state_clear(struct boot_loader_state *state)
649649
{
650+
#if defined(MCUBOOT_ENC_IMAGES)
651+
int image;
652+
int slot;
653+
654+
for (image = 0; image < BOOT_IMAGE_NUMBER; ++image) {
655+
for (slot = 0; slot < BOOT_NUM_SLOTS; ++slot) {
656+
/* Not using boot_enc_zeorize here, as it is redundant
657+
* to the memset below that clears entire boot_loader_state.
658+
*/
659+
boot_enc_drop(&state->enc[image][slot]);
660+
}
661+
}
662+
#endif
650663
memset(state, 0, sizeof(struct boot_loader_state));
651664
}

0 commit comments

Comments
 (0)