From 23a6784cb927dacf9e46080e037870d2bbe80e0f Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 24 Jan 2019 14:32:11 +0200 Subject: [PATCH] Update usage of PSA ITS to comply with v1.0 --- library/psa_crypto.c | 9 ++++----- library/psa_crypto_storage_its.c | 13 ++++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 1b961b803..2d21bb079 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -92,7 +92,7 @@ #include "mbedtls/xtea.h" #if ( defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_PSA_HAS_ITS_IO) ) -#include "psa_prot_internal_storage.h" +#include "psa/internal_trusted_storage.h" #endif #define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) ) @@ -4220,7 +4220,7 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret ) case PSA_ITS_SUCCESS: return( PSA_SUCCESS ); - case PSA_ITS_ERROR_KEY_NOT_FOUND: + case PSA_ITS_ERROR_UID_NOT_FOUND: return( PSA_ERROR_EMPTY_SLOT ); case PSA_ITS_ERROR_STORAGE_FAILURE: @@ -4229,10 +4229,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret ) case PSA_ITS_ERROR_INSUFFICIENT_SPACE: return( PSA_ERROR_INSUFFICIENT_STORAGE ); - case PSA_ITS_ERROR_INVALID_KEY: case PSA_ITS_ERROR_OFFSET_INVALID: case PSA_ITS_ERROR_INCORRECT_SIZE: - case PSA_ITS_ERROR_BAD_POINTER: + case PSA_ITS_ERROR_INVALID_ARGUMENTS: return( PSA_ERROR_INVALID_ARGUMENT ); case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED: @@ -4263,7 +4262,7 @@ psa_status_t mbedtls_psa_inject_entropy( const unsigned char *seed, its_status = psa_its_get_info( PSA_CRYPTO_ITS_RANDOM_SEED_UID, &p_info ); status = its_to_psa_error( its_status ); - if( PSA_ITS_ERROR_KEY_NOT_FOUND == its_status ) /* No seed exists */ + if( PSA_ITS_ERROR_UID_NOT_FOUND == its_status ) /* No seed exists */ { its_status = psa_its_set( PSA_CRYPTO_ITS_RANDOM_SEED_UID, seed_size, seed, 0 ); status = its_to_psa_error( its_status ); diff --git a/library/psa_crypto_storage_its.c b/library/psa_crypto_storage_its.c index d53467a1a..1c7e1711f 100644 --- a/library/psa_crypto_storage_its.c +++ b/library/psa_crypto_storage_its.c @@ -29,7 +29,7 @@ #include "psa/crypto.h" #include "psa_crypto_storage_backend.h" -#include "psa_prot_internal_storage.h" +#include "psa/internal_trusted_storage.h" #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" @@ -42,7 +42,7 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret ) case PSA_ITS_SUCCESS: return( PSA_SUCCESS ); - case PSA_ITS_ERROR_KEY_NOT_FOUND: + case PSA_ITS_ERROR_UID_NOT_FOUND: return( PSA_ERROR_EMPTY_SLOT ); case PSA_ITS_ERROR_STORAGE_FAILURE: @@ -51,10 +51,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret ) case PSA_ITS_ERROR_INSUFFICIENT_SPACE: return( PSA_ERROR_INSUFFICIENT_STORAGE ); - case PSA_ITS_ERROR_INVALID_KEY: case PSA_ITS_ERROR_OFFSET_INVALID: case PSA_ITS_ERROR_INCORRECT_SIZE: - case PSA_ITS_ERROR_BAD_POINTER: + case PSA_ITS_ERROR_INVALID_ARGUMENTS: return( PSA_ERROR_INVALID_ARGUMENT ); case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED: @@ -100,7 +99,7 @@ int psa_is_key_present_in_storage( const psa_key_id_t key ) ret = psa_its_get_info( data_identifier, &data_identifier_info ); - if( ret == PSA_ITS_ERROR_KEY_NOT_FOUND ) + if( ret == PSA_ITS_ERROR_UID_NOT_FOUND ) return( 0 ); return( 1 ); } @@ -150,14 +149,14 @@ psa_status_t psa_destroy_persistent_key( const psa_key_id_t key ) struct psa_its_info_t data_identifier_info; ret = psa_its_get_info( data_identifier, &data_identifier_info ); - if( ret == PSA_ITS_ERROR_KEY_NOT_FOUND ) + if( ret == PSA_ITS_ERROR_UID_NOT_FOUND ) return( PSA_SUCCESS ); if( psa_its_remove( data_identifier ) != PSA_ITS_SUCCESS ) return( PSA_ERROR_STORAGE_FAILURE ); ret = psa_its_get_info( data_identifier, &data_identifier_info ); - if( ret != PSA_ITS_ERROR_KEY_NOT_FOUND ) + if( ret != PSA_ITS_ERROR_UID_NOT_FOUND ) return( PSA_ERROR_STORAGE_FAILURE ); return( PSA_SUCCESS );