MBEDTLS_PSA_INJECT_ENTROPY: Make sure the seed file exist when running tests
The seed file must exist before running tests. Because the location is somewhat platform- and configuration-dependent, and to be friendly to developers who run test suites individually and aren't familiar with this feature, rely on the test framework code rather than on test scripts to create the seed file. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
a08def9871
commit
c2d16b2159
4 changed files with 50 additions and 2 deletions
|
@ -20,6 +20,11 @@
|
|||
#include <test/macros.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
|
||||
#include <psa/crypto.h>
|
||||
#include <test/psa_crypto_helpers.h>
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Static global variables */
|
||||
|
||||
|
@ -35,9 +40,22 @@ mbedtls_test_info_t mbedtls_test_info;
|
|||
int mbedtls_test_platform_setup(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
|
||||
/* Make sure that injected entropy is present. Otherwise
|
||||
* psa_crypto_init() will fail. This is not necessary for test suites
|
||||
* that don't use PSA, but it's harmless (except for leaving a file
|
||||
* behind). */
|
||||
ret = mbedtls_test_inject_entropy_restore();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
ret = mbedtls_platform_setup(&platform_ctx);
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue