mcu-tools / mcuboot

Secure boot for 32-bit Microcontrollers!
Apache License 2.0
1.31k stars 666 forks source link

PureEdDSA and support for calculating SHA directly on device #2080

Open de-nordic opened 1 day ago

de-nordic commented 1 day ago

Three commits:

  1. Adds support for sha512 when TinyCrypt is used
  2. adds PureEdDSA where image signature is calculated over image directly, rather than hash
  3. adds support for calculating sha directly on storage, rather than loading chunks to memory

Note that mentioned below Kconfig options have proper MCUBOOT_ identifiers in code, but it is easier to communicate change by using them in examples.

Both commits provide support only on devices that are within address space. There is possibility to extend both commits to work with external devices via features like XIP, where external device can be mapped to internal address space, but this is not approached here.

The PureEdDSA change adds TLV that marks the image as signed with Pure signature and logic in MCUboot that rejects images without the TLV, when expected by MCUboot. The change also slightly improves security of devices, specifically if the verification can be done by dedicated coprocessor.

Both solutions slightly improve performance as they cut on additional processing.

The PureEdDSA commit requires imgtool change: https://github.com/mcu-tools/mcuboot/pull/2063

Notes on stats:

Enabling the option CONFIG_MCUBOOT_HASH_STORAGE_DIRECTLY, that comes with second commit, reduces code by another ~50 bytes.

Enabling the CONFIG_BOOT_SIGNATURE_TYPE_PURE, provided by the third commit, shaves off additional ~150 bytes.

While SHA directly on device and in RAM works with the same image signed for specified sha, the PureEdDSA requires special signature processing via imgtool and lacks HASH TLV.

de-nordic commented 20 hours ago

@taltenbach FYI