Skip to content

Commit 6d943d6

Browse files
committed
bootutil: Support for MCUBOOT_BYPASS_KEY_MATCH
This MCUboot configuration option turns off matching of public key hash, taken from image TLV, against built in public key. Such verification is not needed when there is only one key built in as the signature verification will reject image signed with unknown key anyway. Enabling the option allows to slightly reduce MCUboot binary size by removing the code that does the key matching. Boot time improvement is not really significant. Signed-off-by: Dominik Ermel <[email protected]>
1 parent e2e372f commit 6d943d6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

boot/bootutil/src/image_validate.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ bootutil_img_hash(struct boot_loader_state *state,
280280
# define KEY_BUF_SIZE (SIG_BUF_SIZE + 24)
281281
#endif /* !MCUBOOT_HW_KEY */
282282

283+
#if !defined(MCUBOOT_BYPASS_KEY_MATCH)
284+
/* Find functions are only needed when key is checked first */
283285
#if !defined(MCUBOOT_HW_KEY)
284286
static int
285287
bootutil_find_key(uint8_t *keyhash, uint8_t keyhash_len)
@@ -349,6 +351,18 @@ bootutil_find_key(uint8_t image_index, uint8_t *key, uint16_t key_len)
349351
#endif /* !MCUBOOT_HW_KEY */
350352
#endif /* !MCUBOOT_BUILTIN_KEY */
351353
#endif /* EXPECTED_SIG_TLV */
354+
#else /* !MCUBOOT_BYPASS_KEY_MATCH */
355+
static inline int
356+
bootutil_find_key(uint8_t image_index, uint8_t *key, uint16_t key_len)
357+
{
358+
(void)image_index;
359+
(void)key;
360+
(void)key_len;
361+
362+
/* There is only one key, so it always matches */
363+
return 0;
364+
}
365+
#endif /* !MCUBOOT_BYPASS_KEY_MATCH */
352366

353367
/**
354368
* Reads the value of an image's security counter.

0 commit comments

Comments
 (0)