Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions boot/bootutil/src/image_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ static const uint16_t allowed_unprot_tlvs[] = {
#include <ed25519-donna/ed25519.h>

#ifndef MCUBOOT_PRODUCTION_KEY
const uint8_t BOOTLOADER_KEY_M = 2;
const uint8_t BOOTLOADER_KEY_N = 3;
static const uint8_t * const BOOTLOADER_KEYS[] = {
/*** DEVEL/QA KEYS ***/
Expand Down Expand Up @@ -457,8 +456,18 @@ bootutil_img_validate(struct enc_key_data *enc_state, int image_index,
int sig0_idx = sigmask & (1 << 0) ? 0 : 1;
int sig1_idx = sigmask & (1 << 2) ? 2 : 1;

if (FIH_NOT_EQ(__builtin_popcount(sigmask), 2)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks okay, but I fixed the same thing in the PQ boardloader a bit differently - I think it's more readable.

see trezor/trezor-firmware@ce32830

rc = -1;
goto out;
}

if (FIH_NOT_EQ((sigmask & (~((1 << BOOTLOADER_KEY_N) - 1))), 0)){
rc = -1;
goto out;
}

// There must be two different signatures to verify
if (sig0_idx == sig1_idx) {
if (FIH_EQ(sig0_idx, sig1_idx)) {
rc = -1;
goto out;
} else {
Expand Down
Loading