From bf206b8f418465c96a592e12375f7bb1cc5ca281 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Fri, 8 Sep 2023 12:15:58 +0200 Subject: [PATCH] adjust_legacy_from_psa: undef SOME_BUILTIN_EC when builtin curves are used Signed-off-by: Valerio Setti --- .../mbedtls/config_adjust_legacy_from_psa.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/mbedtls/config_adjust_legacy_from_psa.h b/include/mbedtls/config_adjust_legacy_from_psa.h index a0145723fe..5fa70487e0 100644 --- a/include/mbedtls/config_adjust_legacy_from_psa.h +++ b/include/mbedtls/config_adjust_legacy_from_psa.h @@ -124,6 +124,26 @@ #endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_K1_256 */ #endif /* PSA_WANT_ECC_SECP_K1_256 */ +/* The purpose of MBEDTLS_SOME_BUILTIN_EC is to signal that there are builtin + * curves so we want to make sure there is some code using them: + * - if there is at least one PSA_WANT_ALG_xxx which is not accelerated + * - if there is at least one builtin module/function (ex: PK_PARSE_EC_EXTENDED) + * that relies on these curves. + * If none of the above condition is met, then we forcedly enable builtin ECDSA, + * ECDH and ECJPAKE support. + */ +#if (defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA) && \ + !defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA)) || \ + (defined(PSA_WANT_ALG_ECDH) && !defined(MBEDTLS_PSA_ACCEL_ALG_ECDH)) || \ + (defined(PSA_WANT_ALG_ECDSA) && !defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA)) || \ + (defined(PSA_WANT_ALG_JPAKE) && !defined(MBEDTLS_PSA_ACCEL_ALG_JPAKE)) || \ + defined(MBEDTLS_ECP_C) || \ + defined(MBEDTLS_PK_PARSE_EC_EXTENDED) || \ + defined(MBEDTLS_PK_PARSE_EC_COMPRESSED) || \ + defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_DERIVE) +#undef MBEDTLS_SOME_BUILTIN_EC +#endif + #if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA) #if !defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) || defined(MBEDTLS_SOME_BUILTIN_EC) #define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1