b/2453395 cannot reach sslvpn.broadcom.com

Disabled handshake_cutthrough.patch in openssl.config

Change-Id: I4fe837876198dcf0593c5f5d32174d8af76f3f9f
diff --git a/android.testssl/testssl b/android.testssl/testssl
index 3d55f6e..7ff7099 100755
--- a/android.testssl/testssl
+++ b/android.testssl/testssl
@@ -79,8 +79,6 @@
 echo test sslv2/sslv3 with both client and server authentication and small client and server buffers
 $ssltest -server_auth -client_auth -c_small_records -s_small_records $CA $extra || exit 1
 
-echo test sslv2/sslv3 with both client and server authentication and handshake cutthrough
-$ssltest -server_auth -client_auth -cutthrough $CA $extra || exit 1
 
 echo test sslv2 via BIO pair
 $ssltest -bio_pair -ssl2 $extra || exit 1
diff --git a/apps/s_client.c b/apps/s_client.c
index c071658..2f743f0 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -248,7 +248,6 @@
 	BIO_printf(bio_err," -tlsextdebug      - hex dump of all TLS extensions received\n");
 	BIO_printf(bio_err," -status           - request certificate status from server\n");
 	BIO_printf(bio_err," -no_ticket        - disable use of RFC4507bis session tickets\n");
-	BIO_printf(bio_err," -cutthrough       - enable 1-RTT full-handshake for strong ciphers\n");
 #endif
 	BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
 	}
@@ -306,7 +305,6 @@
 	EVP_PKEY *key = NULL;
 	char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
 	int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
-	int cutthrough=0;
 	int crlf=0;
 	int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
 	SSL_CTX *ctx=NULL;
@@ -537,8 +535,6 @@
 		else if	(strcmp(*argv,"-no_ticket") == 0)
 			{ off|=SSL_OP_NO_TICKET; }
 #endif
-		else if (strcmp(*argv,"-cutthrough") == 0)
-			cutthrough=1;
 		else if (strcmp(*argv,"-serverpref") == 0)
 			off|=SSL_OP_CIPHER_SERVER_PREFERENCE;
 		else if (strcmp(*argv,"-legacy_renegotiation") == 0)
@@ -729,15 +725,6 @@
 	 */
 	if (sock_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1);
 
-	/* Enable handshake cutthrough for client connections using
-	 * strong ciphers. */
-	if (cutthrough)
-		{
-		int ssl_mode = SSL_CTX_get_mode(ctx);
-		ssl_mode |= SSL_MODE_HANDSHAKE_CUTTHROUGH;
-		SSL_CTX_set_mode(ctx, ssl_mode);
-		}
-
 	if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
 	if (cipher != NULL)
 		if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index c7167f1..4e4964e 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -563,10 +563,6 @@
 /* Use small read and write buffers: (a) lazy allocate read buffers for
  * large incoming records, and (b) limit the size of outgoing records. */
 #define SSL_MODE_SMALL_BUFFERS 0x00000010L
-/* When set, clients may send application data before receipt of CCS
- * and Finished.  This mode enables full-handshakes to 'complete' in
- * one RTT. */
-#define SSL_MODE_HANDSHAKE_CUTTHROUGH 0x00000020L
 
 /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
  * they cannot be used to clear bits. */
@@ -1117,12 +1113,10 @@
 /* Is the SSL_connection established? */
 #define SSL_get_state(a)		SSL_state(a)
 #define SSL_is_init_finished(a)		(SSL_state(a) == SSL_ST_OK)
-#define SSL_in_init(a)			((SSL_state(a)&SSL_ST_INIT) && \
-                                  !SSL_cutthrough_complete(a))
+#define SSL_in_init(a)			(SSL_state(a)&SSL_ST_INIT)
 #define SSL_in_before(a)		(SSL_state(a)&SSL_ST_BEFORE)
 #define SSL_in_connect_init(a)		(SSL_state(a)&SSL_ST_CONNECT)
 #define SSL_in_accept_init(a)		(SSL_state(a)&SSL_ST_ACCEPT)
-int SSL_cutthrough_complete(const SSL *s);
 
 /* The following 2 states are kept in ssl->rstate when reads fail,
  * you should not need these */
diff --git a/include/openssl/ssl3.h b/include/openssl/ssl3.h
index 164b5f9..bf71ef9 100644
--- a/include/openssl/ssl3.h
+++ b/include/openssl/ssl3.h
@@ -465,7 +465,6 @@
 /*client */
 /* extra state */
 #define SSL3_ST_CW_FLUSH		(0x100|SSL_ST_CONNECT)
-#define SSL3_ST_CUTTHROUGH_COMPLETE (0x101|SSL_ST_CONNECT)
 /* write to server */
 #define SSL3_ST_CW_CLNT_HELLO_A		(0x110|SSL_ST_CONNECT)
 #define SSL3_ST_CW_CLNT_HELLO_B		(0x111|SSL_ST_CONNECT)
diff --git a/openssl.config b/openssl.config
index feb2068..637ffdc 100644
--- a/openssl.config
+++ b/openssl.config
@@ -75,8 +75,8 @@
         progs.patch                 \
         arm-asm.patch               \
         openssl_defs.patch          \
-        small_records.patch         \
-        handshake_cutthrough.patch"
+        small_records.patch"
+# handshake_cutthrough.patch disabled for better compatibility b/2453395
 
 OPENSSL_PATCHES_progs_SOURCES="\
 	apps/progs.h \
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index 5893064..e5138b6 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -182,13 +182,6 @@
 	
 	s->in_handshake++;
 	if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); 
-	if (SSL_get_mode(s) & SSL_MODE_HANDSHAKE_CUTTHROUGH)
-		{
-		/* Reneotiation complicates the state machine */
-		s->s3->flags |= SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS;
-		/* Send app data along with CCS/Finished */
-		s->s3->flags |= SSL3_FLAGS_DELAY_CLIENT_FINISHED;
-		}
 
 	for (;;)
 		{
@@ -457,29 +450,14 @@
 				}
 			else
 				{
-				if ((SSL_get_mode(s) & SSL_MODE_HANDSHAKE_CUTTHROUGH) && SSL_get_cipher_bits(s, NULL) >= 128)
-					{
-					if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)
-						{
-						s->state=SSL3_ST_CUTTHROUGH_COMPLETE;
-						s->s3->flags|=SSL3_FLAGS_POP_BUFFER;
-						s->s3->delay_buf_pop_ret=0;
-						}
-					else
-						{
-						s->s3->tmp.next_state=SSL3_ST_CUTTHROUGH_COMPLETE;
-						}
-					}
-				else
-					{
 #ifndef OPENSSL_NO_TLSEXT
-					/* Allow NewSessionTicket if ticket expected */
-					if (s->tlsext_ticket_expected)
-						s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
-					else
+				/* Allow NewSessionTicket if ticket expected */
+				if (s->tlsext_ticket_expected)
+					s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
+				else
 #endif
-						s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
-					}
+				
+				s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
 				}
 			s->init_num=0;
 			break;
@@ -527,24 +505,6 @@
 			s->state=s->s3->tmp.next_state;
 			break;
 
-		case SSL3_ST_CUTTHROUGH_COMPLETE:
-#ifndef OPENSSL_NO_TLSEXT
-			/* Allow NewSessionTicket if ticket expected */
-			if (s->tlsext_ticket_expected)
-				s->state=SSL3_ST_CR_SESSION_TICKET_A;
-			else
-#endif
-				s->state=SSL3_ST_CR_FINISHED_A;
-
-			/* SSL_write() will take care of flushing buffered data if
-			 * DELAY_CLIENT_FINISHED is set.
-			 */
-			if (!(s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED))
-				ssl_free_wbio_buffer(s);
-			ret = 1;
-			goto end;
-			/* break; */
-
 		case SSL_ST_OK:
 			/* clean a few things up */
 			ssl3_cleanup_key_block(s);
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 2c44bde..8fa4ab0 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -2566,22 +2566,9 @@
 
 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
 	{
-	int n,ret;
+	int ret;
 	
 	clear_sys_error();
-	if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
-		{
-		/* Deal with an application that calls SSL_read() when handshake data
- 		 * is yet to be written.
- 		 */
-		if (BIO_wpending(s->wbio) > 0)
-			{
-			s->rwstate=SSL_WRITING;
-			n=BIO_flush(s->wbio);
-			if (n <= 0) return(n);
-			s->rwstate=SSL_NOTHING;
-			}
-		}
 	if (s->s3->renegotiate) ssl3_renegotiate_check(s);
 	s->s3->in_read_app_data=1;
 	ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
diff --git a/ssl/ssl.h b/ssl/ssl.h
index c7167f1..4e4964e 100644
--- a/ssl/ssl.h
+++ b/ssl/ssl.h
@@ -563,10 +563,6 @@
 /* Use small read and write buffers: (a) lazy allocate read buffers for
  * large incoming records, and (b) limit the size of outgoing records. */
 #define SSL_MODE_SMALL_BUFFERS 0x00000010L
-/* When set, clients may send application data before receipt of CCS
- * and Finished.  This mode enables full-handshakes to 'complete' in
- * one RTT. */
-#define SSL_MODE_HANDSHAKE_CUTTHROUGH 0x00000020L
 
 /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
  * they cannot be used to clear bits. */
@@ -1117,12 +1113,10 @@
 /* Is the SSL_connection established? */
 #define SSL_get_state(a)		SSL_state(a)
 #define SSL_is_init_finished(a)		(SSL_state(a) == SSL_ST_OK)
-#define SSL_in_init(a)			((SSL_state(a)&SSL_ST_INIT) && \
-                                  !SSL_cutthrough_complete(a))
+#define SSL_in_init(a)			(SSL_state(a)&SSL_ST_INIT)
 #define SSL_in_before(a)		(SSL_state(a)&SSL_ST_BEFORE)
 #define SSL_in_connect_init(a)		(SSL_state(a)&SSL_ST_CONNECT)
 #define SSL_in_accept_init(a)		(SSL_state(a)&SSL_ST_ACCEPT)
-int SSL_cutthrough_complete(const SSL *s);
 
 /* The following 2 states are kept in ssl->rstate when reads fail,
  * you should not need these */
diff --git a/ssl/ssl3.h b/ssl/ssl3.h
index 164b5f9..bf71ef9 100644
--- a/ssl/ssl3.h
+++ b/ssl/ssl3.h
@@ -465,7 +465,6 @@
 /*client */
 /* extra state */
 #define SSL3_ST_CW_FLUSH		(0x100|SSL_ST_CONNECT)
-#define SSL3_ST_CUTTHROUGH_COMPLETE (0x101|SSL_ST_CONNECT)
 /* write to server */
 #define SSL3_ST_CW_CLNT_HELLO_A		(0x110|SSL_ST_CONNECT)
 #define SSL3_ST_CW_CLNT_HELLO_B		(0x111|SSL_ST_CONNECT)
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 0ba658e..15650da 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -2752,17 +2752,7 @@
 	SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb);
 	}
 
-int SSL_cutthrough_complete(const SSL *s)
-	{
-	return (!s->server &&                 /* cutthrough only applies to clients */
-		!s->hit &&                        /* full-handshake */
-		s->version >= SSL3_VERSION &&
-		s->s3->in_read_app_data == 0 &&   /* cutthrough only applies to write() */
-		(SSL_get_mode((SSL*)s) & SSL_MODE_HANDSHAKE_CUTTHROUGH) &&  /* cutthrough enabled */
-		SSL_get_cipher_bits(s, NULL) >= 128 &&                      /* strong cipher choosen */
-		(s->state == SSL3_ST_CR_SESSION_TICKET_A ||                 /* ready to write app-data*/
-			s->state == SSL3_ST_CR_FINISHED_A));
-	}
+
 
 #if defined(_WINDLL) && defined(OPENSSL_SYS_WIN16)
 #include "../crypto/bio/bss_file.c"
diff --git a/ssl/ssltest.c b/ssl/ssltest.c
index 438f3ab..09d3502 100644
--- a/ssl/ssltest.c
+++ b/ssl/ssltest.c
@@ -279,7 +279,6 @@
 	fprintf(stderr," -test_cipherlist - verifies the order of the ssl cipher lists\n");
 	fprintf(stderr," -c_small_records - enable client side use of small SSL record buffers\n");
 	fprintf(stderr," -s_small_records - enable server side use of small SSL record buffers\n");
-	fprintf(stderr," -cutthrough       - enable 1-RTT full-handshake for strong ciphers\n");
 	}
 
 static void print_details(SSL *c_ssl, const char *prefix)
@@ -437,7 +436,6 @@
 	int ssl_mode = 0;
 	int c_small_records=0;
 	int s_small_records=0;
-	int cutthrough = 0;
 
 	verbose = 0;
 	debug = 0;
@@ -634,10 +632,6 @@
 			{
 			s_small_records = 1;
 			}
-		else if (strcmp(*argv, "-cutthrough") == 0)
-			{
-			cutthrough = 1;
-			}
 		else
 			{
 			fprintf(stderr,"unknown option %s\n",*argv);
@@ -788,13 +782,6 @@
 		ssl_mode |= SSL_MODE_SMALL_BUFFERS;
 		SSL_CTX_set_mode(s_ctx, ssl_mode);
 		}
-	ssl_mode = 0;
-	if (cutthrough)
-		{
-		ssl_mode = SSL_CTX_get_mode(c_ctx);
-		ssl_mode = SSL_MODE_HANDSHAKE_CUTTHROUGH;
-		SSL_CTX_set_mode(c_ctx, ssl_mode);
-		}
 
 #ifndef OPENSSL_NO_DH
 	if (!no_dhe)