diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 4a8e50c996..f2cf9fed25 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -213,7 +213,8 @@ typedef struct mbedtls_pk_rsassa_pss_options { * format and use PSA functions * - if !ECP_C then use new raw data and PSA functions directly. */ -#if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_ECP_C) && \ + defined(MBEDTLS_ECP_LIGHT) #define MBEDTLS_PK_USE_PSA_EC_DATA #endif /* MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_ECP_C */ @@ -290,7 +291,7 @@ typedef struct mbedtls_pk_context { size_t MBEDTLS_PRIVATE(pub_raw_len); /**< Valid bytes in "pub_raw" */ psa_ecc_family_t MBEDTLS_PRIVATE(ec_family); /**< EC family of pk */ size_t MBEDTLS_PRIVATE(ec_bits); /**< Curve's bits of pk */ -#endif /* MBEDTLS_PK_USE_PSA_EC_PUB_KEY */ +#endif /* MBEDTLS_PK_USE_PSA_EC_DATA */ } mbedtls_pk_context; #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) diff --git a/library/debug.c b/library/debug.c index 1868cb7424..8236452757 100644 --- a/library/debug.c +++ b/library/debug.c @@ -194,6 +194,7 @@ void mbedtls_debug_print_ecp(const mbedtls_ssl_context *ssl, int level, } #endif /* MBEDTLS_ECP_LIGHT */ +#if defined(MBEDTLS_BIGNUM_C) #if defined(MBEDTLS_PK_USE_PSA_EC_DATA) void mbedtls_debug_print_psa_ec(const mbedtls_ssl_context *ssl, int level, const char *file, int line, @@ -240,7 +241,6 @@ void mbedtls_debug_print_psa_ec(const mbedtls_ssl_context *ssl, int level, } #endif /* MBEDTLS_PK_USE_PSA_EC_DATA */ -#if defined(MBEDTLS_BIGNUM_C) void mbedtls_debug_print_mpi(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_mpi *X) diff --git a/library/pk.c b/library/pk.c index 47c19b2086..826c29a8cb 100644 --- a/library/pk.c +++ b/library/pk.c @@ -227,7 +227,7 @@ int mbedtls_pk_update_public_key_from_keypair(mbedtls_pk_context *pk, return 0; } -#endif /* MBEDTLS_PK_USE_PSA_EC_PUB_KEY */ +#endif /* MBEDTLS_PK_USE_PSA_EC_DATA */ #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) /* diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 32d697ac03..376af2509a 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -1140,15 +1140,15 @@ static int eckey_check_pair_psa(mbedtls_pk_context *pub, mbedtls_pk_context *prv mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT; #if defined(MBEDTLS_PK_USE_PSA_EC_DATA) const psa_ecc_family_t curve = prv->ec_family; - const size_t curve_bits = PSA_BITS_TO_BYTES(prv->ec_bits); + const size_t curve_bits = prv->ec_bits; #else /* !MBEDTLS_PK_USE_PSA_EC_DATA */ uint8_t pub_key_buf[MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH]; size_t pub_key_len; size_t curve_bits; const psa_ecc_family_t curve = mbedtls_ecc_group_to_psa(mbedtls_pk_ec_ro(*prv)->grp.id, &curve_bits); - const size_t curve_bytes = PSA_BITS_TO_BYTES(curve_bits); #endif /* !MBEDTLS_PK_USE_PSA_EC_DATA */ + const size_t curve_bytes = PSA_BITS_TO_BYTES(curve_bits); psa_set_key_type(&key_attr, PSA_KEY_TYPE_ECC_KEY_PAIR(curve)); psa_set_key_usage_flags(&key_attr, PSA_KEY_USAGE_EXPORT);