Fix test code under MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-02-16 18:28:56 +01:00
parent 4fbffcd144
commit f68a9cf1e7

View File

@ -3,7 +3,7 @@
#include "psa/crypto.h" #include "psa/crypto.h"
#include "test/psa_crypto_helpers.h" #include "test/psa_crypto_helpers.h"
#define INVALID_KEY_ID 0xfedcba98 #define INVALID_KEY_ID mbedtls_svc_key_id_make( 0, 0xfedcba98 )
/* END_HEADER */ /* END_HEADER */
@ -16,7 +16,7 @@
void import_not_supported( int key_type, data_t *key_material ) void import_not_supported( int key_type, data_t *key_material )
{ {
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_id_t key_id = INVALID_KEY_ID; mbedtls_svc_key_id_t key_id = INVALID_KEY_ID;
PSA_ASSERT( psa_crypto_init( ) ); PSA_ASSERT( psa_crypto_init( ) );
psa_set_key_type( &attributes, key_type ); psa_set_key_type( &attributes, key_type );
@ -24,7 +24,7 @@ void import_not_supported( int key_type, data_t *key_material )
key_material->x, key_material->len, key_material->x, key_material->len,
&key_id ), &key_id ),
PSA_ERROR_NOT_SUPPORTED ); PSA_ERROR_NOT_SUPPORTED );
TEST_EQUAL( key_id, 0 ); TEST_ASSERT( mbedtls_svc_key_id_equal( key_id, MBEDTLS_SVC_KEY_ID_INIT ) );
exit: exit:
psa_destroy_key( key_id ); psa_destroy_key( key_id );
@ -36,14 +36,14 @@ exit:
void generate_not_supported( int key_type, int bits ) void generate_not_supported( int key_type, int bits )
{ {
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_id_t key_id = INVALID_KEY_ID; mbedtls_svc_key_id_t key_id = INVALID_KEY_ID;
PSA_ASSERT( psa_crypto_init( ) ); PSA_ASSERT( psa_crypto_init( ) );
psa_set_key_type( &attributes, key_type ); psa_set_key_type( &attributes, key_type );
psa_set_key_bits( &attributes, bits ); psa_set_key_bits( &attributes, bits );
TEST_EQUAL( psa_generate_key( &attributes, &key_id ), TEST_EQUAL( psa_generate_key( &attributes, &key_id ),
PSA_ERROR_NOT_SUPPORTED ); PSA_ERROR_NOT_SUPPORTED );
TEST_EQUAL( key_id, 0 ); TEST_ASSERT( mbedtls_svc_key_id_equal( key_id, MBEDTLS_SVC_KEY_ID_INIT ) );
exit: exit:
psa_destroy_key( key_id ); psa_destroy_key( key_id );