Hi Antonio
Thanks for your fast response.
In MCUboot the only part that seems to cause the trouble is encrypted_psa.c. It keeps the AES keys of both the primary and the secondary image imported during the swap. They are different keys, because each image has its own random key, and the primary image
is encrypted back into the secondary slot.
I prototyped a patch which imports/destroys the AES key for each operation. That works with the current PSA thin core. I also prototyped a key table in PSA thin core. This also solves the problem.
The MCUboot patch is simpler, but in my opinion it feels odd if MCUboot has to reload the key for each chunk it swaps, since MCUboot uses the PSA API correctly as it is. Performance wise the difference is negligible, at least on our setup. I would be willing
to find a solution upstream and could provide either or both patches after some cleanup.
What do you think?
Best
Mario
From: Antonio De Angelis <Antonio.DeAngelis@arm.com>
Sent: Wednesday, December 2, 2026 17:37
To: Jaun, Mario <Mario.Jaun@zuehlke.com>; Anton Komlev via TF-M <tf-m@lists.trustedfirmware.org>
Cc: nd <nd@arm.com>
Subject: Re: BL2 thin PSA crypto core: single key slot and encrypted swap
Hi,
the limit has not come up yet for the scenario that you're testing. I am wondering whether the MCUboot layer could be rewritten to avoid having to load and keep multiple keys at the same time in the store. If that is a hard requirement, extending the number
of keys the thin layer can store is doable, it will definitely lead to an increase of complexity of the part of the thin layer that manages keys.
Thanks,
Antonio
Sent from Outlook for Mac
From: Jaun, Mario via TF-M <tf-m@lists.trustedfirmware.org>
Date: Wednesday, 2 December 2026 at 15:00
To: Anton Komlev via TF-M <tf-m@lists.trustedfirmware.org>
Subject: [TF-M] BL2 thin PSA crypto core: single key slot and encrypted swap
Hi all,
We are enabling MCUboot image encryption in BL2 with a swap upgrade strategy (SWAP_USING_OFFSET, RSA-OAEP). Encrypted updates fail on target because MCUboot needs several keys imported at the same time, while the thin PSA crypto core holds only one. We are
working with STM32U5 but this seems to apply to any platform.
Is the single key slot a deliberate limit or did encrypted swap simply not come up yet?
Thanks for any hints.
Best
Mario