KCM-7386533_CVE-2009-3555.patch   [plain text]


diff -Naur ../openssl.original/include/openssl/ssl.h ./include/openssl/ssl.h
--- ../openssl.original/include/openssl/ssl.h	2009-11-11 14:05:57.000000000 -0800
+++ ./include/openssl/ssl.h	2009-11-11 14:03:11.000000000 -0800
@@ -1740,6 +1740,7 @@
 #define SSL_R_NO_PRIVATE_KEY_ASSIGNED			 190
 #define SSL_R_NO_PROTOCOLS_AVAILABLE			 191
 #define SSL_R_NO_PUBLICKEY				 192
+#define SSL_R_NO_RENEGOTIATION				 318
 #define SSL_R_NO_SHARED_CIPHER				 193
 #define SSL_R_NO_VERIFY_CALLBACK			 194
 #define SSL_R_NULL_SSL_CTX				 195
diff -Naur ../openssl.original/include/openssl/ssl3.h ./include/openssl/ssl3.h
--- ../openssl.original/include/openssl/ssl3.h	2009-11-11 14:05:57.000000000 -0800
+++ ./include/openssl/ssl3.h	2009-11-11 14:03:11.000000000 -0800
@@ -309,11 +309,12 @@
 #define SSL3_CT_FORTEZZA_DMS			20
 #define SSL3_CT_NUMBER				7
 
-#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS	0x0001
-#define SSL3_FLAGS_DELAY_CLIENT_FINISHED	0x0002
-#define SSL3_FLAGS_POP_BUFFER			0x0004
-#define TLS1_FLAGS_TLS_PADDING_BUG		0x0008
-
+#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS		0x0001
+#define SSL3_FLAGS_DELAY_CLIENT_FINISHED		0x0002
+#define SSL3_FLAGS_POP_BUFFER				0x0004
+#define TLS1_FLAGS_TLS_PADDING_BUG			0x0008
+#define SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION	0x0010
+	
 typedef struct ssl3_state_st
 	{
 	long flags;
diff -Naur ../openssl.original/ssl/s3_lib.c ./ssl/s3_lib.c
--- ../openssl.original/ssl/s3_lib.c	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/s3_lib.c	2009-11-11 14:03:11.000000000 -0800
@@ -1756,6 +1756,9 @@
 	if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
 		return(0);
 
+	if (!(s->s3->flags & SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))
+		return(0);
+
 	s->s3->renegotiate=1;
 	return(1);
 	}
diff -Naur ../openssl.original/ssl/s3_pkt.c ./ssl/s3_pkt.c
--- ../openssl.original/ssl/s3_pkt.c	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/s3_pkt.c	2009-11-11 14:03:11.000000000 -0800
@@ -977,6 +977,7 @@
 
 		if (SSL_is_init_finished(s) &&
 			!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
+			(s->s3->flags & SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION) &&
 			!s->s3->renegotiate)
 			{
 			ssl3_renegotiate(s);
@@ -1109,7 +1110,8 @@
 	if ((s->s3->handshake_fragment_len >= 4) &&	!s->in_handshake)
 		{
 		if (((s->state&SSL_ST_MASK) == SSL_ST_OK) &&
-			!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS))
+			!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
+			(s->s3->flags & SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))
 			{
 #if 0 /* worked only because C operator preferences are not as expected (and
        * because this is not really needed for clients except for detecting
diff -Naur ../openssl.original/ssl/s3_srvr.c ./ssl/s3_srvr.c
--- ../openssl.original/ssl/s3_srvr.c	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/s3_srvr.c	2009-11-11 14:03:11.000000000 -0800
@@ -654,6 +654,14 @@
 	SSL_COMP *comp=NULL;
 	STACK_OF(SSL_CIPHER) *ciphers=NULL;
 
+	if (s->new_session
+		&& !(s->s3->flags&SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))
+			{
+			al=SSL_AD_HANDSHAKE_FAILURE;
+			SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);
+			goto f_err;
+			}
+
 	/* We do this so that we will respond with our native type.
 	 * If we are TLSv1 and we get SSLv3, we will respond with TLSv1,
 	 * This down switching should be handled by a different method.
diff -Naur ../openssl.original/ssl/ssl.h ./ssl/ssl.h
--- ../openssl.original/ssl/ssl.h	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/ssl.h	2009-11-11 14:03:11.000000000 -0800
@@ -1740,6 +1740,7 @@
 #define SSL_R_NO_PRIVATE_KEY_ASSIGNED			 190
 #define SSL_R_NO_PROTOCOLS_AVAILABLE			 191
 #define SSL_R_NO_PUBLICKEY				 192
+#define SSL_R_NO_RENEGOTIATION				 318
 #define SSL_R_NO_SHARED_CIPHER				 193
 #define SSL_R_NO_VERIFY_CALLBACK			 194
 #define SSL_R_NULL_SSL_CTX				 195
diff -Naur ../openssl.original/ssl/ssl3.h ./ssl/ssl3.h
--- ../openssl.original/ssl/ssl3.h	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/ssl3.h	2009-11-11 14:03:11.000000000 -0800
@@ -309,11 +309,12 @@
 #define SSL3_CT_FORTEZZA_DMS			20
 #define SSL3_CT_NUMBER				7
 
-#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS	0x0001
-#define SSL3_FLAGS_DELAY_CLIENT_FINISHED	0x0002
-#define SSL3_FLAGS_POP_BUFFER			0x0004
-#define TLS1_FLAGS_TLS_PADDING_BUG		0x0008
-
+#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS		0x0001
+#define SSL3_FLAGS_DELAY_CLIENT_FINISHED		0x0002
+#define SSL3_FLAGS_POP_BUFFER				0x0004
+#define TLS1_FLAGS_TLS_PADDING_BUG			0x0008
+#define SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION	0x0010
+	
 typedef struct ssl3_state_st
 	{
 	long flags;
diff -Naur ../openssl.original/ssl/ssl_err.c ./ssl/ssl_err.c
--- ../openssl.original/ssl/ssl_err.c	2009-11-11 14:05:57.000000000 -0800
+++ ./ssl/ssl_err.c	2009-11-11 14:03:11.000000000 -0800
@@ -335,6 +335,7 @@
 {ERR_REASON(SSL_R_NO_PRIVATE_KEY_ASSIGNED),"no private key assigned"},
 {ERR_REASON(SSL_R_NO_PROTOCOLS_AVAILABLE),"no protocols available"},
 {ERR_REASON(SSL_R_NO_PUBLICKEY)          ,"no publickey"},
+{ERR_REASON(SSL_R_NO_RENEGOTIATION)      ,"no renegotiation"},
 {ERR_REASON(SSL_R_NO_SHARED_CIPHER)      ,"no shared cipher"},
 {ERR_REASON(SSL_R_NO_VERIFY_CALLBACK)    ,"no verify callback"},
 {ERR_REASON(SSL_R_NULL_SSL_CTX)          ,"null ssl ctx"},