Repository navigation
bootutil: init PSA crypto before ECDSA key import - #2969
Merged
nordicjm merged 2 commits intoNov 18, 2026
Merged
Conversation
JayToltTech
force-pushed
the
fix/ecdsa-psa-crypto-init
branch
from
November 13, 2026 05:22
6af9992 to
8e6ccf8
Compare
JayToltTech
marked this pull request as ready for review
November 13, 2026 05:26
JayToltTech
marked this pull request as draft
November 13, 2026 05:28
JayToltTech
force-pushed
the
fix/ecdsa-psa-crypto-init
branch
from
November 13, 2026 05:38
8e6ccf8 to
0254ad1
Compare
JayToltTech
marked this pull request as ready for review
November 13, 2026 05:39
This was referenced Nov 13, 2026
de-nordic
approved these changes
Nov 13, 2026
The PSA ECDSA path never calls psa_crypto_init(). Ed25519, the encryption code and the FIH delay RNG all init PSA themselves, ECDSA just assumes someone else did. On Zephyr the mbedtls module's SYS_INIT usually has, so it doesn't show. With CONFIG_MBEDTLS_INIT=n, or a port that doesn't init PSA before boot_go(), psa_import_key() returns PSA_ERROR_BAD_STATE and nothing ECDSA-signed validates. Same on Mbed TLS 3.6 and 4.1. psa_crypto_init() is a no-op when PSA is already up. Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
init_crypto() called psa_crypto_init() before every boot, which assumed the code under test would never need to do it itself. That's what hid the missing init in the PSA ECDSA path. Without the previous commit, sig-ecdsa-psa fails 12 of 31 core tests on both 3.6 and mbedtls-v4. The external RNG enable stays, that's harness setup. Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
JayToltTech
force-pushed
the
fix/ecdsa-psa-crypto-init
branch
from
November 15, 2026 00:37
0254ad1 to
d6873f9
Compare
nordicjm
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PSA ECDSA path imports the public key without ever calling
psa_crypto_init(). Ed25519, the encryption code and the FIH delay RNG all init PSA themselves. ECDSA just assumes someone else did.On Zephyr the mbedtls module's
SYS_INITusually has, so you don't see it. Tripped over it moving a Zephyr boot signature from tinycrypt ECDSA-P256 to PSA ECDSA-P384, on v2.4.0 with TF-PSA-Crypto 1.x. P-384 has no tinycrypt path, so that's also the first time the build goes through PSA at all, and the bootloader stopped validating anything.The trigger was a missing
CONFIG_MBEDTLS_ENABLE_HEAP. Zephyr's ownpsa_crypto_init()failed withPSA_ERROR_INSUFFICIENT_MEMORY,SYS_INITdrops the return code of a non-device init so nothing said so, and MCUboot carried on intopsa_import_key()with PSA never initialized. Adding the init exposed the config error. The bug manifests the same way withCONFIG_MBEDTLS_INIT=nor on a port that doesn't init PSA beforeboot_go().The sim never caught it because
init_crypto()calledpsa_crypto_init()before every boot, which assumed the code under test would leave that to its caller. So I took that out of the sim first, andsig-ecdsa-psaandsig-ecdsa-psa mbedtls-v4each failed 12 of 31coretests with 'Unable to perform basic upgrade'. Then added the init tobootutil_ecdsa_parse_public_key()and they passed again, along with every other PSA row insim.yaml.The commits are in the other order so nothing in between is red for bisect.
FYI #2557 is heading in a similar direction with a single backend init hook, currently for Ed25519. If that ends up covering ECDSA too, this could fold into it.