mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
psa: Move from key handle to key identifier
Move all the PSA crypto APIs using key handles to use key identifiers but psa_key_open() and psa_key_close(). This is done without modifying any test as key handles and key identifiers are now the same. Update the library modules using PSA crypto APIs to get rid of key handles. Programs and unit tests are updated to not use key handles in subsequent commits, not in this one. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@ -198,13 +198,13 @@ int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start,
|
||||
if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_OPAQUE )
|
||||
{
|
||||
size_t buffer_size;
|
||||
psa_key_handle_t* key_slot = (psa_key_handle_t*) key->pk_ctx;
|
||||
psa_key_id_t* key_id = (psa_key_id_t*) key->pk_ctx;
|
||||
|
||||
if ( *p < start )
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
buffer_size = (size_t)( *p - start );
|
||||
if ( psa_export_public_key( *key_slot, start, buffer_size, &len )
|
||||
if ( psa_export_public_key( *key_id, start, buffer_size, &len )
|
||||
!= PSA_SUCCESS )
|
||||
{
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
@ -265,12 +265,12 @@ int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *key, unsigned char *buf, si
|
||||
{
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_type_t key_type;
|
||||
psa_key_handle_t handle;
|
||||
psa_key_id_t key_id;
|
||||
psa_ecc_family_t curve;
|
||||
size_t bits;
|
||||
|
||||
handle = *((psa_key_handle_t*) key->pk_ctx );
|
||||
if( PSA_SUCCESS != psa_get_key_attributes( handle, &attributes ) )
|
||||
key_id = *((psa_key_id_t*) key->pk_ctx );
|
||||
if( PSA_SUCCESS != psa_get_key_attributes( key_id, &attributes ) )
|
||||
return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
|
||||
key_type = psa_get_key_type( &attributes );
|
||||
bits = psa_get_key_bits( &attributes );
|
||||
|
Reference in New Issue
Block a user