Skip to content

Commit 5be772e

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 <dominik.ermel@nordicsemi.no>
1 parent 0319e91 commit 5be772e

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
@@ -278,6 +278,8 @@ bootutil_img_hash(struct boot_loader_state *state,
278278
# define KEY_BUF_SIZE (SIG_BUF_SIZE + 24)
279279
#endif /* !MCUBOOT_HW_KEY */
280280

281+
#if !defined(MCUBOOT_BYPASS_KEY_MATCH)
282+
/* Find functions are only needed when key is checked first */
281283
#if !defined(MCUBOOT_HW_KEY)
282284
static int
283285
bootutil_find_key(uint8_t *keyhash, uint8_t keyhash_len)
@@ -347,6 +349,18 @@ bootutil_find_key(uint8_t image_index, uint8_t *key, uint16_t key_len)
347349
#endif /* !MCUBOOT_HW_KEY */
348350
#endif /* !MCUBOOT_BUILTIN_KEY */
349351
#endif /* EXPECTED_SIG_TLV */
352+
#else /* !MCUBOOT_BYPASS_KEY_MATCH */
353+
static inline int
354+
bootutil_find_key(uint8_t image_index, uint8_t *key, uint16_t key_len)
355+
{
356+
(void)image_index;
357+
(void)key;
358+
(void)key_len;
359+
360+
/* There is only one key, so it always matches */
361+
return 0;
362+
}
363+
#endif /* !MCUBOOT_BYPASS_KEY_MATCH */
350364

351365
/**
352366
* Reads the value of an image's security counter.

0 commit comments

Comments
 (0)