Skip to content

Conversation

valeriosetti
Copy link
Contributor

@valeriosetti valeriosetti commented Sep 23, 2025

I found that in the Zephyr codebase there are several occurrences of the following pattern:

    select MBEDTLS if !BUILD_WITH_TFM
    select MBEDTLS_PSA_CRYPTO_C if !BUILD_WITH_TFM

This is used to enable Mbed TLS' PSA Crypto Core when TF-M is not available in the build. This is not really nice because it brings the PSA Crypto enablement logic down to the subsystem/module/sample/test using it and it also causes code duplication.

The goal of this PR is to introduce PSA_CRYPTO_PROVIDER as a solution to this problem. This is meant to simplify the end user life: they will just need to enable PSA_CRYPTO_PROVIDER and then Zephyr will take care of enabling what's needed based on the current platform.

@valeriosetti valeriosetti force-pushed the psa-crypto-provider branch 8 times, most recently from f28c600 to e84cc0d Compare September 25, 2025 22:39
@valeriosetti valeriosetti marked this pull request as ready for review September 25, 2025 22:39
@jhedberg jhedberg requested review from asmellby and removed request for HoZHel September 26, 2025 08:21
@valeriosetti valeriosetti requested review from frkv and removed request for ppryga September 26, 2025 08:55
@valeriosetti
Copy link
Contributor Author

Hold on with reviews: apparently I did a rebase mistake and I brought back PSA_CRYPTO_PROVIDER Kconfig. I'm going to fix that immediately

The dependency should be PSA_CRYPTO_CLIENT and not
MBEDTLS_PSA_CRYPTO_CLIENT because the former is more generic. TF-M can
indeed provide PSA Crypto API, not only Mbed TLS.

Signed-off-by: Valerio Setti <[email protected]>
The driver code only relies on legacy Mbed TLS crypto, not on PSA API, so
enabling MBEDTLS_PSA_CRYPTO_C is not needed here.

Signed-off-by: Valerio Setti <[email protected]>
…_EFR32

The driver only uses psa_generate_random() so ENTROPY_C is not required.

Signed-off-by: Valerio Setti <[email protected]>
The goal of new Kconfig PSA_CRYPTO_PROVIDER is to automatically enable
any of the PSA Crypto API provider available for the platform without
having the user to manually pick the proper one. This provider can be
either TF-M, if that's enabled in the build, or Mbed TLS otherwise.

PSA_CRYPTO_PROVIDER simplifies also modules/subsystem Kconfigs removing
blocks as:
	select MBEDTLS if !BUILD_WITH_TFM
	select MBEDTLS_PSA_CRYPTO_C if !BUILD_WITH_TFM

Kconfig PSA_CRYPTO_PROVIDER_CUSTOM is also added to allow the end user
to add a custom implementation of PSA Crypto API instead of TF-M or
Mbed TLS ones.

Signed-off-by: Valerio Setti <[email protected]>
Remove previous Kconfig choices CONFIG_BT_MESH_USES_MBEDTLS_PSA and
CONFIG_BT_MESH_USES_TFM_PSA and use CONFIG_PSA_CRYPTO instead.
This commit also updates test code accordingly.

Signed-off-by: Valerio Setti <[email protected]>
Update release-notes about the following additions:
- CONFIG_PSA_CRYPTO
- CONFIG_PSA_CRYPTO_PROVIDER_TFM
- CONFIG_PSA_CRYPTO_PROVIDER_MBEDTLS
- CONFIG_PSA_CRYPTO_PROVIDER_CUSTOM

Signed-off-by: Valerio Setti <[email protected]>
Copy link

@tomi-font
Copy link
Contributor

@d3zd3z @ceolin Can you review this?

bool "PSA Crypto API"
help
Enable a PSA Crypto API provider in the build. If TF-M is enabled then
it will be used for this scope, otherwise Mbed TLS will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help text is saying that there are only 2 options.

It should also mention the custom/out-of-tree option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.