From 06af0cd4a3e40a279a4400c07092a41a0f4d2fad Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sun, 28 Apr 2019 11:32:30 +0200 Subject: [PATCH] Always require reset after psa_get_key_attributes There was a guarantee that psa_get_key_attributes() does not require a subsequent psa_reset_key_attributes() to free resources as long as the key was created with attributes having this property. This requirement was hard to pin down because if a key is created with default parameters, there are cases where it is difficult to ensure that the domain parameters will be reported without allocating memory. So remove this guarantee. Now the only case psa_reset_key_attributes() is not required is if the attribute structure has only been modified with certain specific setters. --- include/psa/crypto.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index 9ec3b9074..705f2ca37 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -151,13 +151,12 @@ psa_status_t psa_crypto_init(void); * - psa_set_key_usage_flags() * - psa_set_key_algorithm() * - psa_reset_key_attributes() - * - psa_get_key_attributes() on a key which has been created with - * attribute structure that itself did not contain auxiliary resources * * If the attribute structure has been modified with other functions, * you must free auxiliary resources by calling psa_reset_key_attributes(). * The following functions may create auxiliary resouces: * - psa_set_key_domain_parameters() + * - psa_get_key_attributes() */ typedef struct psa_key_attributes_s psa_key_attributes_t;