mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #7518 from gilles-peskine-arm/psa_inject_entropy-file-stability
Fix and test MBEDTLS_PSA_INJECT_ENTROPY
This commit is contained in:
@ -208,6 +208,41 @@ psa_key_usage_t mbedtls_test_update_key_usage_flags(psa_key_usage_t usage_flags)
|
||||
*/
|
||||
int mbedtls_test_fail_if_psa_leaking(int line_no, const char *filename);
|
||||
|
||||
|
||||
|
||||
#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
|
||||
/* The #MBEDTLS_PSA_INJECT_ENTROPY feature requires two extra platform
|
||||
* functions, which must be configured as #MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
|
||||
* and #MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO. The job of these functions
|
||||
* is to read and write from the entropy seed file, which is located
|
||||
* in the PSA ITS file whose uid is #PSA_CRYPTO_ITS_RANDOM_SEED_UID.
|
||||
* (These could have been provided as library functions, but for historical
|
||||
* reasons, they weren't, and so each integrator has to provide a copy
|
||||
* of these functions.)
|
||||
*
|
||||
* Provide implementations of these functions for testing. */
|
||||
int mbedtls_test_inject_entropy_seed_read(unsigned char *buf, size_t len);
|
||||
int mbedtls_test_inject_entropy_seed_write(unsigned char *buf, size_t len);
|
||||
|
||||
|
||||
/** Make sure that the injected entropy is present.
|
||||
*
|
||||
* When MBEDTLS_PSA_INJECT_ENTROPY is enabled, psa_crypto_init()
|
||||
* will fail if the PSA entropy seed is not present.
|
||||
* This function must be called at least once in a test suite or other
|
||||
* program before any call to psa_crypto_init().
|
||||
* It does not need to be called in each test case.
|
||||
*
|
||||
* The test framework calls this function before running any test case.
|
||||
*
|
||||
* The few tests that might remove the entropy file must call this function
|
||||
* in their cleanup.
|
||||
*/
|
||||
int mbedtls_test_inject_entropy_restore(void);
|
||||
#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
|
||||
|
||||
|
||||
|
||||
/** Skip a test case if the given key is a 192 bits AES key and the AES
|
||||
* implementation is at least partially provided by an accelerator or
|
||||
* alternative implementation.
|
||||
|
Reference in New Issue
Block a user