Skip to content

Commit 3bdd672

Browse files
committed
deps: openssl: openssl#8096
Cherry-pick: openssl/openssl@4af5836 Original-Pr: openssl/openssl#8096
1 parent 8a273f1 commit 3bdd672

File tree

7 files changed

+53
-61
lines changed

7 files changed

+53
-61
lines changed

deps/openssl/openssl/CHANGES

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
https://github.com/openssl/openssl/commits/ and pick the appropriate
88
release branch.
99

10+
11+
Changes between 1.1.1a and 1.1.1b [xx XXX xxxx]
12+
13+
*) Change the info callback signals for the start and end of a post-handshake
14+
message exchange in TLSv1.3. In 1.1.1/1.1.1a we used SSL_CB_HANDSHAKE_START
15+
and SSL_CB_HANDSHAKE_DONE. Experience has shown that many applications get
16+
confused by this and assume that a TLSv1.2 renegotiation has started. This
17+
can break KeyUpdate handling. Instead we now use
18+
SSL_CB_POST_HANDSHAKE_START and SSL_CB_POST_HANDSHAKE_DONE. This could
19+
break some applications that were expecting the old signals. However
20+
without this KeyUpdate is not usable for many applications.
21+
[Matt Caswell]
22+
1023
Changes between 1.1.1 and 1.1.1a [20 Nov 2018]
1124

1225
*) Timing vulnerability in DSA signature generation

deps/openssl/openssl/doc/man3/SSL_CTX_set_info_callback.pod

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,13 @@ Callback has been called due to an alert being sent or received.
9292

9393
=item SSL_CB_HANDSHAKE_START
9494

95-
Callback has been called because a new handshake is started. In TLSv1.3 this is
96-
also used for the start of post-handshake message exchanges such as for the
97-
exchange of session tickets, or for key updates. It also occurs when resuming a
98-
handshake following a pause to handle early data.
95+
Callback has been called because a new handshake is started. It also occurs when
96+
resuming a handshake following a pause to handle early data.
9997

100-
=item SSL_CB_HANDSHAKE_DONE 0x20
98+
=item SSL_CB_HANDSHAKE_DONE
10199

102-
Callback has been called because a handshake is finished. In TLSv1.3 this is
103-
also used at the end of an exchange of post-handshake messages such as for
104-
session tickets or key updates. It also occurs if the handshake is paused to
105-
allow the exchange of early data.
100+
Callback has been called because a handshake is finished. It also occurs if the
101+
handshake is paused to allow the exchange of early data.
106102

107103
=back
108104

deps/openssl/openssl/include/openssl/ssl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,8 @@ typedef enum {
10541054
# define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
10551055
# define SSL_CB_HANDSHAKE_START 0x10
10561056
# define SSL_CB_HANDSHAKE_DONE 0x20
1057+
# define SSL_CB_POST_HANDSHAKE_START 0x40
1058+
# define SSL_CB_POST_HANDSHAKE_DONE 0x80
10571059

10581060
/* Is the SSL_connection established? */
10591061
# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a))

deps/openssl/openssl/ssl/statem/statem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ static int state_machine(SSL *s, int server)
342342
}
343343

344344
s->server = server;
345-
if (cb != NULL)
346-
cb(s, SSL_CB_HANDSHAKE_START, 1);
345+
if (cb != NULL) {
346+
if (SSL_IS_FIRST_HANDSHAKE(s) || !SSL_IS_TLS13(s))
347+
cb(s, SSL_CB_HANDSHAKE_START, 1);
348+
}
347349

348350
/*
349351
* Fatal errors in this block don't send an alert because we have

deps/openssl/openssl/ssl/statem/statem_lib.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk)
10281028
WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop)
10291029
{
10301030
void (*cb) (const SSL *ssl, int type, int val) = NULL;
1031+
int cleanuphand = s->statem.cleanuphand;
10311032

10321033
if (clearbufs) {
10331034
if (!SSL_IS_DTLS(s)) {
@@ -1054,7 +1055,7 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop)
10541055
* Only set if there was a Finished message and this isn't after a TLSv1.3
10551056
* post handshake exchange
10561057
*/
1057-
if (s->statem.cleanuphand) {
1058+
if (cleanuphand) {
10581059
/* skipped if we just sent a HelloRequest */
10591060
s->renegotiate = 0;
10601061
s->new_session = 0;
@@ -1132,8 +1133,12 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop)
11321133
/* The callback may expect us to not be in init at handshake done */
11331134
ossl_statem_set_in_init(s, 0);
11341135

1135-
if (cb != NULL)
1136-
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
1136+
if (cb != NULL) {
1137+
if (cleanuphand
1138+
|| !SSL_IS_TLS13(s)
1139+
|| SSL_IS_FIRST_HANDSHAKE(s))
1140+
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
1141+
}
11371142

11381143
if (!stop) {
11391144
/* If we've got more work to do we go back into init */

deps/openssl/openssl/ssl/statem/statem_srvr.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,7 +4028,6 @@ int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt)
40284028
uint64_t nonce;
40294029
static const unsigned char nonce_label[] = "resumption";
40304030
const EVP_MD *md = ssl_handshake_md(s);
4031-
void (*cb) (const SSL *ssl, int type, int val) = NULL;
40324031
int hashleni = EVP_MD_size(md);
40334032

40344033
/* Ensure cast to size_t is safe */
@@ -4040,24 +4039,6 @@ int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt)
40404039
}
40414040
hashlen = (size_t)hashleni;
40424041

4043-
if (s->info_callback != NULL)
4044-
cb = s->info_callback;
4045-
else if (s->ctx->info_callback != NULL)
4046-
cb = s->ctx->info_callback;
4047-
4048-
if (cb != NULL) {
4049-
/*
4050-
* We don't start and stop the handshake in between each ticket when
4051-
* sending more than one - but it should appear that way to the info
4052-
* callback.
4053-
*/
4054-
if (s->sent_tickets != 0) {
4055-
ossl_statem_set_in_init(s, 0);
4056-
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
4057-
ossl_statem_set_in_init(s, 1);
4058-
}
4059-
cb(s, SSL_CB_HANDSHAKE_START, 1);
4060-
}
40614042
/*
40624043
* If we already sent one NewSessionTicket, or we resumed then
40634044
* s->session may already be in a cache and so we must not modify it.

deps/openssl/openssl/test/sslapitest.c

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4710,39 +4710,31 @@ static struct info_cb_states_st {
47104710
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWSC"},
47114711
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"},
47124712
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
4713-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4714-
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4715-
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TWST"},
4716-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
4717-
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4718-
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TRCH"},
4719-
{SSL_CB_LOOP, "TWSH"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"},
4720-
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL},
4721-
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
4722-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4723-
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4724-
{SSL_CB_EXIT, NULL}, {0, NULL},
4713+
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
4714+
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_ALERT, NULL},
4715+
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
4716+
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
4717+
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWFIN"},
4718+
{SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"},
4719+
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4720+
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
47254721
}, {
47264722
/* TLSv1.3 client followed by resumption */
47274723
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
47284724
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TWCH"},
47294725
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"}, {SSL_CB_LOOP, "TRSC"},
47304726
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"},
47314727
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4732-
{SSL_CB_EXIT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4733-
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
4734-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
4735-
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "SSLOK "},
4736-
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
4737-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
4728+
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "},
4729+
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "},
4730+
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL},
47384731
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
47394732
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL},
47404733
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
47414734
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
47424735
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
4743-
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "SSLOK "},
4744-
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
4745-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {0, NULL},
4736+
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
4737+
{SSL_CB_EXIT, NULL}, {0, NULL},
47464738
}, {
47474739
/* TLSv1.3 server, early_data */
47484740
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
@@ -4751,8 +4743,7 @@ static struct info_cb_states_st {
47514743
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
47524744
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TED"},
47534745
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TWEOED"}, {SSL_CB_LOOP, "TRFIN"},
4754-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4755-
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4746+
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
47564747
{SSL_CB_EXIT, NULL}, {0, NULL},
47574748
}, {
47584749
/* TLSv1.3 client, early_data */
@@ -4763,9 +4754,8 @@ static struct info_cb_states_st {
47634754
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
47644755
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TPEDE"}, {SSL_CB_LOOP, "TWEOED"},
47654756
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
4766-
{SSL_CB_EXIT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
4767-
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
4768-
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {0, NULL},
4757+
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "},
4758+
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
47694759
}, {
47704760
{0, NULL},
47714761
}
@@ -4804,8 +4794,11 @@ static void sslapi_info_callback(const SSL *s, int where, int ret)
48044794
return;
48054795
}
48064796

4807-
/* Check that, if we've got SSL_CB_HANDSHAKE_DONE we are not in init */
4808-
if ((where & SSL_CB_HANDSHAKE_DONE) && SSL_in_init((SSL *)s) != 0) {
4797+
/*
4798+
* Check that, if we've got SSL_CB_HANDSHAKE_DONE we are not in init
4799+
*/
4800+
if ((where & SSL_CB_HANDSHAKE_DONE)
4801+
&& SSL_in_init((SSL *)s) != 0) {
48094802
info_cb_failed = 1;
48104803
return;
48114804
}

0 commit comments

Comments
 (0)