Commit b63d9956 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Remove function that marks encr keys invalid

Just use existing zeroize function, which also takes care of zeroing out
the encryption key data.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent ea0de009
Loading
Loading
Loading
Loading
+0 −1
Changes for boot/bootutil/include/bootutil/enc_key.h: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ int boot_enc_load(struct enc_key_data *enc_state, int image_index,
        uint8_t *enckey);
bool boot_enc_valid(struct enc_key_data *enc_state, int image_index,
        const struct flash_area *fap);
void boot_enc_mark_keys_invalid(struct enc_key_data *enc_state);
void boot_encrypt(struct enc_key_data *enc_state, int image_index,
        const struct flash_area *fap, uint32_t off, uint32_t sz,
        uint32_t blk_off, uint8_t *buf);
+2 −12
Changes for boot/bootutil/src/encrypted.c: 2 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -320,17 +320,6 @@ boot_enc_valid(struct enc_key_data *enc_state, int image_index,
    return enc_state[rc].valid;
}

void
boot_enc_mark_keys_invalid(struct enc_key_data *enc_state)
{
    size_t slot;

    for (slot = 0; slot < BOOT_NUM_SLOTS; ++slot) {
        memset(&enc_state[slot].aes, 0, sizeof(enc_state[slot].aes));
        enc_state[slot].valid = 0;
    }
}

void
boot_encrypt(struct enc_key_data *enc_state, int image_index,
        const struct flash_area *fap, uint32_t off, uint32_t sz,
@@ -382,7 +371,8 @@ boot_encrypt(struct enc_key_data *enc_state, int image_index,
/**
 * Clears encrypted state after use.
 */
void boot_enc_zeroize(struct enc_key_data *enc_state)
void
boot_enc_zeroize(struct enc_key_data *enc_state)
{
    memset(enc_state, 0, sizeof(struct enc_key_data) * BOOT_NUM_SLOTS);
}
+2 −2
Changes for boot/bootutil/src/loader.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2284,7 +2284,7 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
         * another images). Therefore, mark them as invalid to force their reload
         * by boot_enc_load().
         */
        boot_enc_mark_keys_invalid(state->enc);
        boot_enc_zeroize(state->enc);
#endif

        image_index = BOOT_CURR_IMG(state);
@@ -2330,7 +2330,7 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
         * another images). Therefore, mark them as invalid to force their reload
         * by boot_enc_load().
         */
        boot_enc_mark_keys_invalid(state->enc);
        boot_enc_zeroize(state->enc);
#endif /* MCUBOOT_ENC_IMAGES */

        /* Indicate that swap is not aborted */