mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Keep track of PSA keys used interally
When PSA uses CTR_DRBG for its random generator and CTR_DRBG uses PSA for AES, as currently implemented, there is one volatile key in permanent use for the CTR_DRBG instance. Account for that in tests that want to know exactly how many volatile keys are in use, or how many volatile keys can be created. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -440,4 +440,24 @@ uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
|
||||
#define AES_PSA_DONE() ((void) 0)
|
||||
#endif /* MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO */
|
||||
|
||||
#if !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) && \
|
||||
defined(MBEDTLS_CTR_DRBG_C) && \
|
||||
defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
||||
/* When AES_C is not defined and PSA does not have an external RNG,
|
||||
* then CTR_DRBG uses PSA to perform AES-ECB. In this scenario 1 key
|
||||
* slot is used internally from PSA to hold the AES key and it should
|
||||
* not be taken into account when evaluating remaining open slots. */
|
||||
#define MBEDTLS_TEST_PSA_INTERNAL_KEYS_FOR_DRBG 1
|
||||
#else
|
||||
#define MBEDTLS_TEST_PSA_INTERNAL_KEYS_FOR_DRBG 0
|
||||
#endif
|
||||
|
||||
/** The number of volatile keys that PSA crypto uses internally.
|
||||
*
|
||||
* We expect that many volatile keys to be in use after a successful
|
||||
* psa_crypto_init().
|
||||
*/
|
||||
#define MBEDTLS_TEST_PSA_INTERNAL_KEYS \
|
||||
MBEDTLS_TEST_PSA_INTERNAL_KEYS_FOR_DRBG
|
||||
|
||||
#endif /* PSA_CRYPTO_HELPERS_H */
|
||||
|
Reference in New Issue
Block a user