From a1d980168357d6554008b7bb29a3f15b3594e13f Mon Sep 17 00:00:00 2001 From: mohammad1603 Date: Wed, 6 Jun 2018 13:45:55 +0300 Subject: [PATCH] add slot validation --- library/psa_crypto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d507a53c8..f0439e3ec 100755 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1500,6 +1500,8 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key, if( status != PSA_SUCCESS ) return( status ); slot = &global_data.key_slots[key]; + if( slot->type == PSA_KEY_TYPE_NONE ) + return( PSA_ERROR_EMPTY_SLOT ); cipher_info = mbedtls_cipher_info_from_psa( alg, key_type, key_bits, &cipher_id ); @@ -1643,6 +1645,8 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key, if( status != PSA_SUCCESS ) return( status ); slot = &global_data.key_slots[key]; + if( slot->type == PSA_KEY_TYPE_NONE ) + return( PSA_ERROR_EMPTY_SLOT ); cipher_info = mbedtls_cipher_info_from_psa( alg, key_type, key_bits, &cipher_id );