tls-server: Also change DH group when selecting a different EC curve
If we initially selected a group the peer doesn't support (e.g. because curve25519 is the first ECDH group provided by plugins), then found a supported curve, we previously still instantiated a DH object for the original group and might have formatted the parameters incorrectly.
This commit is contained in:
@@ -1483,20 +1483,23 @@ static status_t send_certificate_request(private_tls_server_t *this,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to find a curve supported by both, client and server
|
* Try to find a curve/group supported by both, client and server
|
||||||
*/
|
*/
|
||||||
static bool find_supported_curve(private_tls_server_t *this,
|
static bool find_supported_curve(private_tls_server_t *this,
|
||||||
tls_named_group_t *curve)
|
tls_named_group_t *curve,
|
||||||
|
key_exchange_method_t *group)
|
||||||
{
|
{
|
||||||
tls_named_group_t current;
|
tls_named_group_t current;
|
||||||
|
key_exchange_method_t current_group;
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
enumerator = this->crypto->create_ec_enumerator(this->crypto);
|
enumerator = this->crypto->create_ec_enumerator(this->crypto);
|
||||||
while (enumerator->enumerate(enumerator, NULL, ¤t))
|
while (enumerator->enumerate(enumerator, ¤t_group, ¤t))
|
||||||
{
|
{
|
||||||
if (peer_supports_curve(this, current))
|
if (peer_supports_curve(this, current))
|
||||||
{
|
{
|
||||||
*curve = current;
|
*curve = current;
|
||||||
|
*group = current_group;
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1520,7 +1523,7 @@ static status_t send_server_key_exchange(private_tls_server_t *this,
|
|||||||
{
|
{
|
||||||
curve = tls_ec_group_to_curve(group);
|
curve = tls_ec_group_to_curve(group);
|
||||||
if (!curve || (!peer_supports_curve(this, curve) &&
|
if (!curve || (!peer_supports_curve(this, curve) &&
|
||||||
!find_supported_curve(this, &curve)))
|
!find_supported_curve(this, &curve, &group)))
|
||||||
{
|
{
|
||||||
DBG1(DBG_TLS, "no EC group supported by client and server");
|
DBG1(DBG_TLS, "no EC group supported by client and server");
|
||||||
this->alert->add(this->alert, TLS_FATAL, TLS_HANDSHAKE_FAILURE);
|
this->alert->add(this->alert, TLS_FATAL, TLS_HANDSHAKE_FAILURE);
|
||||||
|
|||||||
Reference in New Issue
Block a user