psa: Rename psa_load_rsa/ecp_representation

Rename psa_load_rsa/ecp_representation to
mbedtls_psa_rsa/ecp_load_representation
before to move them in their RSA/ECP
specific PSA crypto C modules.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-11-25 14:58:33 +01:00
parent 84cc99420c
commit 9085708371

View file

@ -570,10 +570,9 @@ static psa_status_t psa_check_rsa_key_byte_aligned(
* contents of the context and the context itself * contents of the context and the context itself
* when done. * when done.
*/ */
static psa_status_t psa_load_rsa_representation( psa_key_type_t type, static psa_status_t mbedtls_psa_rsa_load_representation(
const uint8_t *data, psa_key_type_t type, const uint8_t *data, size_t data_length,
size_t data_length, mbedtls_rsa_context **p_rsa )
mbedtls_rsa_context **p_rsa )
{ {
psa_status_t status; psa_status_t status;
mbedtls_pk_context ctx; mbedtls_pk_context ctx;
@ -710,10 +709,10 @@ static psa_status_t psa_import_rsa_key( psa_key_slot_t *slot,
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
/* Parse input */ /* Parse input */
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation( slot->attr.type,
data, data,
data_length, data_length,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -773,10 +772,9 @@ exit:
* contents of the context and the context itself * contents of the context and the context itself
* when done. * when done.
*/ */
static psa_status_t psa_load_ecp_representation( psa_key_type_t type, static psa_status_t mbedtls_psa_ecp_load_representation(
const uint8_t *data, psa_key_type_t type, const uint8_t *data, size_t data_length,
size_t data_length, mbedtls_ecp_keypair **p_ecp )
mbedtls_ecp_keypair **p_ecp )
{ {
mbedtls_ecp_group_id grp_id = MBEDTLS_ECP_DP_NONE; mbedtls_ecp_group_id grp_id = MBEDTLS_ECP_DP_NONE;
psa_status_t status; psa_status_t status;
@ -943,10 +941,10 @@ static psa_status_t psa_import_ecp_key( psa_key_slot_t *slot,
mbedtls_ecp_keypair *ecp = NULL; mbedtls_ecp_keypair *ecp = NULL;
/* Parse input */ /* Parse input */
status = psa_load_ecp_representation( slot->attr.type, status = mbedtls_psa_ecp_load_representation( slot->attr.type,
data, data,
data_length, data_length,
&ecp ); &ecp );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -1642,10 +1640,11 @@ psa_status_t psa_get_key_attributes( mbedtls_svc_key_id_t key,
{ {
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation(
slot->key.data, slot->attr.type,
slot->key.bytes, slot->key.data,
&rsa ); slot->key.bytes,
&rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
break; break;
@ -1774,11 +1773,10 @@ static psa_status_t psa_internal_export_key( const psa_key_slot_t *slot,
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \ #if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY) defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( status = mbedtls_psa_rsa_load_representation( slot->attr.type,
slot->attr.type, slot->key.data,
slot->key.data, slot->key.bytes,
slot->key.bytes, &rsa );
&rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
@ -1803,11 +1801,10 @@ static psa_status_t psa_internal_export_key( const psa_key_slot_t *slot,
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR) || \ #if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR) || \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY) defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY)
mbedtls_ecp_keypair *ecp = NULL; mbedtls_ecp_keypair *ecp = NULL;
status = psa_load_ecp_representation( status = mbedtls_psa_ecp_load_representation( slot->attr.type,
slot->attr.type, slot->key.data,
slot->key.data, slot->key.bytes,
slot->key.bytes, &ecp );
&ecp );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
@ -2276,11 +2273,11 @@ static psa_status_t psa_validate_optional_attributes(
mbedtls_mpi actual, required; mbedtls_mpi actual, required;
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
psa_status_t status = psa_load_rsa_representation( psa_status_t status = mbedtls_psa_rsa_load_representation(
slot->attr.type, slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
@ -3982,10 +3979,10 @@ psa_status_t psa_sign_hash( mbedtls_svc_key_id_t key,
{ {
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -4014,10 +4011,10 @@ psa_status_t psa_sign_hash( mbedtls_svc_key_id_t key,
) )
{ {
mbedtls_ecp_keypair *ecp = NULL; mbedtls_ecp_keypair *ecp = NULL;
status = psa_load_ecp_representation( slot->attr.type, status = mbedtls_psa_ecp_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&ecp ); &ecp );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
status = psa_ecdsa_sign( ecp, status = psa_ecdsa_sign( ecp,
@ -4092,10 +4089,10 @@ psa_status_t psa_verify_hash( mbedtls_svc_key_id_t key,
{ {
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -4117,10 +4114,10 @@ psa_status_t psa_verify_hash( mbedtls_svc_key_id_t key,
if( PSA_ALG_IS_ECDSA( alg ) ) if( PSA_ALG_IS_ECDSA( alg ) )
{ {
mbedtls_ecp_keypair *ecp = NULL; mbedtls_ecp_keypair *ecp = NULL;
status = psa_load_ecp_representation( slot->attr.type, status = mbedtls_psa_ecp_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&ecp ); &ecp );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
status = psa_ecdsa_verify( ecp, status = psa_ecdsa_verify( ecp,
@ -4201,10 +4198,10 @@ psa_status_t psa_asymmetric_encrypt( mbedtls_svc_key_id_t key,
if( PSA_KEY_TYPE_IS_RSA( slot->attr.type ) ) if( PSA_KEY_TYPE_IS_RSA( slot->attr.type ) )
{ {
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto rsa_exit; goto rsa_exit;
@ -4307,10 +4304,10 @@ psa_status_t psa_asymmetric_decrypt( mbedtls_svc_key_id_t key,
if( slot->attr.type == PSA_KEY_TYPE_RSA_KEY_PAIR ) if( slot->attr.type == PSA_KEY_TYPE_RSA_KEY_PAIR )
{ {
mbedtls_rsa_context *rsa = NULL; mbedtls_rsa_context *rsa = NULL;
status = psa_load_rsa_representation( slot->attr.type, status = mbedtls_psa_rsa_load_representation( slot->attr.type,
slot->key.data, slot->key.data,
slot->key.bytes, slot->key.bytes,
&rsa ); &rsa );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -6172,10 +6169,11 @@ static psa_status_t psa_key_agreement_ecdh( const uint8_t *peer_key,
psa_ecc_family_t curve = mbedtls_ecc_group_to_psa( our_key->grp.id, &bits ); psa_ecc_family_t curve = mbedtls_ecc_group_to_psa( our_key->grp.id, &bits );
mbedtls_ecdh_init( &ecdh ); mbedtls_ecdh_init( &ecdh );
status = psa_load_ecp_representation( PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve), status = mbedtls_psa_ecp_load_representation(
peer_key, PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve),
peer_key_length, peer_key,
&their_key ); peer_key_length,
&their_key );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
goto exit; goto exit;
@ -6227,11 +6225,11 @@ static psa_status_t psa_key_agreement_raw_internal( psa_algorithm_t alg,
if( ! PSA_KEY_TYPE_IS_ECC_KEY_PAIR( private_key->attr.type ) ) if( ! PSA_KEY_TYPE_IS_ECC_KEY_PAIR( private_key->attr.type ) )
return( PSA_ERROR_INVALID_ARGUMENT ); return( PSA_ERROR_INVALID_ARGUMENT );
mbedtls_ecp_keypair *ecp = NULL; mbedtls_ecp_keypair *ecp = NULL;
psa_status_t status = psa_load_ecp_representation( psa_status_t status = mbedtls_psa_ecp_load_representation(
private_key->attr.type, private_key->attr.type,
private_key->key.data, private_key->key.data,
private_key->key.bytes, private_key->key.bytes,
&ecp ); &ecp );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
status = psa_key_agreement_ecdh( peer_key, peer_key_length, status = psa_key_agreement_ecdh( peer_key, peer_key_length,