Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f9d8bc

Browse files
committed
disable handshake_cutthrough.patch
CTS tests exposed compatability problems for SSLSocket applications with handshake cutthrough enabled. Disabling until they can be resolved. b/2586347 Change-Id: If2e43f50712780e1905c86b64ac2f89e95e7cc95
1 parent faa58bc commit 7f9d8bc

12 files changed

Lines changed: 13 additions & 123 deletions

File tree

README.android

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The following steps are recommended for porting new OpenSSL versions.
5050
7) Run tests to make sure things are working:
5151

5252
(cd android.testssl/ && ./testssl.sh)
53+
adb shell run-core-tests tests.xnet.AllTests
5354

5455
8) Do a full build before checking in:
5556

android.testssl/testssl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ $ssltest -server_auth -client_auth -s_small_records $CA $extra || exit 1
7979
echo test sslv2/sslv3 with both client and server authentication and small client and server buffers
8080
$ssltest -server_auth -client_auth -c_small_records -s_small_records $CA $extra || exit 1
8181

82-
echo test sslv2/sslv3 with both client and server authentication and handshake cutthrough
83-
$ssltest -server_auth -client_auth -cutthrough $CA $extra || exit 1
8482

8583
echo test sslv2 via BIO pair
8684
$ssltest -bio_pair -ssl2 $extra || exit 1

apps/s_client.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ static void sc_usage(void)
248248
BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n");
249249
BIO_printf(bio_err," -status - request certificate status from server\n");
250250
BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n");
251-
BIO_printf(bio_err," -cutthrough - enable 1-RTT full-handshake for strong ciphers\n");
252251
#endif
253252
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
254253
}
@@ -306,7 +305,6 @@ int MAIN(int argc, char **argv)
306305
EVP_PKEY *key = NULL;
307306
char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
308307
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
309-
int cutthrough=0;
310308
int crlf=0;
311309
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
312310
SSL_CTX *ctx=NULL;
@@ -537,8 +535,6 @@ int MAIN(int argc, char **argv)
537535
else if (strcmp(*argv,"-no_ticket") == 0)
538536
{ off|=SSL_OP_NO_TICKET; }
539537
#endif
540-
else if (strcmp(*argv,"-cutthrough") == 0)
541-
cutthrough=1;
542538
else if (strcmp(*argv,"-serverpref") == 0)
543539
off|=SSL_OP_CIPHER_SERVER_PREFERENCE;
544540
else if (strcmp(*argv,"-legacy_renegotiation") == 0)
@@ -729,15 +725,6 @@ int MAIN(int argc, char **argv)
729725
*/
730726
if (sock_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1);
731727

732-
/* Enable handshake cutthrough for client connections using
733-
* strong ciphers. */
734-
if (cutthrough)
735-
{
736-
int ssl_mode = SSL_CTX_get_mode(ctx);
737-
ssl_mode |= SSL_MODE_HANDSHAKE_CUTTHROUGH;
738-
SSL_CTX_set_mode(ctx, ssl_mode);
739-
}
740-
741728
if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
742729
if (cipher != NULL)
743730
if(!SSL_CTX_set_cipher_list(ctx,cipher)) {

include/openssl/ssl.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,6 @@ typedef struct ssl_session_st
563563
/* Use small read and write buffers: (a) lazy allocate read buffers for
564564
* large incoming records, and (b) limit the size of outgoing records. */
565565
#define SSL_MODE_SMALL_BUFFERS 0x00000010L
566-
/* When set, clients may send application data before receipt of CCS
567-
* and Finished. This mode enables full-handshakes to 'complete' in
568-
* one RTT. */
569-
#define SSL_MODE_HANDSHAKE_CUTTHROUGH 0x00000020L
570566

571567
/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
572568
* they cannot be used to clear bits. */
@@ -1117,12 +1113,10 @@ extern "C" {
11171113
/* Is the SSL_connection established? */
11181114
#define SSL_get_state(a) SSL_state(a)
11191115
#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK)
1120-
#define SSL_in_init(a) ((SSL_state(a)&SSL_ST_INIT) && \
1121-
!SSL_cutthrough_complete(a))
1116+
#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT)
11221117
#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE)
11231118
#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT)
11241119
#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT)
1125-
int SSL_cutthrough_complete(const SSL *s);
11261120

11271121
/* The following 2 states are kept in ssl->rstate when reads fail,
11281122
* you should not need these */

include/openssl/ssl3.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ typedef struct ssl3_state_st
465465
/*client */
466466
/* extra state */
467467
#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT)
468-
#define SSL3_ST_CUTTHROUGH_COMPLETE (0x101|SSL_ST_CONNECT)
469468
/* write to server */
470469
#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT)
471470
#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT)

openssl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ OPENSSL_PATCHES="\
7474
progs.patch \
7575
arm-asm.patch \
7676
small_records.patch \
77-
handshake_cutthrough.patch \
7877
bad_version.patch"
78+
# Disabled for compatibility b/2586347
79+
# handshake_cutthrough.patch
7980

8081
OPENSSL_PATCHES_progs_SOURCES="\
8182
apps/progs.h \

ssl/s3_clnt.c

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,6 @@ int ssl3_connect(SSL *s)
182182

183183
s->in_handshake++;
184184
if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
185-
if (SSL_get_mode(s) & SSL_MODE_HANDSHAKE_CUTTHROUGH)
186-
{
187-
/* Renegotiation complicates the state machine */
188-
s->s3->flags |= SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS;
189-
#if 0 /* Send app data in separate packet, otherwise, some particular site
190-
* (only one site so far) closes the socket.
191-
* Note: there is a very small chance that two TCP packets
192-
* could be arriving at server combined into a single TCP packet,
193-
* then trigger that site to break. We haven't encounter that though.
194-
*/
195-
/* Send app data along with CCS/Finished */
196-
s->s3->flags |= SSL3_FLAGS_DELAY_CLIENT_FINISHED;
197-
#endif
198-
}
199185

200186
for (;;)
201187
{
@@ -464,29 +450,14 @@ int ssl3_connect(SSL *s)
464450
}
465451
else
466452
{
467-
if ((SSL_get_mode(s) & SSL_MODE_HANDSHAKE_CUTTHROUGH) && SSL_get_cipher_bits(s, NULL) >= 128)
468-
{
469-
if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)
470-
{
471-
s->state=SSL3_ST_CUTTHROUGH_COMPLETE;
472-
s->s3->flags|=SSL3_FLAGS_POP_BUFFER;
473-
s->s3->delay_buf_pop_ret=0;
474-
}
475-
else
476-
{
477-
s->s3->tmp.next_state=SSL3_ST_CUTTHROUGH_COMPLETE;
478-
}
479-
}
480-
else
481-
{
482453
#ifndef OPENSSL_NO_TLSEXT
483-
/* Allow NewSessionTicket if ticket expected */
484-
if (s->tlsext_ticket_expected)
485-
s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
486-
else
454+
/* Allow NewSessionTicket if ticket expected */
455+
if (s->tlsext_ticket_expected)
456+
s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
457+
else
487458
#endif
488-
s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
489-
}
459+
460+
s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
490461
}
491462
s->init_num=0;
492463
break;
@@ -534,24 +505,6 @@ int ssl3_connect(SSL *s)
534505
s->state=s->s3->tmp.next_state;
535506
break;
536507

537-
case SSL3_ST_CUTTHROUGH_COMPLETE:
538-
#ifndef OPENSSL_NO_TLSEXT
539-
/* Allow NewSessionTicket if ticket expected */
540-
if (s->tlsext_ticket_expected)
541-
s->state=SSL3_ST_CR_SESSION_TICKET_A;
542-
else
543-
#endif
544-
s->state=SSL3_ST_CR_FINISHED_A;
545-
546-
/* SSL_write() will take care of flushing buffered data if
547-
* DELAY_CLIENT_FINISHED is set.
548-
*/
549-
if (!(s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED))
550-
ssl_free_wbio_buffer(s);
551-
ret = 1;
552-
goto end;
553-
/* break; */
554-
555508
case SSL_ST_OK:
556509
/* clean a few things up */
557510
ssl3_cleanup_key_block(s);

ssl/s3_lib.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,22 +2566,9 @@ int ssl3_write(SSL *s, const void *buf, int len)
25662566

25672567
static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
25682568
{
2569-
int n,ret;
2569+
int ret;
25702570

25712571
clear_sys_error();
2572-
if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
2573-
{
2574-
/* Deal with an application that calls SSL_read() when handshake data
2575-
* is yet to be written.
2576-
*/
2577-
if (BIO_wpending(s->wbio) > 0)
2578-
{
2579-
s->rwstate=SSL_WRITING;
2580-
n=BIO_flush(s->wbio);
2581-
if (n <= 0) return(n);
2582-
s->rwstate=SSL_NOTHING;
2583-
}
2584-
}
25852572
if (s->s3->renegotiate) ssl3_renegotiate_check(s);
25862573
s->s3->in_read_app_data=1;
25872574
ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);

ssl/ssl.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,6 @@ typedef struct ssl_session_st
563563
/* Use small read and write buffers: (a) lazy allocate read buffers for
564564
* large incoming records, and (b) limit the size of outgoing records. */
565565
#define SSL_MODE_SMALL_BUFFERS 0x00000010L
566-
/* When set, clients may send application data before receipt of CCS
567-
* and Finished. This mode enables full-handshakes to 'complete' in
568-
* one RTT. */
569-
#define SSL_MODE_HANDSHAKE_CUTTHROUGH 0x00000020L
570566

571567
/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
572568
* they cannot be used to clear bits. */
@@ -1117,12 +1113,10 @@ extern "C" {
11171113
/* Is the SSL_connection established? */
11181114
#define SSL_get_state(a) SSL_state(a)
11191115
#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK)
1120-
#define SSL_in_init(a) ((SSL_state(a)&SSL_ST_INIT) && \
1121-
!SSL_cutthrough_complete(a))
1116+
#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT)
11221117
#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE)
11231118
#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT)
11241119
#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT)
1125-
int SSL_cutthrough_complete(const SSL *s);
11261120

11271121
/* The following 2 states are kept in ssl->rstate when reads fail,
11281122
* you should not need these */

ssl/ssl3.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ typedef struct ssl3_state_st
465465
/*client */
466466
/* extra state */
467467
#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT)
468-
#define SSL3_ST_CUTTHROUGH_COMPLETE (0x101|SSL_ST_CONNECT)
469468
/* write to server */
470469
#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT)
471470
#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT)

0 commit comments

Comments
 (0)