Create the NV seed file for the tests if needed

Write an all-bits-zero NV seed file for the tests. Without this, if
the seed file is not present when this test suite is executed, the
PSA module initialization will fail, causing most test cases to fail.

Also write an all-bits-zero NV seed file at the end. The test cases in
this test suite mess with the file, but subsequent test suites may
need it.
This commit is contained in:
Gilles Peskine 2018-11-20 23:21:37 +01:00
parent 0fce4c5830
commit 9e1be6a246
2 changed files with 14 additions and 0 deletions

View file

@ -1,3 +1,6 @@
Create NV seed file
create_nv_seed:
PSA init/deinit
init_deinit:2
@ -48,3 +51,6 @@ entropy_from_nv_seed:MBEDTLS_ENTROPY_BLOCK_SIZE - 1:PSA_ERROR_INSUFFICIENT_ENTRO
NV seed only: just enough
entropy_from_nv_seed:ENTROPY_MIN_NV_SEED_SIZE:PSA_SUCCESS
Recreate NV seed file
create_nv_seed:

View file

@ -127,6 +127,14 @@ static void custom_entropy_init( mbedtls_entropy_context *ctx )
* END_DEPENDENCIES
*/
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED */
void create_nv_seed( )
{
static unsigned char seed[ENTROPY_MIN_NV_SEED_SIZE];
TEST_ASSERT( mbedtls_nv_seed_write( seed, sizeof( seed ) ) >= 0 );
}
/* END_CASE */
/* BEGIN_CASE */
void init_deinit( int count )
{