Skip to content

Commit 4b87c45

Browse files
committed
cmake: sysbuild: image_signing: Set encrypted flag in header
Enables setting the encrypted flag in the header when encryption is enabled for the initial image, this means that when it is swapped out to the secondary slot, it will be encrypted rather than being in plaintext Signed-off-by: Jamie McCrae <[email protected]>
1 parent a1b669b commit 4b87c45

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmake/sysbuild/image_signing.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,14 @@ function(zephyr_mcuboot_tasks)
233233
# add_custom_command() are run in order, so adding the 'west sign'
234234
# calls to the "extra_post_build_commands" property ensures they run
235235
# after the commands which generate the unsigned versions.
236-
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
237-
${imgtool_sign} ${imgtool_args} ${imgtool_directxip_hex_command} ${imgtool_hex_extra} ${unconfirmed_args})
236+
if("${keyfile_enc}" STREQUAL "")
237+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
238+
${imgtool_sign} ${imgtool_args} ${imgtool_directxip_hex_command} ${imgtool_hex_extra} ${unconfirmed_args})
239+
else()
240+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
241+
${imgtool_sign} ${imgtool_args} --encrypt "${keyfile_enc}" --clear
242+
${imgtool_directxip_hex_command} ${imgtool_hex_extra} ${unconfirmed_args})
238243

239-
if(NOT "${keyfile_enc}" STREQUAL "")
240244
set(unconfirmed_args ${input}.hex ${output}.encrypted.hex)
241245
list(APPEND byproducts ${output}.encrypted.hex)
242246
set(BYPRODUCT_KERNEL_SIGNED_ENCRYPTED_HEX_NAME "${output}.encrypted.hex"

0 commit comments

Comments
 (0)