Skip to content

Commit 340b127

Browse files
psa_destroy_se_key: explain why the error is NOT_PERMITTED
1 parent 0c3ae1f commit 340b127

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/psa_crypto_se.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ psa_status_t psa_destroy_se_key( psa_se_drv_table_entry_t *driver,
223223
{
224224
psa_status_t status;
225225
psa_status_t storage_status;
226+
/* Normally a missing method would mean that the action is not
227+
* supported. But psa_destroy_key() is not supposed to return
228+
* PSA_ERROR_NOT_SUPPORTED: if you can create a key, you should
229+
* be able to destroy it. The only use case for a driver that
230+
* does not have a way to destroy keys at all is if the keys are
231+
* locked in a read-only state: we can use the keys but not
232+
* destroy them. Hence, if the driver doesn't support destroying
233+
* keys, it's really a lack of permission. */
226234
if( driver->methods->key_management == NULL ||
227235
driver->methods->key_management->p_destroy == NULL )
228236
return( PSA_ERROR_NOT_PERMITTED );

0 commit comments

Comments
 (0)