Skip to content

Commit 128fd15

Browse files
pk: USE_PSA_CRYPTO: don't translate via the TLS ID
Use the same translation function that the PSA crypto implementation uses.
1 parent 540d83d commit 128fd15

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/pk.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
605605
psa_ecc_curve_t curve_id;
606606
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
607607
psa_key_type_t key_type;
608+
size_t bits;
608609
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
609610

610611
/* export the private key material in the format PSA wants */
@@ -616,12 +617,12 @@ int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
616617
if( ( ret = mbedtls_mpi_write_binary( &ec->d, d, d_len ) ) != 0 )
617618
return( ret );
618619

619-
curve_id = mbedtls_ecp_curve_info_from_grp_id( ec->grp.id )->tls_id;
620-
key_type = PSA_KEY_TYPE_ECC_KEY_PAIR(
621-
mbedtls_psa_parse_tls_ecc_group ( curve_id ) );
620+
curve_id = mbedtls_ecc_group_to_psa( ec->grp.id, &bits );
621+
key_type = PSA_KEY_TYPE_ECC_KEY_PAIR( curve_id );
622622

623623
/* prepare the key attributes */
624624
psa_set_key_type( &attributes, key_type );
625+
psa_set_key_bits( &attributes, bits );
625626
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
626627
psa_set_key_algorithm( &attributes, PSA_ALG_ECDSA(hash_alg) );
627628

0 commit comments

Comments
 (0)