mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-24 20:05:31 +00:00
Merge pull request #23 from orenc17/its_update
Update usage of PSA ITS to comply with v1.0
This commit is contained in:
commit
d46548c833
|
@ -93,7 +93,7 @@
|
||||||
#include "mbedtls/xtea.h"
|
#include "mbedtls/xtea.h"
|
||||||
|
|
||||||
#if ( defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_PSA_HAS_ITS_IO) )
|
#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
|
#endif
|
||||||
|
|
||||||
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) )
|
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) )
|
||||||
|
@ -4264,7 +4264,7 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
|
||||||
case PSA_ITS_SUCCESS:
|
case PSA_ITS_SUCCESS:
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_KEY_NOT_FOUND:
|
case PSA_ITS_ERROR_UID_NOT_FOUND:
|
||||||
return( PSA_ERROR_EMPTY_SLOT );
|
return( PSA_ERROR_EMPTY_SLOT );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_STORAGE_FAILURE:
|
case PSA_ITS_ERROR_STORAGE_FAILURE:
|
||||||
|
@ -4273,10 +4273,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
|
||||||
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
|
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
|
||||||
return( PSA_ERROR_INSUFFICIENT_STORAGE );
|
return( PSA_ERROR_INSUFFICIENT_STORAGE );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_INVALID_KEY:
|
|
||||||
case PSA_ITS_ERROR_OFFSET_INVALID:
|
case PSA_ITS_ERROR_OFFSET_INVALID:
|
||||||
case PSA_ITS_ERROR_INCORRECT_SIZE:
|
case PSA_ITS_ERROR_INCORRECT_SIZE:
|
||||||
case PSA_ITS_ERROR_BAD_POINTER:
|
case PSA_ITS_ERROR_INVALID_ARGUMENTS:
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
|
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
|
||||||
|
@ -4307,7 +4306,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 );
|
its_status = psa_its_get_info( PSA_CRYPTO_ITS_RANDOM_SEED_UID, &p_info );
|
||||||
status = its_to_psa_error( its_status );
|
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 );
|
its_status = psa_its_set( PSA_CRYPTO_ITS_RANDOM_SEED_UID, seed_size, seed, 0 );
|
||||||
status = its_to_psa_error( its_status );
|
status = its_to_psa_error( its_status );
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
#include "psa_crypto_storage_backend.h"
|
#include "psa_crypto_storage_backend.h"
|
||||||
#include "psa_prot_internal_storage.h"
|
#include "psa/internal_trusted_storage.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
#include "mbedtls/platform.h"
|
#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:
|
case PSA_ITS_SUCCESS:
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_KEY_NOT_FOUND:
|
case PSA_ITS_ERROR_UID_NOT_FOUND:
|
||||||
return( PSA_ERROR_EMPTY_SLOT );
|
return( PSA_ERROR_EMPTY_SLOT );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_STORAGE_FAILURE:
|
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:
|
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
|
||||||
return( PSA_ERROR_INSUFFICIENT_STORAGE );
|
return( PSA_ERROR_INSUFFICIENT_STORAGE );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_INVALID_KEY:
|
|
||||||
case PSA_ITS_ERROR_OFFSET_INVALID:
|
case PSA_ITS_ERROR_OFFSET_INVALID:
|
||||||
case PSA_ITS_ERROR_INCORRECT_SIZE:
|
case PSA_ITS_ERROR_INCORRECT_SIZE:
|
||||||
case PSA_ITS_ERROR_BAD_POINTER:
|
case PSA_ITS_ERROR_INVALID_ARGUMENTS:
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||||
|
|
||||||
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
|
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 );
|
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( 0 );
|
||||||
return( 1 );
|
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;
|
struct psa_its_info_t data_identifier_info;
|
||||||
|
|
||||||
ret = psa_its_get_info( data_identifier, &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 );
|
return( PSA_SUCCESS );
|
||||||
|
|
||||||
if( psa_its_remove( data_identifier ) != PSA_ITS_SUCCESS )
|
if( psa_its_remove( data_identifier ) != PSA_ITS_SUCCESS )
|
||||||
return( PSA_ERROR_STORAGE_FAILURE );
|
return( PSA_ERROR_STORAGE_FAILURE );
|
||||||
|
|
||||||
ret = psa_its_get_info( data_identifier, &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_ERROR_STORAGE_FAILURE );
|
return( PSA_ERROR_STORAGE_FAILURE );
|
||||||
|
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
|
|
Loading…
Reference in a new issue