Skip to content

Commit c2d85cb

Browse files
krish2718jukkar
authored andcommitted
[noup] crypto: mbedtls: Include pk.h for EC paths without ECDH
CRYPTO_MBEDTLS_CRYPTO_EC (WPA3, etc.) uses mbedtls_pk_* but mbedtls/pk.h was only included when CRYPTO_MBEDTLS_CRYPTO_ECDH or EC_DPP is set. Builds with WPA3 and WPS/P2P but without PSA_WANT_ALG_ECDH fail to compile. Add the same pk.h setup and ECC PSA helper declarations at the start of the EC block. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no> Assisted-by: Cursor: Auto
1 parent 0c05d78 commit c2d85cb

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/crypto/crypto_mbedtls_alt.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,24 @@ size_t crypto_ecdh_prime_len(struct crypto_ecdh *ecdh)
20772077

20782078
#if defined(CRYPTO_MBEDTLS_CRYPTO_EC)
20792079

2080+
/*
2081+
* PSA-focused configuration may omit MBEDTLS_PK_PARSE_C and MBEDTLS_PK_WRITE_C;
2082+
* mbedtls/pk.h gates parse/write prototypes on those macros. Define them before
2083+
* the first include of pk.h in this translation unit if not already set.
2084+
*/
2085+
#if !defined(MBEDTLS_PK_PARSE_C)
2086+
#define MBEDTLS_PK_PARSE_C
2087+
#endif
2088+
#if !defined(MBEDTLS_PK_WRITE_C)
2089+
#define MBEDTLS_PK_WRITE_C
2090+
#endif
2091+
20802092
#include <mbedtls/private/ecp.h>
2093+
#include <mbedtls/pk.h>
2094+
2095+
/* tf-psa-crypto internal functions */
2096+
psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid, size_t *bits);
2097+
mbedtls_ecp_group_id mbedtls_ecc_group_from_psa(psa_ecc_family_t family, size_t bits);
20812098

20822099
/* MPI buffer for crypto_ec_get_a() return value; not thread-safe. */
20832100
static mbedtls_mpi mpi_sw_A;

0 commit comments

Comments
 (0)