Commit 3c44607e authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

bootutil: fix enckey issue when reverting

While doing a revert, the image encryption keys might be saved temporarily
in the scratch area; this is required in situations that we need to swap
one of the last sectors of the primary slot. When this happens, and the
device is interrupted just after restarting the revert swap, bootutil will
try to load the encrypted keys from the primary slot, and possibly use them
in reverted order (image in primary uses key of image in secondary and
vice-versa) which was saved in the test upgrade.

This fixes the issue by reverting the order used to check for the swap
metadata, with scratch being checked before the primary slot.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent e84f0eff
Loading
Loading
Loading
Loading
+1 −1
Changes for boot/bootutil/src/bootutil_misc.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -321,8 +321,8 @@ boot_find_status(int image_index, const struct flash_area **fap)
    uint32_t magic[BOOT_MAGIC_ARR_SZ];
    uint32_t off;
    uint8_t areas[2] = {
        FLASH_AREA_IMAGE_PRIMARY(image_index),
        FLASH_AREA_IMAGE_SCRATCH,
        FLASH_AREA_IMAGE_PRIMARY(image_index),
    };
    unsigned int i;
    int rc;