Blame SOURCES/openssl-1.0.1e-cve-2014-3510.patch

1b2890
From 88ae012c8092852f03c50f6461175271104b4c8a Mon Sep 17 00:00:00 2001
1b2890
From: =?UTF-8?q?Emilia=20K=C3=A4sper?= <emilia@openssl.org>
1b2890
Date: Thu, 24 Jul 2014 22:15:29 +0200
1b2890
Subject: [PATCH] Fix DTLS anonymous EC(DH) denial of service
1b2890
1b2890
CVE-2014-3510
1b2890
1b2890
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
1b2890
---
1b2890
 ssl/d1_clnt.c | 23 +++++++++++++++++++++--
1b2890
 ssl/s3_clnt.c |  7 +++++++
1b2890
 2 files changed, 28 insertions(+), 2 deletions(-)
1b2890
1b2890
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
1b2890
index 65dbb4a..fd6562c 100644
1b2890
--- a/ssl/d1_clnt.c
1b2890
+++ b/ssl/d1_clnt.c
1b2890
@@ -996,6 +996,13 @@ int dtls1_send_client_key_exchange(SSL *s)
1b2890
 			RSA *rsa;
1b2890
 			unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
1b2890
 
1b2890
+			if (s->session->sess_cert == NULL)
1b2890
+				{
1b2890
+				/* We should always have a server certificate with SSL_kRSA. */
1b2890
+				SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1b2890
+				goto err;
1b2890
+				}
1b2890
+
1b2890
 			if (s->session->sess_cert->peer_rsa_tmp != NULL)
1b2890
 				rsa=s->session->sess_cert->peer_rsa_tmp;
1b2890
 			else
1b2890
@@ -1186,6 +1193,13 @@ int dtls1_send_client_key_exchange(SSL *s)
1b2890
 			{
1b2890
 			DH *dh_srvr,*dh_clnt;
1b2890
 
1b2890
+			if (s->session->sess_cert == NULL)
1b2890
+				{
1b2890
+				ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);
1b2890
+				SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE,SSL_R_UNEXPECTED_MESSAGE);
1b2890
+				goto err;
1b2890
+				}
1b2890
+
1b2890
 			if (s->session->sess_cert->peer_dh_tmp != NULL)
1b2890
 				dh_srvr=s->session->sess_cert->peer_dh_tmp;
1b2890
 			else
1b2890
@@ -1245,6 +1259,13 @@ int dtls1_send_client_key_exchange(SSL *s)
1b2890
 			int ecdh_clnt_cert = 0;
1b2890
 			int field_size = 0;
1b2890
 
1b2890
+			if (s->session->sess_cert == NULL)
1b2890
+				{
1b2890
+				ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);
1b2890
+				SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE,SSL_R_UNEXPECTED_MESSAGE);
1b2890
+				goto err;
1b2890
+				}
1b2890
+
1b2890
 			/* Did we send out the client's
1b2890
 			 * ECDH share for use in premaster
1b2890
 			 * computation as part of client certificate?
1b2890
@@ -1720,5 +1741,3 @@ int dtls1_send_client_certificate(SSL *s)
1b2890
 	/* SSL3_ST_CW_CERT_D */
1b2890
 	return(dtls1_do_write(s,SSL3_RT_HANDSHAKE));
1b2890
 	}
1b2890
-
1b2890
-
1b2890
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
1b2890
index 2afb892..df05f78 100644
1b2890
--- a/ssl/s3_clnt.c
1b2890
+++ b/ssl/s3_clnt.c
1b2890
@@ -2253,6 +2253,13 @@ int ssl3_send_client_key_exchange(SSL *s)
1b2890
 			RSA *rsa;
1b2890
 			unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
1b2890
 
1b2890
+			if (s->session->sess_cert == NULL)
1b2890
+				{
1b2890
+				/* We should always have a server certificate with SSL_kRSA. */
1b2890
+				SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1b2890
+				goto err;
1b2890
+				}
1b2890
+
1b2890
 			if (s->session->sess_cert->peer_rsa_tmp != NULL)
1b2890
 				rsa=s->session->sess_cert->peer_rsa_tmp;
1b2890
 			else
1b2890
-- 
1b2890
1.8.3.1
1b2890