From 6cc663101593cfd064c63238e56c89f6401dc636 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 2 Apr 2021 12:27:47 +0200 Subject: [PATCH] psa: Return in error when requested to copy a key to an opaque driver Signed-off-by: Ronald Cron --- library/psa_crypto.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index f9169aa17..25c85c84c 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2149,6 +2149,17 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, } #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + if( psa_key_lifetime_is_external( actual_attributes.core.lifetime ) ) + { + /* + * Copying through an opaque driver is not implemented yet, consider + * a lifetime with an external location as an invalid parameter for + * now. + */ + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + status = psa_copy_key_material( source_slot, target_slot ); if( status != PSA_SUCCESS ) goto exit;