mturk / rpms / openssl

Forked from rpms/openssl 3 years ago
Clone
2d6ef07
diff -up openssl-1.0.0-beta4/ssl/ssl_err.c.tls-comp openssl-1.0.0-beta4/ssl/ssl_err.c
2d6ef07
--- openssl-1.0.0-beta4/ssl/ssl_err.c.tls-comp	2010-01-07 18:45:46.000000000 +0100
2d6ef07
+++ openssl-1.0.0-beta4/ssl/ssl_err.c	2010-01-07 22:46:10.000000000 +0100
2d6ef07
@@ -329,6 +329,7 @@ static ERR_STRING_DATA SSL_str_reasons[]
2d6ef07
 {ERR_REASON(SSL_R_CIPHER_TABLE_SRC_ERROR),"cipher table src error"},
2d6ef07
 {ERR_REASON(SSL_R_CLIENTHELLO_TLSEXT)    ,"clienthello tlsext"},
2d6ef07
 {ERR_REASON(SSL_R_COMPRESSED_LENGTH_TOO_LONG),"compressed length too long"},
2d6ef07
+{ERR_REASON(SSL_R_COMPRESSION_DISABLED)  ,"compression disabled"},
2d6ef07
 {ERR_REASON(SSL_R_COMPRESSION_FAILURE)   ,"compression failure"},
2d6ef07
 {ERR_REASON(SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE),"compression id not within private range"},
2d6ef07
 {ERR_REASON(SSL_R_COMPRESSION_LIBRARY_ERROR),"compression library error"},
2d6ef07
@@ -357,8 +358,10 @@ static ERR_STRING_DATA SSL_str_reasons[]
2d6ef07
 {ERR_REASON(SSL_R_HTTPS_PROXY_REQUEST)   ,"https proxy request"},
2d6ef07
 {ERR_REASON(SSL_R_HTTP_REQUEST)          ,"http request"},
2d6ef07
 {ERR_REASON(SSL_R_ILLEGAL_PADDING)       ,"illegal padding"},
2d6ef07
+{ERR_REASON(SSL_R_INCONSISTENT_COMPRESSION),"inconsistent compression"},
2d6ef07
 {ERR_REASON(SSL_R_INVALID_CHALLENGE_LENGTH),"invalid challenge length"},
2d6ef07
 {ERR_REASON(SSL_R_INVALID_COMMAND)       ,"invalid command"},
2d6ef07
+{ERR_REASON(SSL_R_INVALID_COMPRESSION_ALGORITHM),"invalid compression algorithm"},
2d6ef07
 {ERR_REASON(SSL_R_INVALID_PURPOSE)       ,"invalid purpose"},
2d6ef07
 {ERR_REASON(SSL_R_INVALID_STATUS_RESPONSE),"invalid status response"},
2d6ef07
 {ERR_REASON(SSL_R_INVALID_TICKET_KEYS_LENGTH),"invalid ticket keys length"},
2d6ef07
@@ -421,6 +424,7 @@ static ERR_STRING_DATA SSL_str_reasons[]
2d6ef07
 {ERR_REASON(SSL_R_NULL_SSL_CTX)          ,"null ssl ctx"},
2d6ef07
 {ERR_REASON(SSL_R_NULL_SSL_METHOD_PASSED),"null ssl method passed"},
2d6ef07
 {ERR_REASON(SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED),"old session cipher not returned"},
2d6ef07
+{ERR_REASON(SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED),"old session compression algorithm not returned"},
2d6ef07
 {ERR_REASON(SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE),"only tls allowed in fips mode"},
2d6ef07
 {ERR_REASON(SSL_R_OPAQUE_PRF_INPUT_TOO_LONG),"opaque PRF input too long"},
2d6ef07
 {ERR_REASON(SSL_R_PACKET_LENGTH_TOO_LONG),"packet length too long"},
2d6ef07
@@ -451,6 +455,7 @@ static ERR_STRING_DATA SSL_str_reasons[]
2d6ef07
 {ERR_REASON(SSL_R_RENEGOTIATION_ENCODING_ERR),"renegotiation encoding err"},
2d6ef07
 {ERR_REASON(SSL_R_RENEGOTIATION_MISMATCH),"renegotiation mismatch"},
2d6ef07
 {ERR_REASON(SSL_R_REQUIRED_CIPHER_MISSING),"required cipher missing"},
2d6ef07
+{ERR_REASON(SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING),"required compresssion algorithm missing"},
2d6ef07
 {ERR_REASON(SSL_R_REUSE_CERT_LENGTH_NOT_ZERO),"reuse cert length not zero"},
2d6ef07
 {ERR_REASON(SSL_R_REUSE_CERT_TYPE_NOT_ZERO),"reuse cert type not zero"},
2d6ef07
 {ERR_REASON(SSL_R_REUSE_CIPHER_LIST_NOT_ZERO),"reuse cipher list not zero"},
2d6ef07
diff -up openssl-1.0.0-beta4/ssl/ssl.h.tls-comp openssl-1.0.0-beta4/ssl/ssl.h
2d6ef07
--- openssl-1.0.0-beta4/ssl/ssl.h.tls-comp	2010-01-07 18:45:46.000000000 +0100
2d6ef07
+++ openssl-1.0.0-beta4/ssl/ssl.h	2010-01-07 22:47:07.000000000 +0100
2d6ef07
@@ -485,7 +485,7 @@ typedef struct ssl_session_st
2d6ef07
 	long timeout;
2d6ef07
 	long time;
2d6ef07
 
2d6ef07
-	int compress_meth;		/* Need to lookup the method */
2d6ef07
+	unsigned int compress_meth;	/* Need to lookup the method */
2d6ef07
 
2d6ef07
 	const SSL_CIPHER *cipher;
2d6ef07
 	unsigned long cipher_id;	/* when ASN.1 loaded, this
2d6ef07
@@ -2051,6 +2051,7 @@ void ERR_load_SSL_strings(void);
2d6ef07
 #define SSL_R_CIPHER_TABLE_SRC_ERROR			 139
2d6ef07
 #define SSL_R_CLIENTHELLO_TLSEXT			 226
2d6ef07
 #define SSL_R_COMPRESSED_LENGTH_TOO_LONG		 140
2d6ef07
+#define SSL_R_COMPRESSION_DISABLED			 343
2d6ef07
 #define SSL_R_COMPRESSION_FAILURE			 141
2d6ef07
 #define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE	 307
2d6ef07
 #define SSL_R_COMPRESSION_LIBRARY_ERROR			 142
2d6ef07
@@ -2079,8 +2080,10 @@ void ERR_load_SSL_strings(void);
2d6ef07
 #define SSL_R_HTTPS_PROXY_REQUEST			 155
2d6ef07
 #define SSL_R_HTTP_REQUEST				 156
2d6ef07
 #define SSL_R_ILLEGAL_PADDING				 283
2d6ef07
+#define SSL_R_INCONSISTENT_COMPRESSION			 340
2d6ef07
 #define SSL_R_INVALID_CHALLENGE_LENGTH			 158
2d6ef07
 #define SSL_R_INVALID_COMMAND				 280
2d6ef07
+#define SSL_R_INVALID_COMPRESSION_ALGORITHM		 341
2d6ef07
 #define SSL_R_INVALID_PURPOSE				 278
2d6ef07
 #define SSL_R_INVALID_STATUS_RESPONSE			 328
2d6ef07
 #define SSL_R_INVALID_TICKET_KEYS_LENGTH		 325
2d6ef07
@@ -2143,6 +2146,7 @@ void ERR_load_SSL_strings(void);
2d6ef07
 #define SSL_R_NULL_SSL_CTX				 195
2d6ef07
 #define SSL_R_NULL_SSL_METHOD_PASSED			 196
2d6ef07
 #define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED		 197
2d6ef07
+#define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344
2d6ef07
 #define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE		 297
2d6ef07
 #define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG			 327
2d6ef07
 #define SSL_R_PACKET_LENGTH_TOO_LONG			 198
2d6ef07
@@ -2173,6 +2177,7 @@ void ERR_load_SSL_strings(void);
2d6ef07
 #define SSL_R_RENEGOTIATION_ENCODING_ERR		 336
2d6ef07
 #define SSL_R_RENEGOTIATION_MISMATCH			 337
2d6ef07
 #define SSL_R_REQUIRED_CIPHER_MISSING			 215
2d6ef07
+#define SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING	 342
2d6ef07
 #define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO		 216
2d6ef07
 #define SSL_R_REUSE_CERT_TYPE_NOT_ZERO			 217
2d6ef07
 #define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO		 218
2d6ef07
diff -up openssl-1.0.0-beta4/ssl/s3_clnt.c.tls-comp openssl-1.0.0-beta4/ssl/s3_clnt.c
2d6ef07
--- openssl-1.0.0-beta4/ssl/s3_clnt.c.tls-comp	2010-01-07 17:53:12.000000000 +0100
2d6ef07
+++ openssl-1.0.0-beta4/ssl/s3_clnt.c	2010-01-07 22:47:07.000000000 +0100
2d6ef07
@@ -895,10 +895,31 @@ int ssl3_get_server_hello(SSL *s)
2d6ef07
 		SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);
2d6ef07
 		goto f_err;
2d6ef07
 		}
2d6ef07
+	/* If compression is disabled we'd better not try to resume a session
2d6ef07
+	 * using compression.
2d6ef07
+	 */
2d6ef07
+	if (s->session->compress_meth != 0)
2d6ef07
+		{
2d6ef07
+		al=SSL_AD_INTERNAL_ERROR;
2d6ef07
+		SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_INCONSISTENT_COMPRESSION);
2d6ef07
+		goto f_err;
2d6ef07
+		}
2d6ef07
 #else
2d6ef07
 	j= *(p++);
2d6ef07
-	if ((j == 0) || (s->options & SSL_OP_NO_COMPRESSION))
2d6ef07
+	if (s->hit && j != s->session->compress_meth)
2d6ef07
+		{
2d6ef07
+		al=SSL_AD_ILLEGAL_PARAMETER;
2d6ef07
+		SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED);
2d6ef07
+		goto f_err;
2d6ef07
+		}
2d6ef07
+	if (j == 0)
2d6ef07
 		comp=NULL;
2d6ef07
+	else if (s->options & SSL_OP_NO_COMPRESSION)
2d6ef07
+		{
2d6ef07
+		al=SSL_AD_ILLEGAL_PARAMETER;
2d6ef07
+		SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_COMPRESSION_DISABLED);
2d6ef07
+		goto f_err;
2d6ef07
+		}
2d6ef07
 	else
2d6ef07
 		comp=ssl3_comp_find(s->ctx->comp_methods,j);
2d6ef07
 	
2d6ef07
diff -up openssl-1.0.0-beta4/ssl/s3_srvr.c.tls-comp openssl-1.0.0-beta4/ssl/s3_srvr.c
2d6ef07
--- openssl-1.0.0-beta4/ssl/s3_srvr.c.tls-comp	2010-01-07 17:53:12.000000000 +0100
2d6ef07
+++ openssl-1.0.0-beta4/ssl/s3_srvr.c	2010-01-07 22:46:10.000000000 +0100
2d6ef07
@@ -1088,7 +1088,50 @@ int ssl3_get_client_hello(SSL *s)
2d6ef07
 	 * algorithms from the client, starting at q. */
2d6ef07
 	s->s3->tmp.new_compression=NULL;
2d6ef07
 #ifndef OPENSSL_NO_COMP
2d6ef07
-	if (!(s->options & SSL_OP_NO_COMPRESSION) && s->ctx->comp_methods)
2d6ef07
+	/* This only happens if we have a cache hit */
2d6ef07
+	if (s->session->compress_meth != 0)
2d6ef07
+		{
2d6ef07
+		int m, comp_id = s->session->compress_meth;
2d6ef07
+		/* Perform sanity checks on resumed compression algorithm */
2d6ef07
+		/* Can't disable compression */
2d6ef07
+		if (s->options & SSL_OP_NO_COMPRESSION)
2d6ef07
+			{
2d6ef07
+			al=SSL_AD_INTERNAL_ERROR;
2d6ef07
+			SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INCONSISTENT_COMPRESSION);
2d6ef07
+			goto f_err;
2d6ef07
+			}
2d6ef07
+		/* Look for resumed compression method */
2d6ef07
+		for (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++)
2d6ef07
+			{
2d6ef07
+			comp=sk_SSL_COMP_value(s->ctx->comp_methods,m);
2d6ef07
+			if (comp_id == comp->id)
2d6ef07
+				{
2d6ef07
+				s->s3->tmp.new_compression=comp;
2d6ef07
+				break;
2d6ef07
+				}
2d6ef07
+			}
2d6ef07
+		if (s->s3->tmp.new_compression == NULL)
2d6ef07
+			{
2d6ef07
+			al=SSL_AD_INTERNAL_ERROR;
2d6ef07
+			SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INVALID_COMPRESSION_ALGORITHM);
2d6ef07
+			goto f_err;
2d6ef07
+			}
2d6ef07
+		/* Look for resumed method in compression list */
2d6ef07
+		for (m = 0; m < i; m++)
2d6ef07
+			{
2d6ef07
+			if (q[m] == comp_id)
2d6ef07
+				break;
2d6ef07
+			}
2d6ef07
+		if (m >= i)
2d6ef07
+			{
2d6ef07
+			al=SSL_AD_ILLEGAL_PARAMETER;
2d6ef07
+			SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING);
2d6ef07
+			goto f_err;
2d6ef07
+			}
2d6ef07
+		}
2d6ef07
+	else if (s->hit)
2d6ef07
+		comp = NULL;
2d6ef07
+	else if (!(s->options & SSL_OP_NO_COMPRESSION) && s->ctx->comp_methods)
2d6ef07
 		{ /* See if we have a match */
2d6ef07
 		int m,nn,o,v,done=0;
2d6ef07
 
2d6ef07
@@ -1112,6 +1155,16 @@ int ssl3_get_client_hello(SSL *s)
2d6ef07
 		else
2d6ef07
 			comp=NULL;
2d6ef07
 		}
2d6ef07
+#else
2d6ef07
+	/* If compression is disabled we'd better not try to resume a session
2d6ef07
+	 * using compression.
2d6ef07
+	 */
2d6ef07
+	if (s->session->compress_meth != 0)
2d6ef07
+		{
2d6ef07
+		al=SSL_AD_INTERNAL_ERROR;
2d6ef07
+		SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INCONSISTENT_COMPRESSION);
2d6ef07
+		goto f_err;
2d6ef07
+		}
2d6ef07
 #endif
2d6ef07
 
2d6ef07
 	/* Given s->session->ciphers and SSL_get_ciphers, we must