-
Notifications
You must be signed in to change notification settings - Fork 761
Allow bypasing signature hash key matching #2310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
29e6bcb
to
2825070
Compare
@@ -325,6 +325,18 @@ endif | |||
|
|||
endchoice | |||
|
|||
config BOOT_BYPASS_KEY_MATCH | |||
bool "Do not match TLV key hash against built in key" | |||
depends on !BOOT_SIGNATURE_TYPE_NONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends on !hw key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an option to skip matching the TLV key hash against built-in public keys when only one key is compiled in, reducing code size.
- Adds
MCUBOOT_BYPASS_KEY_MATCH
config flag inmcuboot_config.h
- Wraps
bootutil_find_key
and its call inimage_validate.c
with#if !defined(MCUBOOT_BYPASS_KEY_MATCH)
- Defaults
key_id
to 0 when bypassing key match
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
boot/zephyr/include/mcuboot_config/mcuboot_config.h | Added MCUBOOT_BYPASS_KEY_MATCH option |
boot/bootutil/src/image_validate.c | Conditionalized key-hash matching and lookup logic |
Files not reviewed (1)
- boot/zephyr/Kconfig: Language not supported
Comments suppressed due to low confidence (2)
boot/bootutil/src/image_validate.c:274
- There are no tests covering the bypass logic. Please add unit tests for both paths (with and without
MCUBOOT_BYPASS_KEY_MATCH
) to verify correct key lookup and fallback behavior.
#if !defined(MCUBOOT_BYPASS_KEY_MATCH)
boot/bootutil/src/image_validate.c:641
- When bypassing the key‐match, we unconditionally set
key_id = 0
. Consider adding a compile-time or runtime assertion to ensure exactly one built-in key is present when this option is enabled to avoid inadvertently using the wrong key.
key_id = 0;
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]>
Add Zephyr support for MCUBOOT_BYPASS_KEY_MATCH Signed-off-by: Dominik Ermel <[email protected]>
ac3dd9a
to
4420345
Compare
Currently MCUboot checks whether key hash in TLV matches any known builtin public keys.
When only one key in compiled in, most cases, then this match is pointless as image signature verification will just verify validity of the key anyway.
The PR adds MCUBOOT_BYPASS_KEY_MATCH option that allows to turn of the key matching and slightly reduces the binary size.