Always generate DH keys for ephemeral DH cipher suites

Modified version of the commit ffaef3f15 in the master branch by Stephen
Henson. This makes the SSL_OP_SINGLE_DH_USE option a no-op and always
generates a new DH key for every handshake regardless.

CVE-2016-0701 (fix part 2 or 2)

Issue reported by Antonio Sanso

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
This commit is contained in:
Matt Caswell
2015-12-17 02:57:20 +00:00
parent 878e2c5b13
commit c5b831f21d
4 changed files with 9 additions and 53 deletions

View File

@@ -1687,20 +1687,9 @@ int ssl3_send_server_key_exchange(SSL *s)
}
s->s3->tmp.dh = dh;
if ((dhp->pub_key == NULL ||
dhp->priv_key == NULL ||
(s->options & SSL_OP_SINGLE_DH_USE))) {
if (!DH_generate_key(dh)) {
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB);
goto err;
}
} else {
dh->pub_key = BN_dup(dhp->pub_key);
dh->priv_key = BN_dup(dhp->priv_key);
if ((dh->pub_key == NULL) || (dh->priv_key == NULL)) {
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB);
goto err;
}
if (!DH_generate_key(dh)) {
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB);
goto err;
}
r[0] = dh->p;
r[1] = dh->g;