Skip to content

Commit

Permalink
scripts: hid_configurator: Support pure ED25519 signature
Browse files Browse the repository at this point in the history
Change adds support for pure ED25519 signature (used by nRF54L-based
devices that enable MCUboot hardware cryptography). imgtool from MCUboot
upstream repository does not support this configuration, a dedicated
imgtool version from sdk-mcuboot repository must be used.

Jira: NCSDK-30745

Signed-off-by: Marek Pieta <[email protected]>
Signed-off-by: Pekka Niskanen <[email protected]>
Signed-off-by: Divya Pillai <[email protected]>
  • Loading branch information
MarekPieta authored and carlescufi committed Dec 4, 2024
1 parent 3d32533 commit 6f444f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
23 changes: 23 additions & 0 deletions scripts/hid_configurator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ Complete the following steps:
py -3 -m pip install -r requirements.txt
py -3 -m pip install .
.. note::
Currently, the ``imgtool`` from PyPI does not support pure ED25519 signature (used by nRF54L-based devices that enable MCUboot hardware cryptography).
This may result in rejecting proper DFU images (``DFU image is invalid``).
``imgtool`` supporting pure ED25519 signature can be installed from the ``sdk-mcuboot`` repository (:file:`ncs/bootloader/mcuboot/scripts` directory of the |NCS|).
Run the following commands in the source directory to install ``imgtool`` and the required dependencies:

.. parsed-literal::
:class: highlight
py -3 -m pip install -r requirements.txt
py -3 -m pip install .
Debian/Ubuntu/Linux Mint
========================

Expand Down Expand Up @@ -151,6 +163,17 @@ Complete the following steps:
pip3 install --user -r requirements.txt
pip3 install --user .
.. note::
Currently, the ``imgtool`` from PyPI does not support pure ED25519 signature (used by nRF54L-based devices that enable MCUboot hardware cryptography).
This may result in rejecting proper DFU images (``DFU image is invalid``).
``imgtool`` supporting pure ED25519 signature can be installed from the ``sdk-mcuboot`` repository (:file:`ncs/bootloader/mcuboot/scripts` directory of the |NCS|).
Run the following commands in the source directory to install ``imgtool`` and the required dependencies:

.. parsed-literal::
:class: highlight
pip3 install --user -r requirements.txt
pip3 install --user .
Stopping fwupd daemon
=====================
Expand Down
16 changes: 14 additions & 2 deletions scripts/hid_configurator/modules/dfu.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ def b0_get_dfu_image_bootloader_var():


def mcuboot_common_is_dfu_file_correct(dfu_bin):
res, _, _ = imgtool.image.Image.verify(dfu_bin, None)
try:
res, _, _ = imgtool.image.Image.verify(dfu_bin, None)
except ValueError:
# `imgtool` from `sdk-mcuboot` repository is needed to support pure ED25519 signature.
# This `imgtool` package version modifies the `verify` function signature (the function
# returns one more value).
res, _, _, _ = imgtool.image.Image.verify(dfu_bin, None)

if res != imgtool.image.VerifyResult.OK:
print('DFU image is invalid')
Expand All @@ -219,7 +225,13 @@ def mcuboot_common_is_dfu_file_correct(dfu_bin):


def mcuboot_common_get_dfu_image_version(dfu_bin):
res, ver, _ = imgtool.image.Image.verify(dfu_bin, None)
try:
res, ver, _ = imgtool.image.Image.verify(dfu_bin, None)
except ValueError:
# `imgtool` from `sdk-mcuboot` repository is needed to support pure ED25519 signature.
# This `imgtool` package version modifies the `verify` function signature (the function
# returns one more value).
res, ver, _, _ = imgtool.image.Image.verify(dfu_bin, None)

if res != imgtool.image.VerifyResult.OK:
print('Image in file is invalid')
Expand Down

0 comments on commit 6f444f7

Please sign in to comment.