Skip to content

Commit d46548c

Browse files
authored
Merge pull request #23 from orenc17/its_update
Update usage of PSA ITS to comply with v1.0
2 parents 37a8c0c + 23a6784 commit d46548c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

library/psa_crypto.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
#include "mbedtls/xtea.h"
9494

9595
#if ( defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_PSA_HAS_ITS_IO) )
96-
#include "psa_prot_internal_storage.h"
96+
#include "psa/internal_trusted_storage.h"
9797
#endif
9898

9999
#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 )
42644264
case PSA_ITS_SUCCESS:
42654265
return( PSA_SUCCESS );
42664266

4267-
case PSA_ITS_ERROR_KEY_NOT_FOUND:
4267+
case PSA_ITS_ERROR_UID_NOT_FOUND:
42684268
return( PSA_ERROR_EMPTY_SLOT );
42694269

42704270
case PSA_ITS_ERROR_STORAGE_FAILURE:
@@ -4273,10 +4273,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
42734273
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
42744274
return( PSA_ERROR_INSUFFICIENT_STORAGE );
42754275

4276-
case PSA_ITS_ERROR_INVALID_KEY:
42774276
case PSA_ITS_ERROR_OFFSET_INVALID:
42784277
case PSA_ITS_ERROR_INCORRECT_SIZE:
4279-
case PSA_ITS_ERROR_BAD_POINTER:
4278+
case PSA_ITS_ERROR_INVALID_ARGUMENTS:
42804279
return( PSA_ERROR_INVALID_ARGUMENT );
42814280

42824281
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
@@ -4307,7 +4306,7 @@ psa_status_t mbedtls_psa_inject_entropy( const unsigned char *seed,
43074306
its_status = psa_its_get_info( PSA_CRYPTO_ITS_RANDOM_SEED_UID, &p_info );
43084307
status = its_to_psa_error( its_status );
43094308

4310-
if( PSA_ITS_ERROR_KEY_NOT_FOUND == its_status ) /* No seed exists */
4309+
if( PSA_ITS_ERROR_UID_NOT_FOUND == its_status ) /* No seed exists */
43114310
{
43124311
its_status = psa_its_set( PSA_CRYPTO_ITS_RANDOM_SEED_UID, seed_size, seed, 0 );
43134312
status = its_to_psa_error( its_status );

library/psa_crypto_storage_its.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "psa/crypto.h"
3131
#include "psa_crypto_storage_backend.h"
32-
#include "psa_prot_internal_storage.h"
32+
#include "psa/internal_trusted_storage.h"
3333

3434
#if defined(MBEDTLS_PLATFORM_C)
3535
#include "mbedtls/platform.h"
@@ -42,7 +42,7 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
4242
case PSA_ITS_SUCCESS:
4343
return( PSA_SUCCESS );
4444

45-
case PSA_ITS_ERROR_KEY_NOT_FOUND:
45+
case PSA_ITS_ERROR_UID_NOT_FOUND:
4646
return( PSA_ERROR_EMPTY_SLOT );
4747

4848
case PSA_ITS_ERROR_STORAGE_FAILURE:
@@ -51,10 +51,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
5151
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
5252
return( PSA_ERROR_INSUFFICIENT_STORAGE );
5353

54-
case PSA_ITS_ERROR_INVALID_KEY:
5554
case PSA_ITS_ERROR_OFFSET_INVALID:
5655
case PSA_ITS_ERROR_INCORRECT_SIZE:
57-
case PSA_ITS_ERROR_BAD_POINTER:
56+
case PSA_ITS_ERROR_INVALID_ARGUMENTS:
5857
return( PSA_ERROR_INVALID_ARGUMENT );
5958

6059
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
@@ -100,7 +99,7 @@ int psa_is_key_present_in_storage( const psa_key_id_t key )
10099

101100
ret = psa_its_get_info( data_identifier, &data_identifier_info );
102101

103-
if( ret == PSA_ITS_ERROR_KEY_NOT_FOUND )
102+
if( ret == PSA_ITS_ERROR_UID_NOT_FOUND )
104103
return( 0 );
105104
return( 1 );
106105
}
@@ -150,14 +149,14 @@ psa_status_t psa_destroy_persistent_key( const psa_key_id_t key )
150149
struct psa_its_info_t data_identifier_info;
151150

152151
ret = psa_its_get_info( data_identifier, &data_identifier_info );
153-
if( ret == PSA_ITS_ERROR_KEY_NOT_FOUND )
152+
if( ret == PSA_ITS_ERROR_UID_NOT_FOUND )
154153
return( PSA_SUCCESS );
155154

156155
if( psa_its_remove( data_identifier ) != PSA_ITS_SUCCESS )
157156
return( PSA_ERROR_STORAGE_FAILURE );
158157

159158
ret = psa_its_get_info( data_identifier, &data_identifier_info );
160-
if( ret != PSA_ITS_ERROR_KEY_NOT_FOUND )
159+
if( ret != PSA_ITS_ERROR_UID_NOT_FOUND )
161160
return( PSA_ERROR_STORAGE_FAILURE );
162161

163162
return( PSA_SUCCESS );

0 commit comments

Comments
 (0)