Commit Graph

166 Commits (master)

Author SHA1 Message Date
Daniele Lacamera 5f231a890c Fix: keep wolfBoot API declarations visible to app builds
c3f9717f guarded the success/trigger/sector-flag declarations behind
WOLFBOOT_FIXED_PARTITIONS, but wolfboot.h includes target.h only under
__WOLFBOOT, so test-apps (compiled without __WOLFBOOT) never saw the
macro and failed with implicit-declaration errors on imx95_m7, mcxa,
mcxw and mcxw-tz. Unguard the header declarations; keep the definitions
guarded and move wolfBoot_success out of the fixed-partition guard
since it only uses the partition-state API.
2026-09-16 18:31:59 +02:00
Daniele Lacamera c3f9717fb5 PR 892: address 3 Fenrir review findings
- libwolfboot.c: keep the partition state APIs (set/get_partition_state)
  available to CUSTOM_PARTITION_TRAILER / WOLFBOOT_NO_PARTITIONS builds;
  guard the fixed-partition APIs (sector flags, erase, trigger, success)
  behind WOLFBOOT_FIXED_PARTITIONS. Add the unit-custom-trailer-nopart
  compile target to lock in that configuration.
- unit-p1021-fcm-bytes.c: add program tests for status 0x81 (fail) and
  0x00 (write-protected), asserting no later page is programmed.
- unit-p1021-erase-advance.c: add an erase test for status 0x00
  (write-protected), asserting failure before advancing to the next block.
2026-09-16 17:19:16 +02:00
Daniele Lacamera cc7fec1ea2 PR 892: anti-rollback for CUSTOM_PARTITION_TRAILER targets
Add HAVE_PARTITION_TRAILERS macro (set when WOLFBOOT_FIXED_PARTITIONS or
CUSTOM_PARTITION_TRAILER is defined) and use it to gate the TESTING state
transition in update_ram.c. Previously the gate was WOLFBOOT_FIXED_PARTITIONS
only, so targets using custom partition trailers never transitioned from
UPDATING to TESTING, allowing rollback to older versions.

Add unit-update-ram-custom-trailer test covering the CUSTOM_PARTITION_TRAILER
path with mocked get/set_trailer_at callbacks.
2026-09-16 14:30:26 +02:00
Daniele Lacamera febf29ad61 pkcs11 store: batch sector commits to Store_Close
Every wolfPKCS11 field write flushed the payload sector and the header
sector to flash (2 erases + 2 programs of a full sector each), and the
token store re-serializes all objects per C_CreateObject/C_DestroyObject,
so those calls cost hundreds of sector erases and tens of seconds on
flash with slow erase times.

Cache modified sectors in RAM and commit them together when the store
window closes:

- sector cache sized to the worst-case span of one object plus the
  header sector (WOLFBOOT_PKCS11_STORE_CACHE_SECTORS), LRU eviction
  when exceeded
- header sector commits last, so a committed header is the atomic
  commit point of the batch: power failure during a flush leaves the
  flash in either the pre-batch or the post-batch state
- per-commit backup sector write preserved, keeping recovery of the
  sector in flight at failure time
- delete_object commits on return (durability contract, unit-tested)
- nodes table, bitmap, payload ids and the live object size
  (handle->size) are read from the cache when the sector is dirty

Measured on an STM32H5 with 8KB sectors, wolfPKCS11 in the secure
world: C_CreateObject 1.5s -> 0.15s, C_DestroyObject 1.3s -> 0.12s,
456 -> 40 sector erases per create, and the count no longer scales
with the number of objects in the token.

PKCS11_STORE_STATS (off by default) adds flash-activity counters and a
test-app bench to quantify store traffic: make PKCS11_STORE_STATS=1.
2026-09-10 09:40:02 +02:00
David Garske 25cdd5a0d7 c2000: add wolfBoot TI C28x (TMS320F28P550SJ) secure-boot XIP port 2026-08-25 00:01:33 +02:00
Brett Nicholas 25aa151f0b add asymmetric partition sizing for monolithic updates 2026-08-19 17:47:48 +02:00
Daniele Lacamera 3a3f66e1b4 F-9720: describe IMG_STATE_TESTING as the post-swap boot-confirmation state
The comment labeled IMG_STATE_TESTING as an 'ELF loading state', but
the constant is wolfBoot's general dual-bank confirm/rollback marker:
it is set on the BOOT partition after every swap (update_flash.c,
update_flash_hwswap.c, update_ram.c - none ELF-specific) and cleared
by wolfBoot_success(); if still present at the next boot it triggers
a rollback. A maintainer trusting the old comment could have treated
the state as inert on non-ELF targets and disabled the anti-brick
path.

Reword to the accurate description already used in
docs/flash_partitions.md, keeping the note that it only lives on the
boot partition so it cannot conflict with IMAGE_STATE_UPDATING.

Comment-only change; no code or behavior changes.
2026-08-18 05:01:22 +02:00
David Garske c8faa5adc2 Authenticate raw device tree via signed HDR_DEVICE_TREE_DIGEST TLV (Fenrir #7998) 2026-08-13 08:39:22 +02:00
David Garske 4a16dce4f8 efi: authenticate the kernel command line via a signed HDR_CMDLINE manifest TLV 2026-08-10 21:03:50 +02:00
Daniele Lacamera 4d67268a03 version: 2.9.0 2026-07-02 22:58:46 +02:00
Mattia Moffa ef03cf007f Fix additional findings
- Check diag_erase() return value in wolfBoot_record_failure()
- Dedicated WOLFBOOT_FAILURE_PHASE_SELF_UPDATE
- Mark the diagnostics flash write buffers XALIGNED_STACK(4) for HALs
  that access the source word by word
- Ensure diagnostics, update, or swap partitions don't overlap the
  bootloader
2026-07-02 17:53:12 +02:00
Mattia Moffa 1da9866630 Diagnostics: record additional events
- Failed boot after emergency update (WOLFBOOT_FAILURE_PHASE_RECOVERY)
- Failed verification of self-update image
2026-07-02 17:53:12 +02:00
Mattia Moffa ceaed58782 Allow configuration of diagnostics record size on flash 2026-07-02 17:53:12 +02:00
Mattia Moffa 69e8e044c9 Add unit tests 2026-07-02 17:53:12 +02:00
Mattia Moffa 7cc4990907 Add option to persist boot/update failure info to flash
When boot/update partition verification fails during boot or update,
with this option the event is logged to flash in an ad-hoc partition.
Information about logged failures is made available to the application
through an API.
2026-07-02 17:53:12 +02:00
aidan garske b9bd6dae17 Add WOLFCRYPT_TZ_WOLFHSM TrustZone engine for STM32H5 2026-06-24 15:49:43 -07:00
Yosuke Shimizu f4d5340641 Add hardware-based DICE on mcxn 2026-05-21 20:49:20 +02:00
Brett Nicholas 627e0664a2 fix include order for unit tests 2026-05-05 16:37:54 +02:00
Brett Nicholas a2e9267529 Adds generic cryptocb support for PK, hash, and symmetric crypto 2026-05-05 16:37:54 +02:00
Brett Nicholas 65d84a29ec Add SW-only RSA PSS 2026-04-28 15:02:57 +02:00
Daniele Lacamera cffa75d4a4 Proper interface renaming + documentation 2026-04-22 14:14:28 +02:00
Daniele Lacamera b22c85ed27 Added support for fTPM in TrustZone + STM32H5 test app 2026-04-21 20:53:48 +02:00
Brett Nicholas 2e7839e4ee add additional check for DELTA_UPDATE + DISABLE_BACKUP incompatibility 2026-04-17 08:27:05 +02:00
Brett Nicholas c45268ed7f monolithic self-updates: force DISABLE_BACKUP=1, eliminate swap, eliminate update code 2026-04-17 08:27:05 +02:00
Daniele Lacamera 776378ca78 Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
Daniele Lacamera 3697f9e335 image: use portable noinline macro
F/2273
2026-04-10 21:39:19 +02:00
Daniele Lacamera f5d50d4257 enforce skip-verify prerequisites
F/2256
2026-04-08 19:53:50 +02:00
Brett Nicholas 9debc4c559 Fix XMSS and ML_DSA keygen type mismatch between image headers and keystore by unifying AUTH_KEY_*/KEYGEN_* constants 2026-03-30 16:32:44 +02:00
Mattia Moffa b5fab30310 Enable NSC veneers when TZEN=1, even without WOLFCRYPT_TZ 2026-03-18 22:26:32 +01:00
Thomas Cook 3b1ef9d6bc Address copilot pr comments. 2026-03-18 11:53:26 +01:00
Thomas Cook dd4312679b Deploy NO_DIRECT_READ_OF_ERASED_SECTOR to protect against hardfault with AHB read of erased sector. 2026-03-18 11:53:26 +01:00
Daniele Lacamera 4eca085b54 Added USE_CLANG option to Makefile 2026-03-10 15:49:45 +01:00
Daniele Lacamera 19d562dbde Fixed build errors with cross-clang compiler 2026-03-10 15:49:39 +01:00
David Garske a5356b830a NXP T2080 Port Refresh
* Initial port refresh for the NXP T2080 target
* IFC Flash driver and multi-core support on T2080
* Working wolfBoot test-app startup on T2080
* Support for NAII and Curtiss-Wright T2080 vendor boards
2026-03-05 17:49:37 +01:00
Brett Nicholas 4d31ef5502 Add self-header feature with support for sim and AURIX TC3xx 2026-02-27 11:39:51 +01:00
Daniele Lacamera a20101d6df Add support for DICE attestation + PSA attestation 2026-02-06 18:36:47 +01:00
David Garske 4ff0e0ad7d
Merge pull request #662 from danielinux/zephyr-psa
zephyr integration as TEE.
2026-01-08 08:53:11 -08:00
Daniele Lacamera af670811fe zephyr integration as TEE.
- Integrates wolfPSA as psa_crypto/psa_store engine in TrustZone
- Provides interface to access APIs from non-secure mode
- Patches to enable wolfboot as TEE module in zephyr
- Patches to enable stm32h563-nucleo/ns as target in zephyr
- psa_crypto zephyr example using wolfboot/wolfPSA as secure engine
2026-01-07 08:27:58 +01:00
David Garske 12d7f0a153 Improved encryption constants between the bootloader and the signing tool. Allows the sign tool to properly use the correct block size for each encryption algorithm (64 for ChaCha, 16 for AES). 2026-01-05 20:37:04 +01:00
Mattia Moffa f12d2f06b4 Add PKCS11 backend for encrypted partitions 2025-12-30 11:15:41 +01:00
gojimmypi 985e2f76c0 Improve image header default size, check for dupe hash def 2025-12-12 17:47:09 +01:00
Daniele Lacamera 3b3aa2e7c3 Updated ChangeLog & version number.
+ Updated wolfTPM submodule
2025-11-26 15:50:13 +01:00
David Garske 8cb3d33339 Added STM32H5 SPI Driver and support for TPM
Cleanup STM32H5 HAL port.
Refactor `__ARM_FEATURE_CMSE` to `TZ_SECURE()`
Refactor attribute cmse_nonsecure_entry to use new macro `CSME_NSE_API`
Added TPM Non Secure Callable API's
Added TPM support to STM32H5 test application
2025-11-19 16:29:28 +01:00
Mattia Moffa 177358e88d Update H5 app to use new NSC API
- Make the update and swap partitions secure and inaccessible from the
  app except via NSC API
- Add a couple of necessary new NSC functions
- Update the app to only use NSC API
- Fix hal_flash_erase to account for secure addresses
- Fix some bugs in xmodem implementation
2025-10-29 00:13:01 +01:00
Daniele Lacamera 18cbea59de Refactoring of IV handling to prevent reusing IVs
During fallback operations, use a different encryption IV than the one
used to encrypt the backup during the update. This ensures that the same
IV is never reused to encrypt different sectors.
2025-10-17 09:44:46 +02:00
gojimmypi fbd8dcf8a2
Update Copyright year to 2025 2025-10-15 11:33:53 -07:00
David Garske 0ce77a4d27
Merge pull request #590 from danielinux/flash-write-as-nsc
NSC functions: add helper to facilitate updates as trustzone non-secure callable
2025-10-07 09:21:02 -07:00
Daniele Lacamera 568452552c Fix corruption of last boot sector with encryption
As reported by @reza-hdd in #589:

> When Firmware is large enough to consume all the allocated boot partition sectors, in the the final swap and erase operations (_wolfBoot_swap_and_final_erase_) the last sector of FW in Boot partition, which is used as a temporary sector for a copy operation, gets corrupted after being copied in external Swap partition and copied back. It looks like the contents are copied to the external Swap partition without being encrypted, but get decrypted when it is read back.

This was due to the function wolfBoot_copy_sector() assuming that all
copies having an external SWAP as destination would not need any
encryption, as the "normal" case during update is to copy already
encrypted sectors from UPDATE->SWAP.

In the final state, after the update is successfully applied, the
mechanism saves a copy of the last sector from BOOT->SWAP. In this case,
if the application is big enough, an extra function is needed to
encrypt the content of this last sector before writing it to SWAP.

Restoring the backup is OK (normal case SWAP->BOOT, decryption was
already there as also noted by the reporter).
2025-09-10 13:27:22 +02:00
Daniele Lacamera cd347b5886 Fix visibility of new nsc declarations 2025-09-05 18:14:04 +02:00
Daniele Lacamera 82e4950b59 Added NSC functions to facilitate updates from NS application 2025-09-05 14:12:50 +02:00