Blame SOURCES/openssl-fips-0.9.8e-cve-2011-4619.patch

5820f5
diff -up openssl-fips-0.9.8e/ssl/s3_srvr.c.sgc-dos openssl-fips-0.9.8e/ssl/s3_srvr.c
5820f5
--- openssl-fips-0.9.8e/ssl/s3_srvr.c.sgc-dos	2012-03-19 17:42:34.490429863 +0100
5820f5
+++ openssl-fips-0.9.8e/ssl/s3_srvr.c	2012-03-19 17:44:42.928114348 +0100
5820f5
@@ -236,6 +236,7 @@ int ssl3_accept(SSL *s)
5820f5
 				}
5820f5
 
5820f5
 			s->init_num=0;
5820f5
+			s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE;
5820f5
 
5820f5
 			if (s->state != SSL_ST_RENEGOTIATE)
5820f5
 				{
5820f5
@@ -655,6 +656,13 @@ int ssl3_check_client_hello(SSL *s)
5820f5
 	s->s3->tmp.reuse_message = 1;
5820f5
 	if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
5820f5
 		{
5820f5
+		/* We only allow the client to restart the handshake once per
5820f5
+		 * negotiation. */
5820f5
+		if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE)
5820f5
+			{
5820f5
+			SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS);
5820f5
+			return -1;
5820f5
+			}
5820f5
 		/* Throw away what we have done so far in the current handshake,
5820f5
 		 * which will now be aborted. (A full SSL_clear would be too much.)
5820f5
 		 * I hope that tmp.dh is the only thing that may need to be cleared
5820f5
@@ -666,6 +674,7 @@ int ssl3_check_client_hello(SSL *s)
5820f5
 			s->s3->tmp.dh = NULL;
5820f5
 			}
5820f5
 #endif
5820f5
+		s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE;
5820f5
 		return 2;
5820f5
 		}
5820f5
 	return 1;
5820f5
diff -up openssl-fips-0.9.8e/ssl/ssl3.h.sgc-dos openssl-fips-0.9.8e/ssl/ssl3.h
5820f5
--- openssl-fips-0.9.8e/ssl/ssl3.h.sgc-dos	2012-03-19 17:42:34.465429341 +0100
5820f5
+++ openssl-fips-0.9.8e/ssl/ssl3.h	2012-03-19 17:42:34.532430741 +0100
5820f5
@@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st
5820f5
 #define SSL3_FLAGS_DELAY_CLIENT_FINISHED	0x0002
5820f5
 #define SSL3_FLAGS_POP_BUFFER			0x0004
5820f5
 #define TLS1_FLAGS_TLS_PADDING_BUG		0x0008
5820f5
+ 
5820f5
+/* SSL3_FLAGS_SGC_RESTART_DONE is set when we
5820f5
+ * restart a handshake because of MS SGC and so prevents us
5820f5
+ * from restarting the handshake in a loop. It's reset on a
5820f5
+ * renegotiation, so effectively limits the client to one restart
5820f5
+ * per negotiation. This limits the possibility of a DDoS
5820f5
+ * attack where the client handshakes in a loop using SGC to
5820f5
+ * restart. Servers which permit renegotiation can still be
5820f5
+ * effected, but we can't prevent that.
5820f5
+ */
5820f5
+#define SSL3_FLAGS_SGC_RESTART_DONE		0x0040
5820f5
 
5820f5
 typedef struct ssl3_state_st
5820f5
 	{
5820f5
diff -up openssl-fips-0.9.8e/ssl/ssl_err.c.sgc-dos openssl-fips-0.9.8e/ssl/ssl_err.c
5820f5
--- openssl-fips-0.9.8e/ssl/ssl_err.c.sgc-dos	2012-03-19 17:42:34.462429280 +0100
5820f5
+++ openssl-fips-0.9.8e/ssl/ssl_err.c	2012-03-19 17:42:34.532430741 +0100
5820f5
@@ -134,6 +134,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
5820f5
 {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL),	"SSL3_CALLBACK_CTRL"},
5820f5
 {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE),	"SSL3_CHANGE_CIPHER_STATE"},
5820f5
 {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM),	"SSL3_CHECK_CERT_AND_ALGORITHM"},
5820f5
+{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO),	"SSL3_CHECK_CLIENT_HELLO"},
5820f5
 {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO),	"SSL3_CLIENT_HELLO"},
5820f5
 {ERR_FUNC(SSL_F_SSL3_CONNECT),	"SSL3_CONNECT"},
5820f5
 {ERR_FUNC(SSL_F_SSL3_CTRL),	"SSL3_CTRL"},
5820f5
@@ -361,6 +362,7 @@ static ERR_STRING_DATA SSL_str_reasons[]
5820f5
 {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY)   ,"missing tmp rsa key"},
5820f5
 {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY)  ,"missing tmp rsa pkey"},
5820f5
 {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"},
5820f5
+{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"},
5820f5
 {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"},
5820f5
 {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"},
5820f5
 {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"},
5820f5
diff -up openssl-fips-0.9.8e/ssl/ssl.h.sgc-dos openssl-fips-0.9.8e/ssl/ssl.h
5820f5
--- openssl-fips-0.9.8e/ssl/ssl.h.sgc-dos	2012-03-19 17:42:34.488429820 +0100
5820f5
+++ openssl-fips-0.9.8e/ssl/ssl.h	2012-03-19 17:42:34.533430762 +0100
5820f5
@@ -1634,6 +1634,7 @@ void ERR_load_SSL_strings(void);
5820f5
 #define SSL_F_SSL3_CALLBACK_CTRL			 233
5820f5
 #define SSL_F_SSL3_CHANGE_CIPHER_STATE			 129
5820f5
 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM		 130
5820f5
+#define SSL_F_SSL3_CHECK_CLIENT_HELLO			 293
5820f5
 #define SSL_F_SSL3_CLIENT_HELLO				 131
5820f5
 #define SSL_F_SSL3_CONNECT				 132
5820f5
 #define SSL_F_SSL3_CTRL					 213
5820f5
@@ -1858,6 +1859,7 @@ void ERR_load_SSL_strings(void);
5820f5
 #define SSL_R_MISSING_TMP_RSA_KEY			 172
5820f5
 #define SSL_R_MISSING_TMP_RSA_PKEY			 173
5820f5
 #define SSL_R_MISSING_VERIFY_MESSAGE			 174
5820f5
+#define SSL_R_MULTIPLE_SGC_RESTARTS			 325
5820f5
 #define SSL_R_NON_SSLV2_INITIAL_PACKET			 175
5820f5
 #define SSL_R_NO_CERTIFICATES_RETURNED			 176
5820f5
 #define SSL_R_NO_CERTIFICATE_ASSIGNED			 177