From aa64dd32f1ab153a6ac17ce0d8be9900c6dcbd49 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Mon, 16 Dec 2024 06:37:50 +0100 Subject: [PATCH] samples|tests: secure-storage: allow all test rng sources Add MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG to the list of test Kconfigs. Typical use case of this: - the platform has "zephyr,entropy" defined in the devicetree which means that CSPRNG_AVAILABLE is set; - for some reason the board actually does not have any entropy driver enabled (ex: ENTROPY_BT_HCI is disabled in nrf5340bsim when BT is _not_ enabled in the build); - since TEST_RANDOM_GENERATOR is enabled then also TEST_CSPRNG_GENERATOR would be; - unfortunately the call to psa_generate_random() would fail in get_random_data() (in modules/mbedtls/zephyr_entropy.c) because MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG is not set and it would not reach "subsys/random/random_test_csprng.c". This commit fixes this problem. Signed-off-by: Valerio Setti --- samples/psa/its/overlay-entropy_not_secure.conf | 1 + samples/psa/persistent_key/overlay-entropy_not_secure.conf | 1 + .../subsys/secure_storage/psa/crypto/overlay-secure_storage.conf | 1 + .../subsys/secure_storage/psa/its/overlay-transform_default.conf | 1 + 4 files changed, 4 insertions(+) diff --git a/samples/psa/its/overlay-entropy_not_secure.conf b/samples/psa/its/overlay-entropy_not_secure.conf index f2ab17793542..e8eeddbcf92b 100644 --- a/samples/psa/its/overlay-entropy_not_secure.conf +++ b/samples/psa/its/overlay-entropy_not_secure.conf @@ -2,3 +2,4 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y diff --git a/samples/psa/persistent_key/overlay-entropy_not_secure.conf b/samples/psa/persistent_key/overlay-entropy_not_secure.conf index f2ab17793542..e8eeddbcf92b 100644 --- a/samples/psa/persistent_key/overlay-entropy_not_secure.conf +++ b/samples/psa/persistent_key/overlay-entropy_not_secure.conf @@ -2,3 +2,4 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y diff --git a/tests/subsys/secure_storage/psa/crypto/overlay-secure_storage.conf b/tests/subsys/secure_storage/psa/crypto/overlay-secure_storage.conf index e076008277b6..ed84c3043288 100644 --- a/tests/subsys/secure_storage/psa/crypto/overlay-secure_storage.conf +++ b/tests/subsys/secure_storage/psa/crypto/overlay-secure_storage.conf @@ -4,6 +4,7 @@ CONFIG_MAIN_STACK_SIZE=2048 CONFIG_MBEDTLS=y CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y # PSA Crypto needs some heap, but MINIMAL_LIBC has none by default. CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=2048 CONFIG_MBEDTLS_PSA_CRYPTO_C=y diff --git a/tests/subsys/secure_storage/psa/its/overlay-transform_default.conf b/tests/subsys/secure_storage/psa/its/overlay-transform_default.conf index c743a735e4d5..7ed936966baa 100644 --- a/tests/subsys/secure_storage/psa/its/overlay-transform_default.conf +++ b/tests/subsys/secure_storage/psa/its/overlay-transform_default.conf @@ -1,6 +1,7 @@ CONFIG_MBEDTLS=y CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_TIMER_RANDOM_GENERATOR=y +CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y # PSA Crypto needs some heap, but MINIMAL_LIBC has none by default. CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=2048 CONFIG_MBEDTLS_PSA_CRYPTO_C=y