Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage of PSA ITS to comply with v1.0 #23

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions library/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) )
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 );
Expand Down
13 changes: 6 additions & 7 deletions library/psa_crypto_storage_its.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
Expand Down