Generalize test_suite_psa_crypto_entropy

Prepare it for testing aspects of entropy other than
MBEDTLS_PSA_INJECT_ENTROPY.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2020-11-24 18:44:58 +01:00
parent 76175ba785
commit 8ae012b603

View File

@ -4,15 +4,17 @@
#include "mbedtls/entropy.h" #include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h" #include "mbedtls/entropy_poll.h"
/* Calculating the minimum allowed entropy size in bytes */
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
#if defined(MBEDTLS_PSA_ITS_FILE_C) #if defined(MBEDTLS_PSA_ITS_FILE_C)
#include <stdio.h> #include <stdio.h>
#else #else
#include <psa/internal_trusted_storage.h> #include <psa/internal_trusted_storage.h>
#endif #endif
/* Calculating the minimum allowed entropy size in bytes */
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
/* Remove the entropy seed file. Since the library does not expose a way /* Remove the entropy seed file. Since the library does not expose a way
* to do this (it would be a security risk if such a function was ever * to do this (it would be a security risk if such a function was ever
* accessible in production), implement this functionality in a white-box * accessible in production), implement this functionality in a white-box
@ -29,14 +31,11 @@ psa_status_t remove_seed_file( void )
#endif #endif
} }
#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
/* END_HEADER */ /* END_HEADER */
/* BEGIN_DEPENDENCIES /* BEGIN_CASE depends_on:MBEDTLS_PSA_INJECT_ENTROPY */
* depends_on:MBEDTLS_PSA_INJECT_ENTROPY
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
void validate_entropy_seed_injection( int seed_length_a, void validate_entropy_seed_injection( int seed_length_a,
int expected_status_a, int expected_status_a,
int seed_length_b, int seed_length_b,
@ -80,7 +79,7 @@ exit:
} }
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_PSA_INJECT_ENTROPY */
void run_entropy_inject_with_crypto_init( ) void run_entropy_inject_with_crypto_init( )
{ {
psa_status_t status; psa_status_t status;