From 3775c9b48f39e80cdd527245d54ec6a88d3f4fae Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Tue, 15 Apr 2025 12:49:17 +0200 Subject: [PATCH] programs: selftest: remove direct call to mbedtls_platform_entropy_poll() The function is now internal so it cannot be referenced from programs. A dummy alternative is used instead. Signed-off-by: Valerio Setti --- programs/test/selftest.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/programs/test/selftest.c b/programs/test/selftest.c index 0941089779..0a6faa778f 100644 --- a/programs/test/selftest.c +++ b/programs/test/selftest.c @@ -212,10 +212,17 @@ static int run_test_snprintf(void) */ #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_ENTROPY_C) #if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_PLATFORM_GET_ENTROPY_ALT) +static void dummy_entropy(unsigned char *output, size_t output_size) +{ + srand(1); + for (size_t i = 0; i < output_size; i++) { + output[i] = rand(); + } +} + static void create_entropy_seed_file(void) { int result; - size_t output_len = 0; unsigned char seed_value[MBEDTLS_ENTROPY_BLOCK_SIZE]; /* Attempt to read the entropy seed file. If this fails - attempt to write @@ -226,18 +233,7 @@ static void create_entropy_seed_file(void) return; } - result = mbedtls_platform_entropy_poll(NULL, - seed_value, - MBEDTLS_ENTROPY_BLOCK_SIZE, - &output_len); - if (0 != result) { - return; - } - - if (MBEDTLS_ENTROPY_BLOCK_SIZE != output_len) { - return; - } - + dummy_entropy(seed_value, MBEDTLS_ENTROPY_BLOCK_SIZE); mbedtls_platform_std_nv_seed_write(seed_value, MBEDTLS_ENTROPY_BLOCK_SIZE); } #endif