Hi Antonio
Here the two branches containing both approaches at the top commit: https://github.com/mjaun/trusted-firmware-m/tree/thin-psa-key-table https://github.com/mjaun/mcuboot/tree/psa-aes-key-per-operation
Best Mario ________________________________ From: Antonio De Angelis Antonio.DeAngelis@arm.com Sent: Thursday, December 3, 2026 15:08 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
You don't often get email from antonio.deangelis@arm.com. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification If you can share a pointer to the branches that you prototyped I would be happy to have a look. I agree that continuously reimporting and destroying the key is not ideal, but let me have a look first at both approaches.
Thanks, Antonio
Sent from Outlook for Mac
________________________________ From: Jaun, Mario Mario.Jaun@zuehlke.com Date: Thursday, 3 December 2026 at 13:28 To: Antonio De Angelis Antonio.DeAngelis@arm.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 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
You don't often get email from antonio.deangelis@arm.com. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification 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