Commit Graph

2079 Commits

Author SHA1 Message Date
Almir Okato 26ed3f448f espressif: preferred use of a installed esptool
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 10:03:18 -03:00
Roland Mikhel 018b77032c imgtool: Fix getpriv error return with private key
This commit fixes a bug with the getpriv command using
ECDSA keys.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I66c1365a855e97199921ac136a18e26988bce508
2023-07-24 09:33:50 +02:00
Jamie McCrae 9fad4c1f16 boot: boot_serial: Fix wrong cbor type for confirm
Fixes the wrong variable type being used for the confirm element.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 17:00:09 +01:00
Jerzy Kasenberg 52cac94c0e mynewt: Make sysinit() call configurable
In same cases (loging, hash, crypto) main function called
newt tool generated sysinit() function to create
uart device and crypto.

Now user can specify that sysinit should be called for
other cases if needed. This can be useful if some other
package should be included in the build and it has
package initialization function.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:39:05 -03:00
Jerzy Kasenberg 8581168331 boot: mynewt: Respect minimum write size
For MCUs with restriction on minimum write size (STM32H7)
unaligned writes resulted in flash write errors preventing
any sort of update.

Now MCUBOOT_BOOT_MAX_ALIGN can be set accordingly to value
that flash driver uses.
For alignment <= 8 default value provided by mcuboot config
is still used.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:38:11 -03:00
Jerzy Kasenberg 7abfe4fa51 boot: mynewt: Add build version comparison
For downgrade prevention it's possible to use build number
for grater control.
So far only Zephyr has this option in Kconfig now
option is also available in mynewt.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:37:22 -03:00
Jerzy Kasenberg e486b533c1 boot: mynewt: add support for the mcumgr echo command in serial boot mode
This allows user to enable echo for mcumgr command in serial boot.
Code was enabled in zephyr only so far.
Now mynewt build can also have this feature if enabled.

No code changes just option in mynewt build to enable existing
mcuboot feature.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:36:07 -03:00
Michal Lenc daabd6a8db nuttx: add support for swap without scratch area
Definition of MCUBOOT_SWAP_USING_MOVE in case swap without scratch area
is configured in NuttX was missing from mcuboot_config.h file.

Also necessary function flash_area_sector_from_off() is defined and
declared in order to support swap without scratch.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-07-08 08:02:31 -03:00
Piotr Dymacz 6a8746d7ac boot_serial: fix image number handle in image upload request
According to the SMP protocol documentation [1], 'image number' value
in 'image upload request' is optional and can be included only in packet
with 'off' (data offset) set to '0' (first packet in upload request).

In one of recent changes (commit 'cb07e888691d'), initialization of the
'img_num' variable was removed which, in extreme case (no image number
provided in upload request), results in use of its uninitialized value
in flash_area_open() call which then might lead to request abort.

This fixes above regression and also makes MCUboot implementation of the
'image upload request' aligned with Zephyr documentation of the protocol
by considering image number only from first (off == 0) 'image upload
request' SMP packet. In addition, 'image number' value is set to '0' if
the request doesn't provide this field.

[1] docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_1.html

Fixes: cb07e88869 ("boot_serial: Replace cbor auto-generated code with zcbor functions")
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-07-05 16:59:19 -06:00
Piotr Dymacz f2cb55027c boot_serial: fix misuse of 'matched' param from zcbor_map_decode_bulk()
The 'matched' param in zcbor_map_decode_bulk() function is 'pointer to
the counter of matched keys', not length of payload buffer.

Fixes: fac2cabe98 ("boot_serial: Add image state set/get")
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-07-05 16:58:09 -06:00
Jamie McCrae 82feb9a4c5 boot_serial: Fix showing images that are not valid
Fixes an issue which was introduced in commit
fac2cabe98 which would show all
images, including those with invalid headers in the output of
images being listed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-05 16:57:12 -06:00
Roland Mikhel 23fdb0d20b sim: Revert changes to cap values
This commits reverts the changes made to cap values in 75c7c31.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Ibbbf66e89d059ef4e4b45218a8a39778c849f21b
2023-06-30 18:02:20 +02:00
Roland Mikhel c5c2b4d7a7 bootutil: Revert changes to cap values
This commit reverts the changes to the cap values made in 206b914.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Ie47c3f253409932b960f4fc12e3b722b000b3093
2023-06-30 18:02:20 +02:00
Roland Mikhel 7ecffd4e26 ci: Add new variations for ram-load
Adds new test combinations to the CI to
test the ram-load feature more thoroughly.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I56d6f74af55ed078947c092726160b123d36f67f
2023-06-29 13:21:30 +02:00
Roland Mikhel 6945bb6cb4 sim: Add new ram-load test cases
Adds new test cases to various ram-load related logic.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I3a0ca951b2c720be4e6fe2ed0e5d1830fcfb240c
2023-06-29 13:21:30 +02:00
Roland Mikhel 820e9ccef5 sim: fix encryption for ram-load related tests
If ram-load is being used with encryption and
the higher version image is loaded from the primary slot the
verification will fail as the image is always non-encrypted
and will produce an invalid hash. This fix puts encrypted images
into both slots to prevent this issue.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I4ac9f332434a95d140c5572096b8a9161db2d217
2023-06-29 13:21:30 +02:00
Matthew Dalzell 34d5a6915f Tests: Enable psa-crypto-api feature
This patch enables psa-crypto-api feature

Signed-off-by: Matthew Dalzell <matthew.dalzell@arm.com>
Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
2023-06-28 15:24:06 +02:00
Antonio de Angelis 65eb35c2c7 sim: Initialize PSA Crypto subsystem based on psa-crypto-api feature
If the psa-crypto-api feature is defined, the simulator will
initialize the PSA Crypto API exactly once. It needs also to
enable the test external RNG as the assumption is that the
PSA subsystem is configured to use MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG

Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Signed-off-by: Matthew Dalzell <matthew.dalzell@arm.com>
Change-Id: Id02727b8673867ecf1e4fbbdfa3c4b6d6f98f8df
2023-06-28 15:24:06 +02:00
Roland Mikhel 9a82ecae5c ci: add test case for hw-rollback-protection
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: If636d9179c6f06d4bf7452b8eb4f07d3829cf2d7
2023-06-27 14:42:34 +02:00
Roland Mikhel 82670c71f6 bootutil: Add capability to test hw-rollback-prot
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I3dee0baf27b8cae78b87135ea7447556b06fdefd
2023-06-27 14:42:34 +02:00
Roland Mikhel d6703520d1 sim: Add hw-rollback-protection feature
This commit adds simulator support to test the
hw-rollback-protection feature which is using
nv-counters. In the simulator they are stored in Rust
to prevent any race conditions from happening due to
the parallel execution of the tests.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I445fc50615ed1f0c06e5933b16811c24d9d302fc
2023-06-27 14:42:34 +02:00
Roland Mikhel 61962b94f3 bootutil: fix FIH int conversion for security_cnt
Currently there's a compile error when building MCUboot
with HW_ROLLBACK_PROT due to a comparison
when decoding the security_cnt fih_int value. In the security_cnt.h
it is stated that this value must be between 0 and UINT32_MAX
so this cast would not cause any undefined behaviour.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Iee158a31955ff43b73e67a0c08e7a086077b9eb5
2023-06-27 14:42:34 +02:00
Dominik Ermel e6e4801ce2 zephyr/boot_serial_extension: Fix zcbor header path
Include directory path is now set by CMake.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-21 13:48:05 +02:00
David Brown 2c1c5d145a docs: Update security to use github reporting
Hackerone hasn't turned out to be particularly useful.  Fortunately, github now
has a mechanism to directly report security vulnerabilities within the project's
pages.  Update the docs to show this as the preferred vulnerability reporting
mechanism.

Signed-off-by: David Brown <david.brown@linaro.org>
2023-06-15 08:29:08 -06:00
Antonio de Angelis a5db515161 bootutil/crypto: SHA256 abort function return state
Similarly to what has been done for the init function, also
the abort function should return a state in case the caller
needs to implement some error recovery procedure, or even
just for debugging reasons.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I5b8bc8fc2da57cfbc6ddea3f7e95ed7a7ae8e5a9
2023-06-09 14:35:28 +02:00
Antonio de Angelis 0361ad3d42 bootutil/crypto: SHA256 init functions should return a status
SHA-256 init functions should return the status of the init
instead of being void. This would allow the callers to implement
proper error recovery, otherwise on error the SHA-256 operation
will enter an undefined behaviour.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I162ceb8e6dc90dc3c6b83c8a85fbd17b41c0b5d6
2023-06-09 14:35:28 +02:00
Antonio de Angelis f92a2193f4 bootutil/crypto: Fix minor typos in comments for RSA modules
A couple of typos in comments for the newly added RSA modules
need to be assessed.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: Ia06529adb81215fad796895d7b412b35717b6d65
2023-06-09 14:35:28 +02:00
Antonio de Angelis 48547008dd bootutil: Add image_index to additional logging messages
image_index should be added to additional prints as noted
during the original PR review.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I2e456f05ee4ccb372aeab564f7f388bc2fd564e5
2023-06-09 14:35:28 +02:00
Antonio de Angelis 2f85b7e994 bootutil/crypto: Fix the common.h header
The crypto/common.h header checks for MBEDTLS_VERSION_NUMBER
value but it needs to include mbedtls/version.h first
otherwise it won't return a reliable check.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: Ice12fe26bb24fd98c09c4adfe001b5274cee555c
2023-06-09 14:35:28 +02:00
Antonio de Angelis c321a7056b bootutil/crypto: Add a crypto backend for SHA256 based on PSA Crypto APIs
This patch adds a dedicated crypto backend based on PSA Crypto APIs to
implement SHA-256 operations. The enabling of the backend is controlled
by the MCUBOOT_USE_PSA_CRYPTO define.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I6065f7fccb483eda54f0190457f33aa89c6a0796
2023-06-09 14:35:28 +02:00
Antonio de Angelis 02bf072d2d bootutil/crypto: Refactor the RSA signature verification and encryption
This patch refactor the RSA operations done by the signature verification
module and by the encrypted images decryption module. Previous solution is
tightly coupled with Mbed TLS, while this patch provides an abstraction of
the RSA functionalities in a dedicated crypto abstraction header, crypto/rsa.h
that supports both Mbed TLS APIs and PSA Crypto APIs. In case of PSA Crypto,
the verification scheme is directly provided by the crypto backend hence it
simplifies the operations done in the image verification module.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I973bc3374b62eee2d7717c2368bce7611d37a0c8
2023-06-09 14:35:28 +02:00
Antonio de Angelis ba5fb1cec4 bootutil: Add image_index to common prints
Add the image_index to common prints that get repeated in the
print out logging so that it helps differentiate the information
conveyed by the print.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I560b0f76d879e4bd5f82ef65e845fe5c80585c97
2023-06-09 14:35:28 +02:00
Jamie McCrae 74c4d1c52f zephyr: Restore default log level of info
The default log level has changed to "default", restore it back
to info.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-05 11:04:42 +01:00
Jamie McCrae 8a8a24199a zephyr: single_loader: Fix typo
Fixes a typo with a variable name.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-06-05 09:45:27 +01:00
Jamie McCrae a6aef32619 docs: release: Add note on zephyr release
Adds details on updating the zephyr version file for releases.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-25 14:20:28 -06:00
Jamie McCrae d6a7741124 zephyr: Add VERSION file
Adds a file which contains the current MCUboot code version, which
can be used by Zephyr builds.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-25 14:20:28 -06:00
Jamie McCrae abb18a31a3 docs: Add note on addition of image state/image set state commands
Adds a note that both of these functions are now (optionally)
supported in serial recovery mode.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-25 14:19:20 -06:00
Jamie McCrae fac2cabe98 boot_serial: Add image state set/get
Adds optional image state set/get functionality to serial recovery
mode which allows for listing image states and marking images to
be tested or as confirmed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-25 14:19:20 -06:00
Jamie McCrae 52605e5051 release-notes: Add note on zcbor encoder fix
Adds a note that the zcbor encoder buffer size has been fixed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-25 14:17:20 -06:00
Daniel DeGrasse c393b54246 boot: boot_serial: fix usage of zcbor_new_encode_state API
Fix usage of zcbor_new_encode_state API, to correctly pass the payload
length. The previous usage was passing a pointer to the end of the
payload, which resulted in the ZCBOR structure being initialized with
an invalid `payload_end` field. On some platforms, this breaks MCUBoot
serial recovery, as the ZCBOR structures required to send response data
are invalid and can no longer be populated with response data.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-05-25 14:17:20 -06:00
Jamie McCrae 9380135afb ci: zephyr: Update Zephyr image and SDK version
Updates to use the zephyr docker image version 0.26.4 which
includes the zephyr SDK 0.16.1, and resolves build issues with
recent zephyr changes.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-23 11:47:03 +01:00
Marcin Niestroj 9ced459b09 boot: zephyr: fix s/junping/jumping/ typo
Fix typo in Kconfig help text by s/junping/jumping/.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-05-22 07:41:43 +01:00
Jeppe Odgaard 1dbe0cf0a5 boot: zephyr: Use mcuboot-led0 in MCUBOOT_INDICATION_LED help section
bootloader-led0 is deprecated. Replace with mcuboot-led0 in
MCUBOOT_INDICATION_LED help.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-05-22 07:41:23 +01:00
Dominik Ermel 256bc37aad bootutil: Fixing memset not beeing called
Memset could have been out optimized by compiler and also
not called in error path.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-17 12:18:07 +02:00
Daniel Mangum eb7658e84c zephyr: fix link to Zephyr application docs
Updates a broken link to Zephyr application docs in the hello-world
example.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-05-15 13:47:26 +01:00
Jamie McCrae 0038f3967b boot: zcbor: Move copy script
Moves and updates the copy script to the zcbor folder

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:22:51 +02:00
Jamie McCrae b388829846 docs: Add not on CDDL code being replaced
Adds a note that the CDDL function code has been replaced with
zcbor function calls.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:22:51 +02:00
Jamie McCrae cb07e88869 boot_serial: Replace cbor auto-generated code with zcbor functions
Replaces the auto-generated decoding/encoding files with inline code
for encoding/decoding cbor data structures, this adds the benefit of
allowing the elements to be in any order and reduces code size. To
accommodate this, zcbor_bulk has been imported from Zephyr.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 10:22:51 +02:00
Jamie McCrae db6ba46244 boot_serial: Unify zcbor include paths
Moves zcbor files to a subdirectory and replaces differing
include path styles to be unified.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-12 10:33:28 +01:00
Jerzy Kasenberg 7a4b192690 ci: mynewt: Download nrfx from separate repository
Mynewt used to have copy of nrfx.
Now nrfx is taken from original repository and since some CI
targets want to build for NRF MCUs nrfx repository nees to be
downloaded.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-05-10 20:49:59 -03:00