Skip to content

Commit bc259f6

Browse files
committed
[nrf fromlist] modules: mbedtls: do not always enable entropy on MBEDTLS_PSA_CRYPTO_C
Make `CONFIG_MBEDTLS_PSA_CRYPTO_C` look for and enable an entropy driver only when the Mbed TLS PSA Crypto core is used. Others don't necessarily require entropy unconditionally, it can be an optional feature. Additionally, make the RNG source default to `CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` also when some other PSA Crypto core is used. This allows avoiding code bloat by default to avoid falling back to `CONFIG_MBEDTLS_PSA_CRYPTO_LEGACY_RNG` which would enable more features. It may seem a bit silly to have `CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` enabled even if we don't have actual entropy but some places assume that if it's not defined then the legacy path is used. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no> Upstream PR #: 108256
1 parent e88cd52 commit bc259f6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

modules/mbedtls/Kconfig.tf-psa-crypto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ config MBEDTLS_PKCS5_C
412412
choice MBEDTLS_PSA_CRYPTO_RNG_SOURCE
413413
prompt "PSA crypto random source"
414414
depends on MBEDTLS_PSA_CRYPTO_C
415-
default MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG if CSPRNG_ENABLED
415+
default MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG if CSPRNG_ENABLED \
416+
|| !PSA_CRYPTO_PROVIDER_MBEDTLS
416417
default MBEDTLS_PSA_CRYPTO_LEGACY_RNG
417418

418419
config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
@@ -467,7 +468,7 @@ config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG
467468
config MBEDTLS_PSA_CRYPTO_C
468469
bool "Platform Security Architecture cryptography API"
469470
depends on !BUILD_WITH_TFM
470-
select CSPRNG_NEEDED
471+
select CSPRNG_NEEDED if PSA_CRYPTO_PROVIDER_MBEDTLS
471472

472473
config MBEDTLS_USE_PSA_CRYPTO
473474
bool "Use PSA APIs instead of legacy MbedTLS when possible"

0 commit comments

Comments
 (0)