Commit Graph

2079 Commits

Author SHA1 Message Date
Antonio de Angelis 2878eb4e32 bootutil/crypto: Fix local variable name typo for PSA Crypto key parse
Fix a local variable name typo in parse public key function
for the PSA Crypto abstraction, and at the same time put the
memcmp under ifdefs.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: Icadca37e4207ad703a853ea720a053aa2ba76411
2023-05-03 08:40:22 +02:00
Keith Packard ec2ac82c32 boot/zephyr: switch main return type to 'int'
Adapt to Zephyr's change requiring main to return int.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-05-02 15:24:20 +01:00
David Vincze 7f982b0f6f Revert "imgtool: Add backwards compatibility for ECDSA"
This reverts commit 78135ee6eb
as bba5a711483447d7eee2531b65bd1c07c81746c9 made it unnecessary.

Change-Id: Idee755f05c17502599aaa947826e9a7feb08b4a7
Signed-off-by: David Vincze <david.vincze@arm.com>
2023-04-28 11:40:31 +02:00
David Vincze 4395b80976 boot: Restore and extend the usage of 0x22 TLV (ECDSA256)
The IMAGE_TLV_ECDSA256 TLV has been put out of use by
commit 63d2346da4.
This commit reverts this part of that patch and at the
same time it extends the usage of this TLV to cover all types
of curves (replacing the newly introduced 0x25 TLV type)
while retaining its value (0x22) for backward compatibility.
Rename IMAGE_TLV_ECDSA256 to IMAGE_TLV_ECDSA_SIG.

Change-Id: I904f292db775c38f26a5e9a87c5f414165efc173
Signed-off-by: David Vincze <david.vincze@arm.com>
2023-04-28 11:40:31 +02:00
Marek Matej 6769344276 boot: zephyr: esp32: zephyr port
Add support for ESP32xx targets to build
as Zephyr application.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-04-27 20:30:35 -03:00
Fabio Utzig 86dba4d6c1 ci: update toml dependency
Switch from toml to tomllib when supported, Python 3.11+, and fallback to
using tomli instead of toml otherwise.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2023-04-27 12:35:12 -03:00
Antonio de Angelis 0a1ef37263 bootutil/crypto: Move BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE into common
BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE is a universal define
that should be moved into a common area of the header
instead of repeating it for every abstraction that needs it

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I21e7511218d0dafac8b7337715932c6564d7c3a1
2023-04-26 13:57:53 +02:00
Antonio de Angelis 88e4aed18f bootutil/crypto: Fix review comments on the ecdsa layer
Fixes in the ecdsa.h abstraction layer:
* Align indentation of parameters to the opening bracket of the function
* Remove inline in some of the bigger functions of the PSA Crypto abstraction
* Fix the prototype of ecdsa_verify for the PSA Crypto abstraction

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I28e1be83bc1a16fdf8b796f89c002528b1bd7791
2023-04-26 13:57:53 +02:00
Antonio de Angelis 10529d3032 bootutil/crypto: Have a single ECDSA verification module
Remove the generic ECDSA verification module and keep the
existing one, just renaming it image_ecdsa.c. Make sure
that the abstraction layer is generically called ecdsa.h
and the abstraction names are not P256 specific.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I6f78cfc1b1c2851cdad67efa91c6cb49498187bb
2023-04-26 13:57:53 +02:00
Antonio de Angelis 966ac81804 bootutil/crypto: Extend ECDSA to support P384 curve
Extend the ecdsa abstraction layer to support P384 curves
during parsing the public key and the signature.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I05e9b27b1809352a6115184ef16c95dc8b6d2a40
2023-04-26 13:57:53 +02:00
Antonio de Angelis 25390ad58c bootutil/crypto: Have a single ECDSA abstraction file
To keep a single ECDSA abstraction to support both existing
modes and PSA Crypto APIs, merge the contents of ecdsa.h
into ecdsa_p256.h

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I08b4a42d87c491badfee3ec4579bd2a23a80602d
2023-04-26 13:57:53 +02:00
Antonio de Angelis cf36d670c9 bootutil/crypto: Add license disclaimer to ecdsa_p256.h
The ecdsa abstraction layer header does not have a license header.
Add it in preparation for the merge with ecdsa.h

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: Ibb906c7f6bb3b50387e4816e1a95b31d3c8b515f
2023-04-26 13:57:53 +02:00
Antonio de Angelis 557451d28d bootutil/crypto: Add a generic signature validation module for ECDSA
Add a dedicated signature validation module for generic ECDSA signatures,
and a corresponding cryptographic abstraction backend based on PSA Crypto
APIs. This signature verification backend is enabled by defining the
option MCUBOOT_SIGN_ECDSA

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I47da70629da0a5681ec7c4dcceed875a997b071b
2023-04-26 13:57:53 +02:00
Roland Mikhel c725cee102 docs: Add release note snippet for ECDSA TLV
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I6837467e985af644f124ae8a9cceb0f68736ec84
2023-04-26 13:27:44 +02:00
Roland Mikhel 30978516d3 sim: Remove curve specific ECDSA TLVs
Remove those TLVs that are tied to a specific curve and modify the
code to use the new generic ECDSA TLV.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Iffe9052580c99e75118cf5df4286e0e9a2af4a8c
2023-04-26 13:27:44 +02:00
Roland Mikhel 6205c10fea sim: Add generic ECDSA TLV support
Add support to the simulator so that
the generic ECDSA TLV can be tested.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I3322ed829d150ff35abfaaa8ecf69ab7017bd7cf
2023-04-26 13:27:44 +02:00
Roland Mikhel 78135ee6eb imgtool: Add backwards compatibility for ECDSA
Add backwards compatibility to the imgtool to support
the old curve specific TLVs. Currently only ECDSA256 needs this.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I275894ebc713ea8adcaab4198b036c41233b11e8
2023-04-26 13:27:44 +02:00
Roland Mikhel 5704174c12 imgtool: Add generic ECDSA TLV support
Update imgtool to support the new
generic ECDSA TLV and the ECDSA
p384 curve type with sha-384

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I9b1887610cc5d0e7cde90f47999fcdf3500ef51c
2023-04-26 13:27:44 +02:00
Roland Mikhel 63d2346da4 bootutil: Remove curve specific ECDSA TLVs
Remove those TLVs that are tied to a specific curve and update
the image validation logic to look for the new generic TLV

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I924f2742424bc255fbed1b0941648baa88f60147
2023-04-26 13:27:44 +02:00
Roland Mikhel b08e77e0f3 bootutil: Create new generic ECDSA TLV
Create a new generic ECDSA TLV type that can be used
to store any signatures irrespective of the curve type.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I2aeb885251fd25e23f5430328b8cc64b8cc8d7be
2023-04-26 13:27:44 +02:00
Jeppe Odgaard 1558e7ab0a boot: zephyr: remove stm32 watchdog defines
The stm32 defines is somewhat redundant due to the generic watchdog
defines which uses the watchdog0 alias. Therefore they are removed in
this commit.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-26 13:15:51 +02:00
Jeppe Odgaard 4420bb663f boot: zephyr: setup watchdog
The Zephyr watchdog API defines a setup function. This function needs to
be executed before the watchdog is functional in some cases. This commit
adds MCUBOOT_WATCHDOG_SETUP when using the generic watchdog0 alias
otherwise it is an empty define.

Fixes https://github.com/mcu-tools/mcuboot/issues/1659

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-26 13:15:51 +02:00
Jamie McCrae 7a8a8f6794 docs: Add release note change for zcbor version
Adds a release note file indicating that zcbor files have been
updated to version 0.7.0

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-26 13:11:56 +02:00
Jamie McCrae 393af79ef1 boot_serial: Update zcbor files from zcbor 0.7.0
Updates zcbor files from version 0.7.0, needed for size variable
support.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-26 13:11:56 +02:00
Szymon Janc 6021d60393 mynewt: Update repository.yml with latest release
newt tool uses repository.yml from main branch.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2023-04-26 13:08:37 +02:00
dependabot[bot] b4a0d1b7a5 build(deps): bump nokogiri from 1.14.2 to 1.14.3 in /docs
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.2 to 1.14.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.14.2...v1.14.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 13:07:19 +02:00
Marek Pieta a95a41b3e1 boot: bootutil: loader: Let image version comparison use build number
Change allows using build number in image version comparison.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-04-25 12:04:27 +02:00
David Brown 3cbb79c25f boot: Fix DOS line endings
This file made it into the repo with DOS line endings. Fix this to match
everything else.

Signed-off-by: David Brown <david.brown@linaro.org>
2023-04-24 11:47:14 +02:00
Jamie McCrae f7d8660e85 boot_serial: Fix include paths for zephyr builds
Fixes include paths for zephyr builds to use the system zcbor_*
files rather than the local files.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 11:34:28 +02:00
Roland Mikhel c7835371a0 bootutil: Add FIH for ED25519 sig verification
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: If43ff9a7c3d755a32b310230e05d01235868392d
2023-04-24 08:36:14 +02:00
Roland Mikhel 186ac88583 bootutil: Fix FIH return type for EC256
For bootutil_verify_sig the declaration expects fih_ret
as the return type not fih_int, this has now been fixed.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: If5943758bebdbf401b1eb387de334fa19a3a7781
2023-04-24 08:36:14 +02:00
Dominik Ermel 5397c13d24 zephyr: serial_recovery: Fix broken CDC device selection
When using CDC only and CONFIG_SERIAL is not enabled in Zephyr,
but there is chosen zephyr,mcumgr-uart, the chosen
takes precedence over CDC and directs MCUmgr to that uart.
This causes two issues: first the CDC is ignored if chosen exists,
and makes build fail because drivers are not built.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-19 14:38:02 +02:00
Dominik Ermel 918da26a67 bootutil: Provide boot_set_next function
Commit provides boot_set_next function that allows to set next
application slot to boot by flash area object pointer, describing
the slot.
The function also takes active which is supposed to indicate whether
running application is being set for next boot and confirm parameter
that allows to confirm the image.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-04-14 15:51:27 +02:00
Jamie McCrae 6902abba27 zephyr: Create common boot serial enter function
Creates a common function for enterial serial recovery mode.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-13 20:07:55 +02:00
Jamie McCrae 35941feacd boot: zephyr: Add pin reset serial recovery entrance method
Adds an optional method for entering serial recovery mode by use
of a pin reset.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-13 20:07:55 +02:00
Jamie McCrae fd79db3a9f zephyr: boot: serial_recovery: Add no application entrace method
Adds a bootloader serial recovery entrance mode that will allow
recovering a module if there is no application that can be booted.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-13 20:07:55 +02:00
Jamie McCrae b3e3ce39f3 boot: zephyr: serial_recovery: Add boot mode enter ability
Adds an optional entrance method for mcuboot's serial recovery by
using Zephyr's boot mode retention system, this allows for an
application to set the retained data and reboot into the bootloader.
This also adds a selection of how to enter serial recovery mode, it
no longer requires having a GPIO entrance mechanism. Entrance
methods have been added under a new Kconfig menu.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-13 20:07:55 +02:00
Jamie McCrae e5c57dd134 boot_serial: Only have build number if non-zero
Only returns the build number in versions responses if the value
is non-zero.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-13 19:25:42 +02:00
Roland Mikhel 8a3b32ce6c bootutil: Refactor signature verification
The current ECDSA-P256 implementation code contains
a lot of code that is tied to a specific condition being met.
The aim of this commit is to cleanup the main verification
logic to be unified between crypto backends and move the
conditional code where it is relevant.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I06b050a263b2b88b08708defb6aa1001a08ba2ae
2023-04-12 17:58:42 +02:00
David Vincze 4e07d8f75f docs: add release note snippet for dumpinfo
Change-Id: I8f3041bff9a842edc53029ba993e21e56adde86c
Signed-off-by: David Vincze <david.vincze@arm.com>
2023-04-12 10:01:14 +02:00
David Vincze ca56135b6b imgtool: Add 'dumpinfo' command
Add new 'dumpinfo' command that can parse a signed image and
print all the available information from the header, TLV area and
trailer in the form of a basic "image map".

The --outfile option can be used to write the image information
to an output file in serialised YAML format.

Change-Id: I99e61078946b02eefd4ac2e682583476d53e8d4f
Signed-off-by: David Vincze <david.vincze@arm.com>
2023-04-12 10:01:14 +02:00
Roland Mikhel c050573dd9 docs: Add release note for p224 removal
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I63d8b38e1d7a15fdc20e36daf768ffd26ac6469c
2023-04-11 07:05:38 +02:00
Roland Mikhel 75c7c310dc sim: Remove P224 curve references
MCUBoot dropped P224 curve support as
there is little interest in using it.
The simulator threw an error as P224
was never supported, this was removed.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I96011e9b00dbc3a6f7590db365a5f480d85394e1
2023-04-11 07:05:38 +02:00
Roland Mikhel 3d92a6cb59 imgtool: Remove P224 curve references
Imgtool does not provide support for P224
curve, just a placeholder function that
says it's not currently implemented.
This has now been removed as P224 support
had been removed from the boot code too.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I477d8e273085f38f35eaf9a591584f3e937d748d
2023-04-11 07:05:38 +02:00
Roland Mikhel 206b914852 bootutil: Remove P224 curve
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I49fad7ede202de4e3c710bf4aa1df195a310b037
2023-04-11 07:05:38 +02:00
David Brown a97f009d20 Update readme for next dev version
Signed-off-by: David Brown <david.brown@linaro.org>
2023-04-06 07:43:42 -06:00
David Brown 23d28832f0 Update to version 1.10.0
Signed-off-by: David Brown <david.brown@linaro.org>
2023-04-06 07:38:04 -06:00
Andrzej Puzdrowski cdf9de094e doc/readme-zephyr: document the serial recovery
Added description on serial recovery mode features and
its configuration.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Anna Kielar <anna.kielar@nordicsemi.no>
2023-03-24 13:11:30 +01:00
Andrzej Puzdrowski 4e9d86aa08 doc: Added serial recovery documentation
Added description on what is the serial recovery protocol
in general.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Anna Kielar <anna.kielar@nordicsemi.no>

fix
2023-03-24 13:11:30 +01:00
Jamie McCrae 827118f2e4 boot: serial_recovery: Add image hash support
Adds support for outputting the image hash TLV in serial recovery
mode, which is needed to comply with the img_mgmt MCUmgr group
requirements.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-23 10:25:38 +01:00