Skip to content

Commit b88c8e1

Browse files
tejlmandcarlescufi
authored andcommitted
cmake: sysbuild: signing support
This commit introduces image signing by adding the possibility to specify algorithm and signing key for sysbuild images. It introduces Kconfig setting to specify signing algorithm and key file. It will default the signing key to the default key provided by MCUBoot if no key has been specified. When signing is enabling, the signature key will be passed to the application so the build system can sign the image as post build step. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 8408af6 commit b88c8e1

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

share/sysbuild/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ set(IMAGES)
3030
get_filename_component(APP_DIR ${APP_DIR} ABSOLUTE)
3131
get_filename_component(app_name ${APP_DIR} NAME)
3232

33+
# Propagate bootloader and signing settings from this system to the MCUboot and
34+
# application image build systems.
35+
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
36+
set(${app_name}_CONFIG_BOOTLOADER_MCUBOOT y CACHE STRING
37+
"MCUBOOT is enabled as bootloader" FORCE
38+
)
39+
set(${app_name}_CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
40+
\"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}\" CACHE STRING
41+
"Signature key file for signing" FORCE
42+
)
43+
44+
# Set corresponding values in mcuboot
45+
set(mcuboot_CONFIG_BOOT_SIGNATURE_TYPE_${SB_CONFIG_SIGNATURE_TYPE} y CACHE STRING
46+
"MCUBOOT signature type" FORCE
47+
)
48+
set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE
49+
\"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}\" CACHE STRING
50+
"Signature key file for signing" FORCE
51+
)
52+
else()
53+
set(${app_name}_CONFIG_BOOTLOADER_MCUBOOT n CACHE STRING
54+
"MCUBOOT is disabled as bootloader" FORCE
55+
)
56+
endif()
57+
3358
# This adds the primary application to the build.
3459
ExternalZephyrProject_Add(
3560
APPLICATION ${app_name}

share/sysbuild/bootloader/Kconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,41 @@ config BOOTLOADER_MCUBOOT
2727
Include MCUboot (Zephyr port) as the bootloader to use
2828

2929
endchoice
30+
31+
if BOOTLOADER_MCUBOOT
32+
33+
config SIGNATURE_TYPE
34+
string
35+
default NONE if BOOT_SIGNATURE_TYPE_NONE
36+
default RSA if BOOT_SIGNATURE_TYPE_RSA
37+
default ECDSA_P256 if BOOT_SIGNATURE_TYPE_ECDSA_P256
38+
default ED25519 if BOOT_SIGNATURE_TYPE_ED25519
39+
40+
choice
41+
prompt "Signature type"
42+
default BOOT_SIGNATURE_TYPE_RSA
43+
44+
config BOOT_SIGNATURE_TYPE_NONE
45+
bool "No signature; use only hash check"
46+
47+
config BOOT_SIGNATURE_TYPE_RSA
48+
bool "RSA signatures"
49+
50+
config BOOT_SIGNATURE_TYPE_ECDSA_P256
51+
bool "Elliptic curve digital signatures with curve P-256"
52+
53+
config BOOT_SIGNATURE_TYPE_ED25519
54+
bool "Edwards curve digital signatures using ed25519"
55+
56+
endchoice
57+
58+
config BOOT_SIGNATURE_KEY_FILE
59+
string "PEM key file"
60+
default "$(ZEPHYR_MCUBOOT_MODULE_DIR)/root-ec-p256.pem" if BOOT_SIGNATURE_TYPE_ECDSA_P256
61+
default "$(ZEPHYR_MCUBOOT_MODULE_DIR)/root-ed25519.pem" if BOOT_SIGNATURE_TYPE_ED25519
62+
default "$(ZEPHYR_MCUBOOT_MODULE_DIR)/root-rsa-2048.pem" if BOOT_SIGNATURE_TYPE_RSA
63+
default ""
64+
help
65+
Absolute path to key file to use with MCUBoot.
66+
67+
endif

0 commit comments

Comments
 (0)