diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 633bb8da2e..8fe2232ec5 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -117,36 +117,35 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, * 'elliptic_curves' and only contained elliptic curve groups. */ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { unsigned char *p = buf; *olen = 0; - if( ssl->conf->curve_list == NULL ) + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); + + if( group_list == NULL ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) + for ( ; *group_list != 0; group_list++ ) { const mbedtls_ecp_curve_info *info; - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + info = mbedtls_ecp_curve_info_from_tls_id( *group_list ); if( info == NULL ) continue; - if( !mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) + if( !mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) ) continue; MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); - MBEDTLS_PUT_UINT16_BE( info->tls_id, p, 0 ); + MBEDTLS_PUT_UINT16_BE( *group_list, p, 0 ); p += 2; MBEDTLS_SSL_DEBUG_MSG( 3, ( "NamedGroup: %s ( %x )", - mbedtls_ecp_curve_info_from_tls_id( info->tls_id )->name, - info->tls_id ) ); + info->name, *group_list ) ); } *olen = p - buf; @@ -301,20 +300,19 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_ECDH_C) + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); /* Pick first available ECDHE group compatible with TLS 1.3 */ - if( ssl->conf->curve_list == NULL ) + if( group_list == NULL ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) + for ( ; *group_list != 0; group_list++ ) { const mbedtls_ecp_curve_info *info; - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + info = mbedtls_ecp_curve_info_from_tls_id( *group_list ); if( info != NULL && - mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) + mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) ) { - *group_id = info->tls_id; + *group_id = *group_list; return( 0 ); } }