Skip to content

Commit

Permalink
Bug 753136 - Fixing ssl3_HandleSupportedCurvesXtn, r=ekr
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 4e975f1a612e05a7c20ee09a243efb3af7cab44c
extra : histedit_source : 007e86d544f5f13c45456663deb7988a2d48936e
  • Loading branch information
martinthomson committed Mar 17, 2015
1 parent c35d122 commit e61b3a0
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions lib/ssl/ssl3ecc.c
@@ -1,3 +1,4 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* SSL3 Protocol
*
Expand Down Expand Up @@ -1220,7 +1221,7 @@ ECName ssl3_GetSvrCertCurveName(sslSocket *ss)
return ec_curve;
}

/* Ensure that the curve in our server cert is one of the ones suppored
/* Ensure that the curve in our server cert is one of the ones supported
* by the remote client, and disable all ECC cipher suites if not.
*/
SECStatus
Expand All @@ -1231,26 +1232,34 @@ ssl3_HandleSupportedCurvesXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data)
PRUint32 mutualCurves = 0;
PRUint16 svrCertCurveName;

if (!data->data || data->len < 4 || data->len > 65535)
goto loser;
if (!data->data || data->len < 4) {
(void)ssl3_DecodeError(ss);
return SECFailure;
}

/* get the length of elliptic_curve_list */
list_len = ssl3_ConsumeHandshakeNumber(ss, 2, &data->data, &data->len);
if (list_len < 0 || data->len != list_len || (data->len % 2) != 0) {
/* malformed */
goto loser;
(void)ssl3_DecodeError(ss);
return SECFailure;
}
/* build bit vector of peer's supported curve names */
while (data->len) {
PRInt32 curve_name =
ssl3_ConsumeHandshakeNumber(ss, 2, &data->data, &data->len);
PRInt32 curve_name =
ssl3_ConsumeHandshakeNumber(ss, 2, &data->data, &data->len);
if (curve_name < 0) {
return SECFailure; /* fatal alert already sent */
}
if (curve_name > ec_noName && curve_name < ec_pastLastName) {
peerCurves |= (1U << curve_name);
}
}
/* What curves do we support in common? */
mutualCurves = ss->ssl3.hs.negotiatedECCurves &= peerCurves;
if (!mutualCurves) { /* no mutually supported EC Curves */
goto loser;
if (!mutualCurves) {
/* no mutually supported EC Curves, disable ECC */
ssl3_DisableECCSuites(ss, ecSuites);
return SECSuccess;
}

/* if our ECC cert doesn't use one of these supported curves,
Expand All @@ -1266,12 +1275,7 @@ ssl3_HandleSupportedCurvesXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data)
*/
ssl3_DisableECCSuites(ss, ecdh_ecdsa_suites);
ssl3_DisableECCSuites(ss, ecdhe_ecdsa_suites);
return SECFailure;

loser:
/* no common curve supported */
ssl3_DisableECCSuites(ss, ecSuites);
return SECFailure;
return SECSuccess;
}

#endif /* NSS_DISABLE_ECC */

0 comments on commit e61b3a0

Please sign in to comment.