Commit Graph

2293 Commits

Author SHA1 Message Date
Thomas Altenbach 44a935ebcc docs: Update documentation regarding encrypted scratch area
When using swap using scratch, the decryption now happens when copying
from the scratch area to the primary slot, which means the image is
stored encrypted in the scratch area. This commit updates the
documentation accordingly.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach 08d2d94c14 bootutil: Keep image encrypted in scratch area
Currently, when swap using scratch is used with encrypted images,
MCUboot is decrypting the images during the copy from the secondary slot
to the scratch area. This means the scratch area contains plaintext
image data and therefore that the scratch area must be placed in the
MCU's internal flash memory. This commit makes the necessary changes to
perform the decryption when copying from the scratch area to the primary
slot instead, making possible to place the scratch area in an external
flash memory since the scratch area is now encrypted.

Note that BOOT_SWAP_SAVE_ENCTLV must be enabled if the scratch area is
placed in external flash memory.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach f515bb1c44 bootutil: Properly retrieve image headers after interrupted swap-scratch
For swap using scratch, the boot_read_image_header routine, responsible
for reading the image headers, was always looking for the primary and
secondary image's headers at the beginning of respectively the primary
and secondary slots, regardless of the current boot status.

This means if during a swap-scratch upgrade a reset happens after the
sector containing the image header in the primary or secondary slot has
been erased, invalid image headers were read since at that time the
location of the headers has changed.

Currently, this doesn't seem to cause any issue because the swap-scratch
algorithm is implemented in such a way the content of the headers is no
more necessary when the headers are erased. However, to be able to
decrypt the secondary image when copied to the primary slot instead of
when copied to the scratch area, properly reading the secondary image's
header is required even after it has been erased from the secondary
slot.

To that end, the boot_read_image_header is modified to determine from
the boot status the current location of the image headers and to always
read the actual header, no matter the current state of the upgrade
process.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Jamie McCrae fb2cf0ec3d docs: release-notes: Add note on fixed nordic boards
Adds a note that building for these boards has been fixed

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae 8980799219 boot: zephyr: Fix build for nrf9160dk
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae 2f5a7f4721 boot: zephyr: Fix build for thingy53
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae c9e4ab8b24 boot: zephyr: Fix build for thingy52
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
David Brown c06f7bb367 Revert "boot: Add MCUBOOT_HW_KEY support for image encryption"
This reverts commit 0fa46270c0.

This breaks:

    samples/synchronization/sample.kernel.synchronization on
    b_u585i_iot02a/stm32u585xx/ns error

as this TF-M configuration uses its own keys.  This change is an API
change that needs to be coordinated with TF-M changes.

Before this revert, compiling this test results in:

    .../encrypted.c:447: undefined reference to
    `boot_enc_retrieve_private_key`

Signed-off-by: David Brown <david.brown@linaro.org>
2024-07-09 09:19:43 -06:00
David Brown 1d79ef35ee boot: Fix ASN.1 for mbedtls >= 3.1
In Mbed TLS 3.1, the private fields in the ASN.1 structure were made private.
This breaks code that accesses these private macros.

Fix this by changing the ASN.1 specific code to use a new field accessor
`ASN1_CONTEXT_MEMBER` that will be conditionally defined based on the version of
Mbed TLS that is present.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-28 10:04:35 -06:00
Thomas Altenbach 86acda9ed4 ext: fiat: Use user-defined assert macro
The libc assert macro was used in curve25519.c even if the user provided
its own definition of the assert macro for MCUboot through
mcuboot_assert.h. This commit fixes this issue.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-06-26 16:52:20 -06:00
David Brown a706317769 sim: Increase jmpbuf size
Increase the size of the jmpbuf to accomodate other architectures.
Unfortunately, the size of this is not available in the libc crate.
Increase this so encompass any platforms we wish to support, including
aarch64 on both Linux and MacOS.

Increasing an array beyond 32 means there is no default offered, so
implement this manually.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown d6a5a7344f sim: Fix resolver warning from cargo
Cargo prints a warning about conflicting resolvers being used.  Fix this
by explicitly setting the resolver in the project file.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 847548a9ac sim: Put "C" on externs
Many of these extern functions are missing the "C". It doesn't seem to matter on
any of our targets, but this does make the code more correct, and might be a
problem in the future.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 1b1d495338 FIH: Disable FIH labels on Apple targets
The symbols injected here cause some kind of poor interaction with the linker on
MacOS, which results in most of the code becoming hopelessly corrupt.  For now,
just disable these symbols on this target.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 9cc8dac569 sim: Put AreaDesc in an Rc
Since there are references to this struct passed to C code, put it into an Rc so
that it won't move around when the data is moved.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 5d155132dc sim: Don't take address of movable struct
This struct was having addresses taken of fields within it, and then being
returned.  It is platform-specific whether this causes a move.  It seems to be
working on x86_64, but causes a segfault on aarch64.  Box the struct so that it
isn't moved after being initialized.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
Thomas Altenbach 9ae634f3bf bootutil: Fix signed/unsigned comparison in boot_read_enc_key
When MCUBOOT_SWAP_SAVE_ENCTLV is enabled, a comparison between a signed
and an unsigned integer is made in boot_read_enc_key. This might cause a
warning to be emitted at compile-time.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-06-20 17:54:01 -03:00
David Vincze 8be24f87e3 docs: Replace Slack channel links with Discord
Replace Slack channel links with MCUboot Discord channel
as the discussions have moved there.

Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: I132279574e674408dffc9ed377d216775a54fd56
2024-06-14 15:31:51 +02:00
Rustam Ismayilov 533fef2ad7 imgtool: Update version.py to take command line arguments
Main method printed hardcoded versions, update to take argument
to enable the possibility of testing version strings by invoking
the command through command line.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: If75769ef223944865313ed95336e859ebef85fd6
2024-06-14 13:56:40 +02:00
Rustam Ismayilov 316a139c1c imgtool: dumpinfo improvements
Fix trailer info dumping reads pad characters as values for status
Refactor printing styled texts and frames
Use isinstance() for type checking
Fold notice text depending on line length
Refactoring some parts for readability
Fix additional linting issues

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I741562bb70b18407bdd32e9c7391048faf6394c6
2024-06-14 13:56:40 +02:00
Rustam Ismayilov f3a5702879 imgtool: Various dumpinfo fixes
Add support for dumping images with custom tlv
Fix uninitialized access to some variables
Fix trailer magic detection
Fix some linting issues (parenthesis, indentation, spacing)

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I5b6e1dfa74606e2645a258065dd045cc8c7052c5
2024-06-14 13:56:40 +02:00
Rustam Ismayilov d16a613f6d imgtool: Assert "measurement value" is last in boot_record.py
'Measurement Value' added the 'properties' list initially,
rather than adding it separately later.
Added an assertion to ensure 'Measurement Value' remains as
the last item in the 'properties' list

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I106059c6c903c3d560477d5114d866f48590ad7e
2024-06-14 13:56:40 +02:00
Rustam Ismayilov 36f8bf3085 imgtool: Fix verify command for edcsa-p384 signed images
Fixed hash algorithm defaults to SHA256 in case no key provided.
Verification improved by adding check for key - tlv mismatch,
VerifyResult.KEY_MISMATCH added to indicate this case.
Multiple styling fixes and import optimisation, exception handling.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I61a588de5b39678707c0179f4edaa411ceb67c8e
2024-06-14 13:56:40 +02:00
Rustam Ismayilov 2712f74312 imgtool: Add missing requirements to requirements.txt file
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I9c84e544b466c0e041bb947fb4dd3e01b0d38ae5
2024-06-14 13:56:40 +02:00
Dinesh Kumar K 03171ffdc1 docs: Add release note snippet on MCUBOOT_HW_KEY for image encryption
Signed-off-by: Dinesh Kumar K <dinesh@linumiz.com>
2024-06-12 15:17:54 -06:00
Dinesh Kumar K 0fa46270c0 boot: Add MCUBOOT_HW_KEY support for image encryption
Currently encryption supports only private key embed
in mcuboot itself. To support MCUBOOT_HW_KEY for image
encryption boot_retrieve_private_key() hook is added.

This hook helps retrieving private key from trusted
sources like OTP, TPM.

Signed-off-by: Dinesh Kumar K <dinesh@linumiz.com>
2024-06-12 15:17:54 -06:00
David Vincze 92ad926ecc docs: Add release note snippet for imgtool testing
Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: I69ee2da7637363f5a50b9ef3aa3f0aaf5301714a
2024-06-04 09:51:43 +02:00
Mahesh Mahadevan 45d379e715 zephyr: boards: Add files needed for NXP FRDM MCXN947 QSPI variant
1. set BOOT_MAX_IMG_SECTORS value for frmd_mcxn947_qspi. W25Q64 flash on the board
   is very large (8MB), so we must increase the number of max sectors when
   targeting this board with MCUboot.
2. Set the zephyr,flash chosen node to point to internal flash as this board
   supports booting from internal flash only.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-05-24 06:45:03 +01:00
dependabot[bot] 2dcbabcb2c build(deps): bump rexml from 3.2.6 to 3.2.8 in /docs
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.6 to 3.2.8.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.6...v3.2.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-23 19:59:45 +02:00
Jerzy Kasenberg 29f9540db8 mynewt: Igore swap_scratch.c for single application slot
swap_scratch.c requires definition of SLOT1, in single application
slot build it's not needed and file would not be used anyway so
now it is removed from mynewt build

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2024-05-23 18:09:36 +02:00
dependabot[bot] f08ace635a build(deps): bump nokogiri from 1.16.2 to 1.16.5 in /docs
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.2 to 1.16.5.
- [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.16.2...v1.16.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-23 18:08:32 +02:00
Denis Mingulov 3113df8f9f imgtool: initial sanity test
An initial sanity test for imgtool is added, checks
different commands for key operations (keygen, getpriv,
getpub and getpubhash).

Also very basic test for sign / verify is added.

Some tests are disabled (marked as 'xfail') due to
the missing implementation.

Signed-off-by: Denis Mingulov <denis@mingulov.com>
2024-05-23 14:39:17 +02:00
Denis Mingulov a4cb878cae imgtool: Fixed missing dependency to 'pyyaml' (for dumpinfo)
imgtool's dumpinfo depends to pyyaml package, so add it to
requirements.

Signed-off-by: Denis Mingulov <denis@mingulov.com>
2024-05-23 14:39:17 +02:00
Denis Mingulov faf2dd1f6a imgtool: fixed keys/general.py to pass existing unittests
keys.KeyClass._emit is able to use 'file' parameter not as a file
but some object (not only sys.stdout but io.StringIO, like by
tests).

Fixed all explicit checks for sys.stdio usage in favor of
io.TextIOBase, also improve a single unit test to cover
also all the changed methods.

Signed-off-by: Denis Mingulov <denis@mingulov.com>
2024-05-23 14:39:17 +02:00
Denis Mingulov 12026047bd ci: add imgtool test to workflows
Add imgtool test call to workflows, use pytest and
publish artifacts with test results.

Also enable test run on 'pull_request', but limit
the previous default imgtool_run.sh run ('environment' job)
to run on 'push' event only (the same behaviour as before).

Signed-off-by: Denis Mingulov <denis@mingulov.com>
2024-05-23 14:39:17 +02:00
Marek Matej 898a1ca64a boot: zephyr: add ESP32-C6 support
Update the list of SoCs to support the ESP32-C6.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2024-05-21 16:52:51 +02:00
Marek Matej 018dc01d48 boot/zephyr: use socs conf
Use socs folder to configure Espressif targets.
Remove all boards confs which was created by copying other boards.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2024-05-13 04:25:17 -03:00
David Brown 9c99326b97 Preps for 2.1.0 release
Update version information for 2.1.0 release.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-05-09 08:03:52 -06:00
Tomi Fontanilles d4394c2f9b mbedtls config: fix too early check_config.h includes
check_config.h was included manually by custom configuration files.
This caused compilation errors when updating MbedTLS to 3.6.0
because check_config.h was processed too early, before the whole
configuration is defined, effectively causing configuration check errors.

MbedTLS already takes care of including check_config.h at the right time.
Remove those erroneous manual check_config.h includes.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-04-25 11:05:54 +02:00
David Brown 78bfe750cd docs: Fold additional release notes
Add in a few additional release notes for the 2.1 release.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-24 09:18:54 -06:00
David Brown 9bbe0a0462 Preps for 2.1.0-rc1 release
Update release notes and version numbers for 2.1.0-rc1 release.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-24 09:18:54 -06:00
David Brown 36eeeef8c4 docs: Update release notes for HKDF fix
Add missing release notes from merged fix.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-24 09:18:54 -06:00
David Brown 8b1d5f0629 docs: add release notes for reset vector update
Add missing release notes for this change.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-24 09:18:54 -06:00
Thomas Altenbach 73315f7b51 bootutil: Fix memory leak in HKDF implementation
The bootutil_hmac_sha256_set_key routine performs some dynamic memory
allocations when mbedTLS is used. To properly free the allocated memory,
bootutil_hmac_sha256_drop must be called before reinitializing the HMAC
context using bootutil_hmac_sha256_init.  However, in the hkdf routine,
the HMAC context was freed only once even though it was initialized
multiple times.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-04-23 11:03:22 -06:00
Mahesh Mahadevan 453096b17d zephyr: arm: Update reading the flash image reset vector
This change uses the flash functions to read the applications
reset vector. This allow flexibility on which flash device the
application is programmed.
For e.g: MCUBoot can be programmed and running from Internal
Flash while Zephyr can be loaded from a different Flash device.
This change is made for ARM platform, it can be extended to
non-ARM platforms as well.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-04-23 10:32:09 -06:00
Jamie McCrae 02267cfdb5 docs: release-notes: Add note on Zephyr boot banner
Adds a note about the new Zephyr MCUboot boot banner feature

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-04-23 11:28:48 +01:00
Jamie McCrae 1496129235 boot: zephyr: Add optional MCUboot boot banner
Adds an optional MCUboot boot banner which displays the MCUboot
version and zephyr version

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-04-23 11:28:48 +01:00
Alex Tsamakos 7174dd2ba8 boot: zephyr: boards: actinius: enable multithreading in config
Adds config with multithreading enabled for all Actinius boards

Signed-off-by: Alex Tsamakos <alex@actinius.com>
2024-04-23 11:26:34 +01:00
David Brown d2e69bf720 docs: Release notes for ptest updates
Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-19 11:50:52 -06:00
David Brown 80704f874b sim: Allow slow tests to be skipped
The normal simulation test takes several hours to run on most machines. Allow a
few very slow tests to be skipped by setting the environment variable
`MCUBOOT_SKIP_SLOW_TESTS` to some value. For obvious reasons, this shouldn't be
done if these power failure simulation tests are needed.

With this change, on my desktop Linux machine, the test time with the skipping
goes from about 2 hours, to around 5 minutes.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-19 11:50:52 -06:00