Commit 956311d2 authored by Dominik Ermel's avatar Dominik Ermel Committed by Jamie
Browse files

boot: Make boot_enc_valid take slot instead of image index

There is no point for boot_enc_valid to take image index and
flash area and use these to figure out slot number.

Signed-off-by: default avatarDominik Ermel <dominik.ermel@nordicsemi.no>
parent 4619da56
Loading
Loading
Loading
Loading
+1 −2
Changes for boot/bootutil/include/bootutil/enc_key.h: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -69,8 +69,7 @@ int boot_enc_set_key(struct enc_key_data *enc_state, uint8_t slot,
int boot_enc_load(struct enc_key_data *enc_state, int slot,
        const struct image_header *hdr, const struct flash_area *fap,
        struct boot_status *bs);
bool boot_enc_valid(struct enc_key_data *enc_state, int image_index,
        const struct flash_area *fap);
bool boot_enc_valid(struct enc_key_data *enc_state, int slot);
void boot_encrypt(struct enc_key_data *enc_state, int slot,
        uint32_t off, uint32_t sz, uint32_t blk_off, uint8_t *buf);
void boot_enc_zeroize(struct enc_key_data *enc_state);
+2 −12
Changes for boot/bootutil/src/encrypted.c: 2 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -682,19 +682,9 @@ boot_enc_load(struct enc_key_data *enc_state, int slot,
}

bool
boot_enc_valid(struct enc_key_data *enc_state, int image_index,
        const struct flash_area *fap)
boot_enc_valid(struct enc_key_data *enc_state, int slot)
{
    int rc;

    rc = flash_area_id_to_multi_image_slot(image_index, flash_area_get_id(fap));
    if (rc < 0) {
        /* can't get proper slot number - skip encryption, */
        /* postpone the error for a upper layer */
        return false;
    }

    return enc_state[rc].valid;
    return enc_state[slot].valid;
}

void
+1 −1
Changes for boot/bootutil/src/image_validate.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ bootutil_img_hash(struct enc_key_data *enc_state, int image_index,
#ifdef MCUBOOT_ENC_IMAGES
    /* Encrypted images only exist in the secondary slot */
    if (MUST_DECRYPT(fap, image_index, hdr) &&
            !boot_enc_valid(enc_state, image_index, fap)) {
            !boot_enc_valid(enc_state, 1)) {
        return -1;
    }
#endif