diff options
author | tb <> | 2021-03-27 17:56:28 +0000 |
---|---|---|
committer | tb <> | 2021-03-27 17:56:28 +0000 |
commit | c181c81fb01592ad1d49ebf7afa9676c41a32aaf (patch) | |
tree | ac68380783b8a8e28d9f271506951e261e2e33a4 | |
parent | 5d4b8b6f9a8de0dda3e5c12178bbb427e7f32037 (diff) | |
download | openbsd-c181c81fb01592ad1d49ebf7afa9676c41a32aaf.tar.gz openbsd-c181c81fb01592ad1d49ebf7afa9676c41a32aaf.tar.bz2 openbsd-c181c81fb01592ad1d49ebf7afa9676c41a32aaf.zip |
Garbage collect s->internal->type
This variable is used in the legacy stack to decide whether we are
a server or a client. That's what s->server is for...
The new TLSv1.3 stack failed to set s->internal->type, which resulted
in hilarious mishandling of previous_{client,server}_finished. Indeed,
both client and server would first store the client's verify_data in
previous_server_finished and later overwrite it with the server's
verify_data. Consequently, renegotiation has been completely broken
for more than a year. In fact, server side renegotiation was broken
during the 6.5 release cycle. Clearly, no-one uses this.
This commit fixes client side renegotiation and restores the previous
behavior of SSL_get_client_CA_list(). Server side renegotiation will
be fixed in a later commit.
ok jsing
-rw-r--r-- | src/lib/libssl/ssl_both.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/ssl_cert.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_clnt.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_srvr.c | 4 |
6 files changed, 9 insertions, 18 deletions
diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c index 6625286daf..789ab01213 100644 --- a/src/lib/libssl/ssl_both.c +++ b/src/lib/libssl/ssl_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_both.c,v 1.25 2021/03/24 18:44:00 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_both.c,v 1.26 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -181,7 +181,7 @@ ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) | |||
181 | S3I(s)->tmp.finish_md_len = md_len; | 181 | S3I(s)->tmp.finish_md_len = md_len; |
182 | 182 | ||
183 | /* Copy finished so we can use it for renegotiation checks. */ | 183 | /* Copy finished so we can use it for renegotiation checks. */ |
184 | if (s->internal->type == SSL_ST_CONNECT) { | 184 | if (!s->server) { |
185 | memcpy(S3I(s)->previous_client_finished, | 185 | memcpy(S3I(s)->previous_client_finished, |
186 | S3I(s)->tmp.finish_md, md_len); | 186 | S3I(s)->tmp.finish_md, md_len); |
187 | S3I(s)->previous_client_finished_len = md_len; | 187 | S3I(s)->previous_client_finished_len = md_len; |
@@ -285,7 +285,7 @@ ssl3_get_finished(SSL *s, int a, int b) | |||
285 | 285 | ||
286 | /* Copy finished so we can use it for renegotiation checks. */ | 286 | /* Copy finished so we can use it for renegotiation checks. */ |
287 | OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); | 287 | OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); |
288 | if (s->internal->type == SSL_ST_ACCEPT) { | 288 | if (s->server) { |
289 | memcpy(S3I(s)->previous_client_finished, | 289 | memcpy(S3I(s)->previous_client_finished, |
290 | S3I(s)->tmp.peer_finish_md, md_len); | 290 | S3I(s)->tmp.peer_finish_md, md_len); |
291 | S3I(s)->previous_client_finished_len = md_len; | 291 | S3I(s)->previous_client_finished_len = md_len; |
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c index 2e0dca58ea..03ef8565ac 100644 --- a/src/lib/libssl/ssl_cert.c +++ b/src/lib/libssl/ssl_cert.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_cert.c,v 1.80 2020/11/20 08:08:02 tb Exp $ */ | 1 | /* $OpenBSD: ssl_cert.c,v 1.81 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -505,7 +505,7 @@ SSL_CTX_get_client_CA_list(const SSL_CTX *ctx) | |||
505 | STACK_OF(X509_NAME) * | 505 | STACK_OF(X509_NAME) * |
506 | SSL_get_client_CA_list(const SSL *s) | 506 | SSL_get_client_CA_list(const SSL *s) |
507 | { | 507 | { |
508 | if (s->internal->type == SSL_ST_CONNECT) { | 508 | if (!s->server) { |
509 | /* We are in the client. */ | 509 | /* We are in the client. */ |
510 | if ((s->version >> 8) == SSL3_VERSION_MAJOR) | 510 | if ((s->version >> 8) == SSL3_VERSION_MAJOR) |
511 | return (S3I(s)->tmp.ca_names); | 511 | return (S3I(s)->tmp.ca_names); |
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 984ade0957..63adacd9cf 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_clnt.c,v 1.88 2021/03/24 18:44:00 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.89 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -226,8 +226,6 @@ ssl3_connect(SSL *s) | |||
226 | goto end; | 226 | goto end; |
227 | } | 227 | } |
228 | 228 | ||
229 | s->internal->type = SSL_ST_CONNECT; | ||
230 | |||
231 | if (!ssl3_setup_init_buffer(s)) { | 229 | if (!ssl3_setup_init_buffer(s)) { |
232 | ret = -1; | 230 | ret = -1; |
233 | goto end; | 231 | goto end; |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index e3e0c974af..c77fdd77e9 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.252 2021/03/24 18:44:00 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.253 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -186,8 +186,6 @@ SSL_clear(SSL *s) | |||
186 | return (0); | 186 | return (0); |
187 | } | 187 | } |
188 | 188 | ||
189 | s->internal->type = 0; | ||
190 | |||
191 | s->version = s->method->internal->version; | 189 | s->version = s->method->internal->version; |
192 | s->client_version = s->version; | 190 | s->client_version = s->version; |
193 | s->internal->rwstate = SSL_NOTHING; | 191 | s->internal->rwstate = SSL_NOTHING; |
@@ -2494,7 +2492,6 @@ SSL_dup(SSL *s) | |||
2494 | goto err; | 2492 | goto err; |
2495 | 2493 | ||
2496 | ret->version = s->version; | 2494 | ret->version = s->version; |
2497 | ret->internal->type = s->internal->type; | ||
2498 | ret->method = s->method; | 2495 | ret->method = s->method; |
2499 | 2496 | ||
2500 | if (s->session != NULL) { | 2497 | if (s->session != NULL) { |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index c8c7ca5472..7f197bbcdf 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.330 2021/03/24 18:44:00 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.331 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -755,8 +755,6 @@ typedef struct ssl_internal_st { | |||
755 | 755 | ||
756 | /* XXX non-callback */ | 756 | /* XXX non-callback */ |
757 | 757 | ||
758 | int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ | ||
759 | |||
760 | /* This holds a variable that indicates what we were doing | 758 | /* This holds a variable that indicates what we were doing |
761 | * when a 0 or -1 is returned. This is needed for | 759 | * when a 0 or -1 is returned. This is needed for |
762 | * non-blocking IO so we know what request needs re-doing when | 760 | * non-blocking IO so we know what request needs re-doing when |
diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index 047087c1c9..aea8d67260 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/lib/libssl/ssl_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_srvr.c,v 1.99 2021/03/24 18:44:00 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_srvr.c,v 1.100 2021/03/27 17:56:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -227,8 +227,6 @@ ssl3_accept(SSL *s) | |||
227 | goto end; | 227 | goto end; |
228 | } | 228 | } |
229 | 229 | ||
230 | s->internal->type = SSL_ST_ACCEPT; | ||
231 | |||
232 | if (!ssl3_setup_init_buffer(s)) { | 230 | if (!ssl3_setup_init_buffer(s)) { |
233 | ret = -1; | 231 | ret = -1; |
234 | goto end; | 232 | goto end; |