From 7b8fdc7710ce4c36a20f4d17c1985376c798d01f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 7 Sep 2021 17:59:46 +0800 Subject: [PATCH] fix ci fail without ECDH_C Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index b08d22c454ba..ac013bf21047 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -480,14 +480,20 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, return( ret ); } -#if (defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)) +#if defined(MBEDTLS_ECDH_C) /* TODO: Code for MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED missing */ static int check_ecdh_params( const mbedtls_ssl_context *ssl ) { const mbedtls_ecp_curve_info *curve_info; + mbedtls_ecp_group_id grp_id; +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + grp_id = ssl->handshake->ecdh_ctx.grp.id; +#else + grp_id = ssl->handshake->ecdh_ctx.grp_id; +#endif - curve_info = mbedtls_ecp_curve_info_from_grp_id( ssl->handshake->ecdh_ctx.grp_id ); + curve_info = mbedtls_ecp_curve_info_from_grp_id( grp_id ); if( curve_info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); @@ -497,7 +503,7 @@ static int check_ecdh_params( const mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); #if defined(MBEDTLS_ECP_C) - if( mbedtls_ssl_check_curve( ssl, ssl->handshake->ecdh_ctx.grp_id ) != 0 ) + if( mbedtls_ssl_check_curve( ssl, grp_id ) != 0 ) #else if( ssl->handshake->ecdh_ctx.grp.nbits < 163 || ssl->handshake->ecdh_ctx.grp.nbits > 521 )