From 8756763cf1ff15a2a075f0677327f4d29c0a7588 Mon Sep 17 00:00:00 2001 From: Moran Peker Date: Mon, 4 Jun 2018 18:41:37 +0300 Subject: [PATCH] change error check on psa_internal_export_key func --- library/psa_crypto.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d1960f7271..17d7d1a1fa 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -471,13 +471,13 @@ static psa_status_t psa_internal_export_key(psa_key_slot_t key, if( slot->type == PSA_KEY_TYPE_NONE ) return( PSA_ERROR_EMPTY_SLOT ); - if( !( slot->policy.usage & PSA_KEY_USAGE_EXPORT ) ) - return( PSA_ERROR_NOT_PERMITTED ); - - if( export_public_key && !( PSA_KEY_TYPE_IS_PUBLIC_KEY( slot->type ) || - PSA_KEY_TYPE_IS_KEYPAIR( slot->type ) ) ) + if( export_public_key && ( !( PSA_KEY_TYPE_IS_ASYMMETRIC( slot->type ) ) ) ) return( PSA_ERROR_INVALID_ARGUMENT ); + if( ( !export_public_key ) && ( !( PSA_KEY_TYPE_IS_PUBLIC_KEY( slot->type ) ) ) && + ( !( slot->policy.usage & PSA_KEY_USAGE_EXPORT ) ) ) + return( PSA_ERROR_NOT_PERMITTED ); + if( PSA_KEY_TYPE_IS_RAW_BYTES( slot->type ) ) { if( slot->data.raw.bytes > data_size )