From 708ec09e30e1a1ccc28faf26b6d2a39249c02323 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 16 Jul 2024 20:02:37 +0200 Subject: [PATCH] Assert that the key ID range for volatile keys is large enough Signed-off-by: Gilles Peskine --- library/psa_crypto_slot_management.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c index 305ad6ec46..c2949a61e7 100644 --- a/library/psa_crypto_slot_management.c +++ b/library/psa_crypto_slot_management.c @@ -65,6 +65,10 @@ typedef struct { static psa_global_data_t global_data; +MBEDTLS_STATIC_ASSERT(ARRAY_LENGTH(global_data.key_slots) <= + PSA_KEY_ID_VOLATILE_MAX - PSA_KEY_ID_VOLATILE_MIN + 1, + "The volatile key range is larger than the key slot array"); + static uint8_t psa_get_key_slots_initialized(void) { uint8_t initialized;