sysbuild with encryption fails as soon as SB_CONFIG_BOOT_ENCRYPTION_ALG_AES_256=y is set

Hi

For a product, I'd like to have (well it's a requirement) the firmware update encrypted.
So I set the following in sysbuild.conf:
...
SB_CONFIG_BOOT_ENCRYPTION=y
SB_CONFIG_BOOT_ENCRYPTION_ALG_AES_256=y
SB_CONFIG_BOOT_ENCRYPTION_KEY_FILE="PATH_TO/encryption-key.pem"
...

As I'like to use AES-256, I also set CONFIG_PSA_CRYPTO=y in mcuboot.conf as tinycrypt does only support AES-128.
Unfortunately the generating the signed_by_mcuboot_and_b0_ipc_radio.hex file now fiails with:

Usage: imgtool.py sign [OPTIONS] INFILE OUTFILE
Try 'imgtool.py sign --help' for help.

Error: Can not set rom_fixed and load_addr at the same time

surprisingly, using SB_CONFIG_BOOT_ENCRYPTION_ALG_AES_128=y works

I use NCS-3.4.0

  • doing this change in the sdk-nrf repo:


    diff --git a/cmake/sysbuild/b0_mcuboot_signing.cmake b/cmake/sysbuild/b0_mcuboot_signing.cmake
    index 438caf840..72b2715be 100644
    --- a/cmake/sysbuild/b0_mcuboot_signing.cmake
    +++ b/cmake/sysbuild/b0_mcuboot_signing.cmake
    @@ -102,7 +102,7 @@ function(ncs_secure_boot_mcuboot_sign application bin_files signed_targets prefi
    if(NOT "${keyfile_enc}" STREQUAL "")
    if(SB_CONFIG_BOOT_ENCRYPTION_ALG_AES_256)
    # Note: this overrides the default behavior of using AES-128
    - set(imgtool_extra ${imgtool_extra} --encrypt-keylen 256 --load-addr ${slot_address})
    + set(imgtool_extra ${imgtool_extra} --encrypt-keylen 256)
    endif()

    # Signature type determines key exchange scheme; ED25519 here means

    makes it compile. don't now yet if it also works as intended

  • Hi,

    Thanks for the update. Your patch looks to be valid, at least for your chip, but I suspect it may potentially have side effects for nRF targets using the ram loader, so I will add this to our internal bug tracker to allow our developers to review the fix.

    --rom-fixed is the argument I would expect to be used in this case. Excerpt from the SDK v3.4.0 release notes:

    Updated image matching to use the explicit image address when :kconfig:option:`CONFIG_MCUBOOT_CHECK_HEADER_LOAD_ADDRESS` is enabled.
    MCUboot now uses the ``ih_load_address`` field of the image header instead of the reset vector address, allowing it to match an incoming image to the correct partition even when the image is encrypted.
    The new method is enabled by default when MCUboot is built with DTS partitioning.
    Firmware must be signed with the ``imgtool.py sign --rom-fixed <partition_address>`` parameter, which is handled by the |NCS| signing procedures.

    Best regards,

    Vidar

  • Hi Vidar

    Thanks. Will you update this ticket in case of any interesting news from you internal bug tracker?

  • Of course, I will try to update here as soon as there has been any progress on the ticket. Thank you for reporting this in the first place.

Related