1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-24 22:29:04 +08:00

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 <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2025-04-15 12:49:17 +02:00
parent 73bd210a94
commit 3775c9b48f

View File

@ -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