Skip to content

Commit 61a65c0

Browse files
committed
mbedtls: Fix PSA key encoding
When using TF-M, use the PSA_KEY_TYPE_ECC_KEY_PAIR() macro from mbedtls_psa_parse_tls_ecc_group(), since that function is supposed to return a psa_key_type_t. This helps to avoid any misencodings when the return value from mbedtls_psa_parse_tls_ecc_group() is used directly as a psa_key_type_t without additional encoding. Fixes: 0961f31 ("Make PSA util compatible with Mbed Crypto 3.0.1")
1 parent 0cf6805 commit 61a65c0

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

features/mbedtls/inc/mbedtls/psa_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static inline psa_key_type_t mbedtls_psa_parse_tls_ecc_group(
453453
{
454454
#if TARGET_TFM
455455
*bits = PSA_ECC_CURVE_BITS( tls_ecc_grp_reg_id );
456-
return( (psa_ecc_curve_t) tls_ecc_grp_reg_id );
456+
return( PSA_KEY_TYPE_ECC_KEY_PAIR( tls_ecc_grp_reg_id ));
457457
#else
458458
const mbedtls_ecp_curve_info *curve_info =
459459
mbedtls_ecp_curve_info_from_tls_id( tls_ecc_grp_reg_id );

features/mbedtls/src/pk.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,7 @@ int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
620620
/* prepare the key attributes */
621621
#if TARGET_TFM
622622
curve_id = mbedtls_ecp_curve_info_from_grp_id( ec->grp.id )->tls_id;
623-
key_type = PSA_KEY_TYPE_ECC_KEY_PAIR(
624-
mbedtls_psa_parse_tls_ecc_group ( curve_id,
625-
&bits ) );
623+
key_type = mbedtls_psa_parse_tls_ecc_group ( curve_id, &bits );
626624
#else
627625
curve_id = mbedtls_ecc_group_to_psa( ec->grp.id, &bits );
628626
key_type = PSA_KEY_TYPE_ECC_KEY_PAIR( curve_id );

0 commit comments

Comments
 (0)