Skip to content
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

boot: zephyr: Add warning on default key file usage #2087

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
endif()
message("MCUBoot bootloader key file: ${KEY_FILE}")

set(mcuboot_default_signature_files
${MCUBOOT_DIR}/root-ec-p256-pkcs8.pem
${MCUBOOT_DIR}/root-ec-p384.pem
${MCUBOOT_DIR}/root-ec-p384-pkcs8.pem
${MCUBOOT_DIR}/root-ed25519.pem
${MCUBOOT_DIR}/root-rsa-2048.pem
${MCUBOOT_DIR}/root-rsa-3072.pem
${MCUBOOT_DIR}/root-ec-p256.pem
)
Comment on lines +296 to +304
Copy link
Collaborator

Choose a reason for hiding this comment

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

And we will get that one lazy person that just overwrites the key, instead of changing path, and keeps on getting the warning.
Shouldn't we rather hardcode hash of all keys, that we provide with mcuboot, here and compare it to whatever gets assigned as key file and then issue the warning?

Also, in the future, we should rename the keys to something like "NON-PORDUCTION-root-blah.pem" keys...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately not, the actual MD5 of files depends on your git settings, on linux systems they will probably all match, those might differ on mac whereby the line ending was \r instead of \n, and on windows where the line ending is \r\n it will fail


# Emit a warning if using one of the default MCUboot key files
if(${KEY_FILE} IN_LIST mcuboot_default_signature_files)
message(WARNING "WARNING: Using default MCUboot signing key file, this file is for debug use only and is not secure!")
endif()

set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
add_custom_command(
OUTPUT ${GENERATED_PUBKEY}
Expand Down Expand Up @@ -333,6 +348,20 @@ if(CONFIG_BOOT_ENCRYPTION_KEY_FILE AND NOT CONFIG_BOOT_ENCRYPTION_KEY_FILE STREQ
endif()
message("MCUBoot bootloader encryption key file: ${KEY_FILE}")

# Emit a warning if using one of the default MCUboot key files
set(mcuboot_default_encryption_files
${MCUBOOT_DIR}/enc-ec256-priv.pem
${MCUBOOT_DIR}/enc-ec256-pub.pem
${MCUBOOT_DIR}/enc-rsa2048-priv.pem
${MCUBOOT_DIR}/enc-rsa2048-pub.pem
${MCUBOOT_DIR}/enc-x25519-priv.pem
${MCUBOOT_DIR}/enc-x25519-pub.pem
)

if(${KEY_FILE} IN_LIST mcuboot_default_encryption_files)
message(WARNING "WARNING: Using default MCUboot encryption key file, this file is for debug use only and is not secure!")
endif()

set(GENERATED_ENCKEY ${ZEPHYR_BINARY_DIR}/autogen-enckey.c)
add_custom_command(
OUTPUT ${GENERATED_ENCKEY}
Expand Down
Loading