Skip to content

Commit 23a6784

Browse files
author
Oren Cohen
committed
Update usage of PSA ITS to comply with v1.0
1 parent 0b6b871 commit 23a6784

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
@@ -92,7 +92,7 @@
9292
#include "mbedtls/xtea.h"
9393

9494
#if ( defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_PSA_HAS_ITS_IO) )
95-
#include "psa_prot_internal_storage.h"
95+
#include "psa/internal_trusted_storage.h"
9696
#endif
9797

9898
#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 )
42204220
case PSA_ITS_SUCCESS:
42214221
return( PSA_SUCCESS );
42224222

4223-
case PSA_ITS_ERROR_KEY_NOT_FOUND:
4223+
case PSA_ITS_ERROR_UID_NOT_FOUND:
42244224
return( PSA_ERROR_EMPTY_SLOT );
42254225

42264226
case PSA_ITS_ERROR_STORAGE_FAILURE:
@@ -4229,10 +4229,9 @@ static psa_status_t its_to_psa_error( psa_its_status_t ret )
42294229
case PSA_ITS_ERROR_INSUFFICIENT_SPACE:
42304230
return( PSA_ERROR_INSUFFICIENT_STORAGE );
42314231

4232-
case PSA_ITS_ERROR_INVALID_KEY:
42334232
case PSA_ITS_ERROR_OFFSET_INVALID:
42344233
case PSA_ITS_ERROR_INCORRECT_SIZE:
4235-
case PSA_ITS_ERROR_BAD_POINTER:
4234+
case PSA_ITS_ERROR_INVALID_ARGUMENTS:
42364235
return( PSA_ERROR_INVALID_ARGUMENT );
42374236

42384237
case PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED:
@@ -4263,7 +4262,7 @@ psa_status_t mbedtls_psa_inject_entropy( const unsigned char *seed,
42634262
its_status = psa_its_get_info( PSA_CRYPTO_ITS_RANDOM_SEED_UID, &p_info );
42644263
status = its_to_psa_error( its_status );
42654264

4266-
if( PSA_ITS_ERROR_KEY_NOT_FOUND == its_status ) /* No seed exists */
4265+
if( PSA_ITS_ERROR_UID_NOT_FOUND == its_status ) /* No seed exists */
42674266
{
42684267
its_status = psa_its_set( PSA_CRYPTO_ITS_RANDOM_SEED_UID, seed_size, seed, 0 );
42694268
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)