Skip to content

Commit bd7423d

Browse files
committed
boot: zephyr: Add warning on default key file usage
Adds a warning if one of the default signing/encryption key files is used Signed-off-by: Jamie McCrae <[email protected]>
1 parent 9331c92 commit bd7423d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,21 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
299299
endif()
300300
message("MCUBoot bootloader key file: ${KEY_FILE}")
301301

302+
set(mcuboot_default_signature_files
303+
${MCUBOOT_DIR}/root-ec-p256-pkcs8.pem
304+
${MCUBOOT_DIR}/root-ec-p384.pem
305+
${MCUBOOT_DIR}/root-ec-p384-pkcs8.pem
306+
${MCUBOOT_DIR}/root-ed25519.pem
307+
${MCUBOOT_DIR}/root-rsa-2048.pem
308+
${MCUBOOT_DIR}/root-rsa-3072.pem
309+
${MCUBOOT_DIR}/root-ec-p256.pem
310+
)
311+
312+
# Emit a warning if using one of the default MCUboot key files
313+
if(${KEY_FILE} IN_LIST mcuboot_default_signature_files)
314+
message(WARNING "WARNING: Using default MCUboot signing key file, this file is for debug use only and is not secure!")
315+
endif()
316+
302317
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
303318
add_custom_command(
304319
OUTPUT ${GENERATED_PUBKEY}
@@ -339,6 +354,20 @@ if(CONFIG_BOOT_ENCRYPTION_KEY_FILE AND NOT CONFIG_BOOT_ENCRYPTION_KEY_FILE STREQ
339354
endif()
340355
message("MCUBoot bootloader encryption key file: ${KEY_FILE}")
341356

357+
# Emit a warning if using one of the default MCUboot key files
358+
set(mcuboot_default_encryption_files
359+
${MCUBOOT_DIR}/enc-ec256-priv.pem
360+
${MCUBOOT_DIR}/enc-ec256-pub.pem
361+
${MCUBOOT_DIR}/enc-rsa2048-priv.pem
362+
${MCUBOOT_DIR}/enc-rsa2048-pub.pem
363+
${MCUBOOT_DIR}/enc-x25519-priv.pem
364+
${MCUBOOT_DIR}/enc-x25519-pub.pem
365+
)
366+
367+
if(${KEY_FILE} IN_LIST mcuboot_default_encryption_files)
368+
message(WARNING "WARNING: Using default MCUboot encryption key file, this file is for debug use only and is not secure!")
369+
endif()
370+
342371
set(GENERATED_ENCKEY ${ZEPHYR_BINARY_DIR}/autogen-enckey.c)
343372
add_custom_command(
344373
OUTPUT ${GENERATED_ENCKEY}

0 commit comments

Comments
 (0)