Skip to content

Commit

Permalink
samples|tests: secure-storage: allow all test rng sources
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
valeriosetti authored and kartben committed Dec 19, 2024
1 parent 46b8536 commit aa64dd3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions samples/psa/its/overlay-entropy_not_secure.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y
1 change: 1 addition & 0 deletions samples/psa/persistent_key/overlay-entropy_not_secure.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit aa64dd3

Please sign in to comment.