summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2021-07-01 17:53:39 +0000
committerjsing <>2021-07-01 17:53:39 +0000
commita0afc1b4032278e02db285a67fa2e295e9970176 (patch)
tree57d97f559edf3211313bbaee593ec7483ded13e4
parentbd1a6cca8085312ddc750a73ac51cba9231bfcf6 (diff)
downloadopenbsd-a0afc1b4032278e02db285a67fa2e295e9970176.tar.gz
openbsd-a0afc1b4032278e02db285a67fa2e295e9970176.tar.bz2
openbsd-a0afc1b4032278e02db285a67fa2e295e9970176.zip
Merge SSL_METHOD_INTERNAL into SSL_METHOD.
Now that SSL_METHOD is opaque and in internal headers, we can remove SSL_METHOD_INTERNAL by merging it back into SSL_METHOD. ok tb@
-rw-r--r--src/lib/libssl/bio_ssl.c6
-rw-r--r--src/lib/libssl/d1_both.c14
-rw-r--r--src/lib/libssl/d1_lib.c4
-rw-r--r--src/lib/libssl/s3_lib.c19
-rw-r--r--src/lib/libssl/ssl_both.c6
-rw-r--r--src/lib/libssl/ssl_lib.c62
-rw-r--r--src/lib/libssl/ssl_locl.h18
-rw-r--r--src/lib/libssl/ssl_methods.c130
-rw-r--r--src/lib/libssl/ssl_packet.c5
-rw-r--r--src/lib/libssl/ssl_versions.c21
-rw-r--r--src/lib/libssl/t1_enc.c4
-rw-r--r--src/lib/libssl/t1_lib.c6
-rw-r--r--src/lib/libssl/tls13_handshake.c4
-rw-r--r--src/lib/libssl/tls13_legacy.c16
-rw-r--r--src/lib/libssl/tls13_server.c6
15 files changed, 126 insertions, 195 deletions
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c
index 460b09fd87..bb40b2a6f7 100644
--- a/src/lib/libssl/bio_ssl.c
+++ b/src/lib/libssl/bio_ssl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_ssl.c,v 1.30 2021/06/11 11:13:53 jsing Exp $ */ 1/* $OpenBSD: bio_ssl.c,v 1.31 2021/07/01 17:53:39 jsing 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 *
@@ -294,10 +294,10 @@ ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
294 SSL_shutdown(ssl); 294 SSL_shutdown(ssl);
295 295
296 if (ssl->internal->handshake_func == 296 if (ssl->internal->handshake_func ==
297 ssl->method->internal->ssl_connect) 297 ssl->method->ssl_connect)
298 SSL_set_connect_state(ssl); 298 SSL_set_connect_state(ssl);
299 else if (ssl->internal->handshake_func == 299 else if (ssl->internal->handshake_func ==
300 ssl->method->internal->ssl_accept) 300 ssl->method->ssl_accept)
301 SSL_set_accept_state(ssl); 301 SSL_set_accept_state(ssl);
302 302
303 SSL_clear(ssl); 303 SSL_clear(ssl);
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c
index 52189128c8..2e5e86641c 100644
--- a/src/lib/libssl/d1_both.c
+++ b/src/lib/libssl/d1_both.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_both.c,v 1.75 2021/06/11 17:29:48 jsing Exp $ */ 1/* $OpenBSD: d1_both.c,v 1.76 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -600,7 +600,7 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
600 unsigned char devnull [256]; 600 unsigned char devnull [256];
601 601
602 while (frag_len) { 602 while (frag_len) {
603 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 603 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
604 devnull, frag_len > sizeof(devnull) ? 604 devnull, frag_len > sizeof(devnull) ?
605 sizeof(devnull) : frag_len, 0); 605 sizeof(devnull) : frag_len, 0);
606 if (i <= 0) 606 if (i <= 0)
@@ -612,7 +612,7 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
612 } 612 }
613 613
614 /* read the body of the fragment (header has already been read */ 614 /* read the body of the fragment (header has already been read */
615 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 615 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
616 frag->fragment + msg_hdr->frag_off, frag_len, 0); 616 frag->fragment + msg_hdr->frag_off, frag_len, 0);
617 if (i <= 0 || (unsigned long)i != frag_len) 617 if (i <= 0 || (unsigned long)i != frag_len)
618 goto err; 618 goto err;
@@ -690,7 +690,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
690 unsigned char devnull [256]; 690 unsigned char devnull [256];
691 691
692 while (frag_len) { 692 while (frag_len) {
693 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 693 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
694 devnull, frag_len > sizeof(devnull) ? 694 devnull, frag_len > sizeof(devnull) ?
695 sizeof(devnull) : frag_len, 0); 695 sizeof(devnull) : frag_len, 0);
696 if (i <= 0) 696 if (i <= 0)
@@ -712,7 +712,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
712 712
713 if (frag_len) { 713 if (frag_len) {
714 /* read the body of the fragment (header has already been read */ 714 /* read the body of the fragment (header has already been read */
715 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 715 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
716 frag->fragment, frag_len, 0); 716 frag->fragment, frag_len, 0);
717 if (i <= 0 || (unsigned long)i != frag_len) 717 if (i <= 0 || (unsigned long)i != frag_len)
718 goto err; 718 goto err;
@@ -756,7 +756,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
756 } 756 }
757 757
758 /* read handshake message header */ 758 /* read handshake message header */
759 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, wire, 759 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, wire,
760 DTLS1_HM_HEADER_LENGTH, 0); 760 DTLS1_HM_HEADER_LENGTH, 0);
761 if (i <= 0) /* nbio, or an error */ 761 if (i <= 0) /* nbio, or an error */
762 { 762 {
@@ -825,7 +825,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
825 if (frag_len > 0) { 825 if (frag_len > 0) {
826 unsigned char *p = (unsigned char *)s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH; 826 unsigned char *p = (unsigned char *)s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH;
827 827
828 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 828 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
829 &p[frag_off], frag_len, 0); 829 &p[frag_off], frag_len, 0);
830 /* XDTLS: fix this--message fragments cannot span multiple packets */ 830 /* XDTLS: fix this--message fragments cannot span multiple packets */
831 if (i <= 0) { 831 if (i <= 0) {
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c
index 66895a361f..6d9959ff43 100644
--- a/src/lib/libssl/d1_lib.c
+++ b/src/lib/libssl/d1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_lib.c,v 1.56 2021/06/19 16:52:47 jsing Exp $ */ 1/* $OpenBSD: d1_lib.c,v 1.57 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -100,7 +100,7 @@ dtls1_new(SSL *s)
100 if (s->server) 100 if (s->server)
101 s->d1->internal->cookie_len = sizeof(D1I(s)->cookie); 101 s->d1->internal->cookie_len = sizeof(D1I(s)->cookie);
102 102
103 s->method->internal->ssl_clear(s); 103 s->method->ssl_clear(s);
104 return (1); 104 return (1);
105 105
106 err: 106 err:
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 0cdf9edd2f..125c108f02 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.211 2021/06/30 18:07:50 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.212 2021/07/01 17:53:39 jsing 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 *
@@ -1548,7 +1548,7 @@ ssl3_new(SSL *s)
1548 return (0); 1548 return (0);
1549 } 1549 }
1550 1550
1551 s->method->internal->ssl_clear(s); 1551 s->method->ssl_clear(s);
1552 1552
1553 return (1); 1553 return (1);
1554} 1554}
@@ -2688,7 +2688,7 @@ ssl3_shutdown(SSL *s)
2688 } 2688 }
2689 } else if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) { 2689 } else if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) {
2690 /* If we are waiting for a close from our peer, we are closed */ 2690 /* If we are waiting for a close from our peer, we are closed */
2691 s->method->internal->ssl_read_bytes(s, 0, NULL, 0, 0); 2691 s->method->ssl_read_bytes(s, 0, NULL, 0, 0);
2692 if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) { 2692 if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) {
2693 return(-1); /* return WANT_READ */ 2693 return(-1); /* return WANT_READ */
2694 } 2694 }
@@ -2709,8 +2709,8 @@ ssl3_write(SSL *s, const void *buf, int len)
2709 if (S3I(s)->renegotiate) 2709 if (S3I(s)->renegotiate)
2710 ssl3_renegotiate_check(s); 2710 ssl3_renegotiate_check(s);
2711 2711
2712 return s->method->internal->ssl_write_bytes(s, 2712 return s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA,
2713 SSL3_RT_APPLICATION_DATA, buf, len); 2713 buf, len);
2714} 2714}
2715 2715
2716static int 2716static int
@@ -2722,8 +2722,9 @@ ssl3_read_internal(SSL *s, void *buf, int len, int peek)
2722 if (S3I(s)->renegotiate) 2722 if (S3I(s)->renegotiate)
2723 ssl3_renegotiate_check(s); 2723 ssl3_renegotiate_check(s);
2724 S3I(s)->in_read_app_data = 1; 2724 S3I(s)->in_read_app_data = 1;
2725 ret = s->method->internal->ssl_read_bytes(s, 2725
2726 SSL3_RT_APPLICATION_DATA, buf, len, peek); 2726 ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
2727 peek);
2727 if ((ret == -1) && (S3I(s)->in_read_app_data == 2)) { 2728 if ((ret == -1) && (S3I(s)->in_read_app_data == 2)) {
2728 /* 2729 /*
2729 * ssl3_read_bytes decided to call s->internal->handshake_func, 2730 * ssl3_read_bytes decided to call s->internal->handshake_func,
@@ -2733,8 +2734,8 @@ ssl3_read_internal(SSL *s, void *buf, int len, int peek)
2733 * handshake processing and try to read application data again. 2734 * handshake processing and try to read application data again.
2734 */ 2735 */
2735 s->internal->in_handshake++; 2736 s->internal->in_handshake++;
2736 ret = s->method->internal->ssl_read_bytes(s, 2737 ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA,
2737 SSL3_RT_APPLICATION_DATA, buf, len, peek); 2738 buf, len, peek);
2738 s->internal->in_handshake--; 2739 s->internal->in_handshake--;
2739 } else 2740 } else
2740 S3I(s)->in_read_app_data = 0; 2741 S3I(s)->in_read_app_data = 0;
diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c
index d3d4883b35..03c5a2f1e9 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.32 2021/06/11 11:13:53 jsing Exp $ */ 1/* $OpenBSD: ssl_both.c,v 1.33 2021/07/01 17:53:39 jsing 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 *
@@ -433,7 +433,7 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
433 433
434 do { 434 do {
435 while (s->internal->init_num < 4) { 435 while (s->internal->init_num < 4) {
436 i = s->method->internal->ssl_read_bytes(s, 436 i = s->method->ssl_read_bytes(s,
437 SSL3_RT_HANDSHAKE, &p[s->internal->init_num], 437 SSL3_RT_HANDSHAKE, &p[s->internal->init_num],
438 4 - s->internal->init_num, 0); 438 4 - s->internal->init_num, 0);
439 if (i <= 0) { 439 if (i <= 0) {
@@ -500,7 +500,7 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
500 p = s->internal->init_msg; 500 p = s->internal->init_msg;
501 n = S3I(s)->hs.tls12.message_size - s->internal->init_num; 501 n = S3I(s)->hs.tls12.message_size - s->internal->init_num;
502 while (n > 0) { 502 while (n > 0) {
503 i = s->method->internal->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, 503 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE,
504 &p[s->internal->init_num], n, 0); 504 &p[s->internal->init_num], n, 0);
505 if (i <= 0) { 505 if (i <= 0) {
506 s->internal->rwstate = SSL_READING; 506 s->internal->rwstate = SSL_READING;
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index dd46bf9423..bb4b700e0b 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.261 2021/06/19 16:52:47 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.262 2021/07/01 17:53:39 jsing 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 *
@@ -187,7 +187,7 @@ SSL_clear(SSL *s)
187 return (0); 187 return (0);
188 } 188 }
189 189
190 s->version = s->method->internal->version; 190 s->version = s->method->version;
191 s->client_version = s->version; 191 s->client_version = s->version;
192 s->internal->rwstate = SSL_NOTHING; 192 s->internal->rwstate = SSL_NOTHING;
193 s->internal->rstate = SSL_ST_READ_HEADER; 193 s->internal->rstate = SSL_ST_READ_HEADER;
@@ -207,12 +207,12 @@ SSL_clear(SSL *s)
207 */ 207 */
208 if (!s->internal->in_handshake && (s->session == NULL) && 208 if (!s->internal->in_handshake && (s->session == NULL) &&
209 (s->method != s->ctx->method)) { 209 (s->method != s->ctx->method)) {
210 s->method->internal->ssl_free(s); 210 s->method->ssl_free(s);
211 s->method = s->ctx->method; 211 s->method = s->ctx->method;
212 if (!s->method->internal->ssl_new(s)) 212 if (!s->method->ssl_new(s))
213 return (0); 213 return (0);
214 } else 214 } else
215 s->method->internal->ssl_clear(s); 215 s->method->ssl_clear(s);
216 216
217 return (1); 217 return (1);
218} 218}
@@ -342,11 +342,11 @@ SSL_new(SSL_CTX *ctx)
342 342
343 s->method = ctx->method; 343 s->method = ctx->method;
344 344
345 if (!s->method->internal->ssl_new(s)) 345 if (!s->method->ssl_new(s))
346 goto err; 346 goto err;
347 347
348 s->references = 1; 348 s->references = 1;
349 s->server = ctx->method->internal->server; 349 s->server = ctx->method->server;
350 350
351 SSL_clear(s); 351 SSL_clear(s);
352 352
@@ -566,7 +566,7 @@ SSL_free(SSL *s)
566 sk_X509_NAME_pop_free(s->internal->client_CA, X509_NAME_free); 566 sk_X509_NAME_pop_free(s->internal->client_CA, X509_NAME_free);
567 567
568 if (s->method != NULL) 568 if (s->method != NULL)
569 s->method->internal->ssl_free(s); 569 s->method->ssl_free(s);
570 570
571 SSL_CTX_free(s->ctx); 571 SSL_CTX_free(s->ctx);
572 572
@@ -811,7 +811,7 @@ SSL_get_read_ahead(const SSL *s)
811int 811int
812SSL_pending(const SSL *s) 812SSL_pending(const SSL *s)
813{ 813{
814 return (s->method->internal->ssl_pending(s)); 814 return (s->method->ssl_pending(s));
815} 815}
816 816
817X509 * 817X509 *
@@ -866,9 +866,9 @@ SSL_copy_session_id(SSL *t, const SSL *f)
866 866
867 /* What if we are set up for one protocol but want to talk another? */ 867 /* What if we are set up for one protocol but want to talk another? */
868 if (t->method != f->method) { 868 if (t->method != f->method) {
869 t->method->internal->ssl_free(t); 869 t->method->ssl_free(t);
870 t->method = f->method; 870 t->method = f->method;
871 if (!t->method->internal->ssl_new(t)) 871 if (!t->method->ssl_new(t))
872 return 0; 872 return 0;
873 } 873 }
874 874
@@ -933,7 +933,7 @@ SSL_accept(SSL *s)
933 if (s->internal->handshake_func == NULL) 933 if (s->internal->handshake_func == NULL)
934 SSL_set_accept_state(s); /* Not properly initialized yet */ 934 SSL_set_accept_state(s); /* Not properly initialized yet */
935 935
936 return (s->method->internal->ssl_accept(s)); 936 return (s->method->ssl_accept(s));
937} 937}
938 938
939int 939int
@@ -942,13 +942,13 @@ SSL_connect(SSL *s)
942 if (s->internal->handshake_func == NULL) 942 if (s->internal->handshake_func == NULL)
943 SSL_set_connect_state(s); /* Not properly initialized yet */ 943 SSL_set_connect_state(s); /* Not properly initialized yet */
944 944
945 return (s->method->internal->ssl_connect(s)); 945 return (s->method->ssl_connect(s));
946} 946}
947 947
948int 948int
949SSL_is_dtls(const SSL *s) 949SSL_is_dtls(const SSL *s)
950{ 950{
951 return s->method->internal->dtls; 951 return s->method->dtls;
952} 952}
953 953
954int 954int
@@ -1085,7 +1085,7 @@ SSL_shutdown(SSL *s)
1085 } 1085 }
1086 1086
1087 if (s != NULL && !SSL_in_init(s)) 1087 if (s != NULL && !SSL_in_init(s))
1088 return (s->method->internal->ssl_shutdown(s)); 1088 return (s->method->ssl_shutdown(s));
1089 1089
1090 return (1); 1090 return (1);
1091} 1091}
@@ -1098,7 +1098,7 @@ SSL_renegotiate(SSL *s)
1098 1098
1099 s->internal->new_session = 1; 1099 s->internal->new_session = 1;
1100 1100
1101 return (s->method->internal->ssl_renegotiate(s)); 1101 return (s->method->ssl_renegotiate(s));
1102} 1102}
1103 1103
1104int 1104int
@@ -1109,7 +1109,7 @@ SSL_renegotiate_abbreviated(SSL *s)
1109 1109
1110 s->internal->new_session = 0; 1110 s->internal->new_session = 0;
1111 1111
1112 return (s->method->internal->ssl_renegotiate(s)); 1112 return (s->method->ssl_renegotiate(s));
1113} 1113}
1114 1114
1115int 1115int
@@ -1825,8 +1825,8 @@ SSL_CTX_new(const SSL_METHOD *meth)
1825 } 1825 }
1826 1826
1827 ret->method = meth; 1827 ret->method = meth;
1828 ret->internal->min_tls_version = meth->internal->min_tls_version; 1828 ret->internal->min_tls_version = meth->min_tls_version;
1829 ret->internal->max_tls_version = meth->internal->max_tls_version; 1829 ret->internal->max_tls_version = meth->max_tls_version;
1830 ret->internal->min_proto_version = 0; 1830 ret->internal->min_proto_version = 0;
1831 ret->internal->max_proto_version = 0; 1831 ret->internal->max_proto_version = 0;
1832 ret->internal->mode = SSL_MODE_AUTO_RETRY; 1832 ret->internal->mode = SSL_MODE_AUTO_RETRY;
@@ -2293,17 +2293,17 @@ SSL_set_ssl_method(SSL *s, const SSL_METHOD *method)
2293 if (s->method == method) 2293 if (s->method == method)
2294 return (ret); 2294 return (ret);
2295 2295
2296 if (s->internal->handshake_func == s->method->internal->ssl_connect) 2296 if (s->internal->handshake_func == s->method->ssl_connect)
2297 handshake_func = method->internal->ssl_connect; 2297 handshake_func = method->ssl_connect;
2298 else if (s->internal->handshake_func == s->method->internal->ssl_accept) 2298 else if (s->internal->handshake_func == s->method->ssl_accept)
2299 handshake_func = method->internal->ssl_accept; 2299 handshake_func = method->ssl_accept;
2300 2300
2301 if (s->method->internal->version == method->internal->version) { 2301 if (s->method->version == method->version) {
2302 s->method = method; 2302 s->method = method;
2303 } else { 2303 } else {
2304 s->method->internal->ssl_free(s); 2304 s->method->ssl_free(s);
2305 s->method = method; 2305 s->method = method;
2306 ret = s->method->internal->ssl_new(s); 2306 ret = s->method->ssl_new(s);
2307 } 2307 }
2308 s->internal->handshake_func = handshake_func; 2308 s->internal->handshake_func = handshake_func;
2309 2309
@@ -2398,7 +2398,7 @@ SSL_do_handshake(SSL *s)
2398 return (-1); 2398 return (-1);
2399 } 2399 }
2400 2400
2401 s->method->internal->ssl_renegotiate_check(s); 2401 s->method->ssl_renegotiate_check(s);
2402 2402
2403 if (SSL_in_init(s) || SSL_in_before(s)) { 2403 if (SSL_in_init(s) || SSL_in_before(s)) {
2404 ret = s->internal->handshake_func(s); 2404 ret = s->internal->handshake_func(s);
@@ -2416,7 +2416,7 @@ SSL_set_accept_state(SSL *s)
2416 s->server = 1; 2416 s->server = 1;
2417 s->internal->shutdown = 0; 2417 s->internal->shutdown = 0;
2418 S3I(s)->hs.state = SSL_ST_ACCEPT|SSL_ST_BEFORE; 2418 S3I(s)->hs.state = SSL_ST_ACCEPT|SSL_ST_BEFORE;
2419 s->internal->handshake_func = s->method->internal->ssl_accept; 2419 s->internal->handshake_func = s->method->ssl_accept;
2420 ssl_clear_cipher_state(s); 2420 ssl_clear_cipher_state(s);
2421} 2421}
2422 2422
@@ -2426,7 +2426,7 @@ SSL_set_connect_state(SSL *s)
2426 s->server = 0; 2426 s->server = 0;
2427 s->internal->shutdown = 0; 2427 s->internal->shutdown = 0;
2428 S3I(s)->hs.state = SSL_ST_CONNECT|SSL_ST_BEFORE; 2428 S3I(s)->hs.state = SSL_ST_CONNECT|SSL_ST_BEFORE;
2429 s->internal->handshake_func = s->method->internal->ssl_connect; 2429 s->internal->handshake_func = s->method->ssl_connect;
2430 ssl_clear_cipher_state(s); 2430 ssl_clear_cipher_state(s);
2431} 2431}
2432 2432
@@ -2503,9 +2503,9 @@ SSL_dup(SSL *s)
2503 * and thus we can't use SSL_copy_session_id. 2503 * and thus we can't use SSL_copy_session_id.
2504 */ 2504 */
2505 2505
2506 ret->method->internal->ssl_free(ret); 2506 ret->method->ssl_free(ret);
2507 ret->method = s->method; 2507 ret->method = s->method;
2508 ret->method->internal->ssl_new(ret); 2508 ret->method->ssl_new(ret);
2509 2509
2510 ssl_cert_free(ret->cert); 2510 ssl_cert_free(ret->cert);
2511 if ((ret->cert = ssl_cert_dup(s->cert)) == NULL) 2511 if ((ret->cert = ssl_cert_dup(s->cert)) == NULL)
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 10fa9b6c17..6ffc2e053c 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.353 2021/06/30 18:04:06 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.354 2021/07/01 17:53:39 jsing 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 *
@@ -319,19 +319,19 @@ __BEGIN_HIDDEN_DECLS
319 319
320/* See if we use signature algorithms extension. */ 320/* See if we use signature algorithms extension. */
321#define SSL_USE_SIGALGS(s) \ 321#define SSL_USE_SIGALGS(s) \
322 (s->method->internal->enc_flags & SSL_ENC_FLAG_SIGALGS) 322 (s->method->enc_flags & SSL_ENC_FLAG_SIGALGS)
323 323
324/* See if we use SHA256 default PRF. */ 324/* See if we use SHA256 default PRF. */
325#define SSL_USE_SHA256_PRF(s) \ 325#define SSL_USE_SHA256_PRF(s) \
326 (s->method->internal->enc_flags & SSL_ENC_FLAG_SHA256_PRF) 326 (s->method->enc_flags & SSL_ENC_FLAG_SHA256_PRF)
327 327
328/* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ 328/* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */
329#define SSL_USE_TLS1_2_CIPHERS(s) \ 329#define SSL_USE_TLS1_2_CIPHERS(s) \
330 (s->method->internal->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS) 330 (s->method->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS)
331 331
332/* Allow TLS 1.3 ciphersuites only. */ 332/* Allow TLS 1.3 ciphersuites only. */
333#define SSL_USE_TLS1_3_CIPHERS(s) \ 333#define SSL_USE_TLS1_3_CIPHERS(s) \
334 (s->method->internal->enc_flags & SSL_ENC_FLAG_TLS1_3_CIPHERS) 334 (s->method->enc_flags & SSL_ENC_FLAG_TLS1_3_CIPHERS)
335 335
336#define SSL_PKEY_RSA 0 336#define SSL_PKEY_RSA 0
337#define SSL_PKEY_ECC 1 337#define SSL_PKEY_ECC 1
@@ -378,7 +378,7 @@ struct ssl_cipher_st {
378 int alg_bits; /* Number of bits for algorithm */ 378 int alg_bits; /* Number of bits for algorithm */
379}; 379};
380 380
381typedef struct ssl_method_internal_st { 381struct ssl_method_st {
382 int dtls; 382 int dtls;
383 int server; 383 int server;
384 int version; 384 int version;
@@ -402,17 +402,13 @@ typedef struct ssl_method_internal_st {
402 int peek); 402 int peek);
403 int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); 403 int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len);
404 404
405 unsigned int enc_flags; /* SSL_ENC_FLAG_* */
406} SSL_METHOD_INTERNAL;
407
408struct ssl_method_st {
409 int (*ssl_dispatch_alert)(SSL *s); 405 int (*ssl_dispatch_alert)(SSL *s);
410 int (*num_ciphers)(void); 406 int (*num_ciphers)(void);
411 const SSL_CIPHER *(*get_cipher)(unsigned int ncipher); 407 const SSL_CIPHER *(*get_cipher)(unsigned int ncipher);
412 const SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); 408 const SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
413 int (*put_cipher_by_char)(const SSL_CIPHER *cipher, unsigned char *ptr); 409 int (*put_cipher_by_char)(const SSL_CIPHER *cipher, unsigned char *ptr);
414 410
415 const struct ssl_method_internal_st *internal; 411 unsigned int enc_flags; /* SSL_ENC_FLAG_* */
416}; 412};
417 413
418typedef struct ssl_session_internal_st { 414typedef struct ssl_session_internal_st {
diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c
index f1a59cd738..a3097c37b9 100644
--- a/src/lib/libssl/ssl_methods.c
+++ b/src/lib/libssl/ssl_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_methods.c,v 1.25 2021/05/16 13:56:31 jsing Exp $ */ 1/* $OpenBSD: ssl_methods.c,v 1.26 2021/07/01 17:53:39 jsing 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 *
@@ -60,7 +60,7 @@
60#include "ssl_locl.h" 60#include "ssl_locl.h"
61#include "tls13_internal.h" 61#include "tls13_internal.h"
62 62
63static const SSL_METHOD_INTERNAL DTLS_method_internal_data = { 63static const SSL_METHOD DTLS_method_data = {
64 .dtls = 1, 64 .dtls = 1,
65 .server = 1, 65 .server = 1,
66 .version = DTLS1_2_VERSION, 66 .version = DTLS1_2_VERSION,
@@ -77,19 +77,15 @@ static const SSL_METHOD_INTERNAL DTLS_method_internal_data = {
77 .ssl_pending = ssl3_pending, 77 .ssl_pending = ssl3_pending,
78 .ssl_read_bytes = dtls1_read_bytes, 78 .ssl_read_bytes = dtls1_read_bytes,
79 .ssl_write_bytes = dtls1_write_app_data_bytes, 79 .ssl_write_bytes = dtls1_write_app_data_bytes,
80 .enc_flags = TLSV1_2_ENC_FLAGS,
81};
82
83static const SSL_METHOD DTLS_method_data = {
84 .ssl_dispatch_alert = dtls1_dispatch_alert, 80 .ssl_dispatch_alert = dtls1_dispatch_alert,
85 .num_ciphers = ssl3_num_ciphers, 81 .num_ciphers = ssl3_num_ciphers,
86 .get_cipher = dtls1_get_cipher, 82 .get_cipher = dtls1_get_cipher,
87 .get_cipher_by_char = ssl3_get_cipher_by_char, 83 .get_cipher_by_char = ssl3_get_cipher_by_char,
88 .put_cipher_by_char = ssl3_put_cipher_by_char, 84 .put_cipher_by_char = ssl3_put_cipher_by_char,
89 .internal = &DTLS_method_internal_data, 85 .enc_flags = TLSV1_2_ENC_FLAGS,
90}; 86};
91 87
92static const SSL_METHOD_INTERNAL DTLS_client_method_internal_data = { 88static const SSL_METHOD DTLS_client_method_data = {
93 .dtls = 1, 89 .dtls = 1,
94 .server = 0, 90 .server = 0,
95 .version = DTLS1_2_VERSION, 91 .version = DTLS1_2_VERSION,
@@ -106,19 +102,15 @@ static const SSL_METHOD_INTERNAL DTLS_client_method_internal_data = {
106 .ssl_pending = ssl3_pending, 102 .ssl_pending = ssl3_pending,
107 .ssl_read_bytes = dtls1_read_bytes, 103 .ssl_read_bytes = dtls1_read_bytes,
108 .ssl_write_bytes = dtls1_write_app_data_bytes, 104 .ssl_write_bytes = dtls1_write_app_data_bytes,
109 .enc_flags = TLSV1_2_ENC_FLAGS,
110};
111
112static const SSL_METHOD DTLS_client_method_data = {
113 .ssl_dispatch_alert = dtls1_dispatch_alert, 105 .ssl_dispatch_alert = dtls1_dispatch_alert,
114 .num_ciphers = ssl3_num_ciphers, 106 .num_ciphers = ssl3_num_ciphers,
115 .get_cipher = dtls1_get_cipher, 107 .get_cipher = dtls1_get_cipher,
116 .get_cipher_by_char = ssl3_get_cipher_by_char, 108 .get_cipher_by_char = ssl3_get_cipher_by_char,
117 .put_cipher_by_char = ssl3_put_cipher_by_char, 109 .put_cipher_by_char = ssl3_put_cipher_by_char,
118 .internal = &DTLS_client_method_internal_data, 110 .enc_flags = TLSV1_2_ENC_FLAGS,
119}; 111};
120 112
121static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = { 113static const SSL_METHOD DTLSv1_method_data = {
122 .dtls = 1, 114 .dtls = 1,
123 .server = 1, 115 .server = 1,
124 .version = DTLS1_VERSION, 116 .version = DTLS1_VERSION,
@@ -135,19 +127,15 @@ static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = {
135 .ssl_pending = ssl3_pending, 127 .ssl_pending = ssl3_pending,
136 .ssl_read_bytes = dtls1_read_bytes, 128 .ssl_read_bytes = dtls1_read_bytes,
137 .ssl_write_bytes = dtls1_write_app_data_bytes, 129 .ssl_write_bytes = dtls1_write_app_data_bytes,
138 .enc_flags = TLSV1_1_ENC_FLAGS,
139};
140
141static const SSL_METHOD DTLSv1_method_data = {
142 .ssl_dispatch_alert = dtls1_dispatch_alert, 130 .ssl_dispatch_alert = dtls1_dispatch_alert,
143 .num_ciphers = ssl3_num_ciphers, 131 .num_ciphers = ssl3_num_ciphers,
144 .get_cipher = dtls1_get_cipher, 132 .get_cipher = dtls1_get_cipher,
145 .get_cipher_by_char = ssl3_get_cipher_by_char, 133 .get_cipher_by_char = ssl3_get_cipher_by_char,
146 .put_cipher_by_char = ssl3_put_cipher_by_char, 134 .put_cipher_by_char = ssl3_put_cipher_by_char,
147 .internal = &DTLSv1_method_internal_data, 135 .enc_flags = TLSV1_1_ENC_FLAGS,
148}; 136};
149 137
150static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { 138static const SSL_METHOD DTLSv1_client_method_data = {
151 .dtls = 1, 139 .dtls = 1,
152 .server = 0, 140 .server = 0,
153 .version = DTLS1_VERSION, 141 .version = DTLS1_VERSION,
@@ -164,19 +152,15 @@ static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = {
164 .ssl_pending = ssl3_pending, 152 .ssl_pending = ssl3_pending,
165 .ssl_read_bytes = dtls1_read_bytes, 153 .ssl_read_bytes = dtls1_read_bytes,
166 .ssl_write_bytes = dtls1_write_app_data_bytes, 154 .ssl_write_bytes = dtls1_write_app_data_bytes,
167 .enc_flags = TLSV1_1_ENC_FLAGS,
168};
169
170static const SSL_METHOD DTLSv1_client_method_data = {
171 .ssl_dispatch_alert = dtls1_dispatch_alert, 155 .ssl_dispatch_alert = dtls1_dispatch_alert,
172 .num_ciphers = ssl3_num_ciphers, 156 .num_ciphers = ssl3_num_ciphers,
173 .get_cipher = dtls1_get_cipher, 157 .get_cipher = dtls1_get_cipher,
174 .get_cipher_by_char = ssl3_get_cipher_by_char, 158 .get_cipher_by_char = ssl3_get_cipher_by_char,
175 .put_cipher_by_char = ssl3_put_cipher_by_char, 159 .put_cipher_by_char = ssl3_put_cipher_by_char,
176 .internal = &DTLSv1_client_method_internal_data, 160 .enc_flags = TLSV1_1_ENC_FLAGS,
177}; 161};
178 162
179static const SSL_METHOD_INTERNAL DTLSv1_2_method_internal_data = { 163static const SSL_METHOD DTLSv1_2_method_data = {
180 .dtls = 1, 164 .dtls = 1,
181 .server = 1, 165 .server = 1,
182 .version = DTLS1_2_VERSION, 166 .version = DTLS1_2_VERSION,
@@ -193,19 +177,15 @@ static const SSL_METHOD_INTERNAL DTLSv1_2_method_internal_data = {
193 .ssl_pending = ssl3_pending, 177 .ssl_pending = ssl3_pending,
194 .ssl_read_bytes = dtls1_read_bytes, 178 .ssl_read_bytes = dtls1_read_bytes,
195 .ssl_write_bytes = dtls1_write_app_data_bytes, 179 .ssl_write_bytes = dtls1_write_app_data_bytes,
196 .enc_flags = TLSV1_2_ENC_FLAGS,
197};
198
199static const SSL_METHOD DTLSv1_2_method_data = {
200 .ssl_dispatch_alert = dtls1_dispatch_alert, 180 .ssl_dispatch_alert = dtls1_dispatch_alert,
201 .num_ciphers = ssl3_num_ciphers, 181 .num_ciphers = ssl3_num_ciphers,
202 .get_cipher = dtls1_get_cipher, 182 .get_cipher = dtls1_get_cipher,
203 .get_cipher_by_char = ssl3_get_cipher_by_char, 183 .get_cipher_by_char = ssl3_get_cipher_by_char,
204 .put_cipher_by_char = ssl3_put_cipher_by_char, 184 .put_cipher_by_char = ssl3_put_cipher_by_char,
205 .internal = &DTLSv1_2_method_internal_data, 185 .enc_flags = TLSV1_2_ENC_FLAGS,
206}; 186};
207 187
208static const SSL_METHOD_INTERNAL DTLSv1_2_client_method_internal_data = { 188static const SSL_METHOD DTLSv1_2_client_method_data = {
209 .dtls = 1, 189 .dtls = 1,
210 .server = 0, 190 .server = 0,
211 .version = DTLS1_2_VERSION, 191 .version = DTLS1_2_VERSION,
@@ -222,16 +202,12 @@ static const SSL_METHOD_INTERNAL DTLSv1_2_client_method_internal_data = {
222 .ssl_pending = ssl3_pending, 202 .ssl_pending = ssl3_pending,
223 .ssl_read_bytes = dtls1_read_bytes, 203 .ssl_read_bytes = dtls1_read_bytes,
224 .ssl_write_bytes = dtls1_write_app_data_bytes, 204 .ssl_write_bytes = dtls1_write_app_data_bytes,
225 .enc_flags = TLSV1_2_ENC_FLAGS,
226};
227
228static const SSL_METHOD DTLSv1_2_client_method_data = {
229 .ssl_dispatch_alert = dtls1_dispatch_alert, 205 .ssl_dispatch_alert = dtls1_dispatch_alert,
230 .num_ciphers = ssl3_num_ciphers, 206 .num_ciphers = ssl3_num_ciphers,
231 .get_cipher = dtls1_get_cipher, 207 .get_cipher = dtls1_get_cipher,
232 .get_cipher_by_char = ssl3_get_cipher_by_char, 208 .get_cipher_by_char = ssl3_get_cipher_by_char,
233 .put_cipher_by_char = ssl3_put_cipher_by_char, 209 .put_cipher_by_char = ssl3_put_cipher_by_char,
234 .internal = &DTLSv1_2_client_method_internal_data, 210 .enc_flags = TLSV1_2_ENC_FLAGS,
235}; 211};
236 212
237const SSL_METHOD * 213const SSL_METHOD *
@@ -289,7 +265,7 @@ DTLS_server_method(void)
289} 265}
290 266
291#if defined(LIBRESSL_HAS_TLS1_3_CLIENT) && defined(LIBRESSL_HAS_TLS1_3_SERVER) 267#if defined(LIBRESSL_HAS_TLS1_3_CLIENT) && defined(LIBRESSL_HAS_TLS1_3_SERVER)
292static const SSL_METHOD_INTERNAL TLS_method_internal_data = { 268static const SSL_METHOD TLS_method_data = {
293 .dtls = 0, 269 .dtls = 0,
294 .server = 1, 270 .server = 1,
295 .version = TLS1_3_VERSION, 271 .version = TLS1_3_VERSION,
@@ -306,20 +282,16 @@ static const SSL_METHOD_INTERNAL TLS_method_internal_data = {
306 .ssl_pending = tls13_legacy_pending, 282 .ssl_pending = tls13_legacy_pending,
307 .ssl_read_bytes = tls13_legacy_read_bytes, 283 .ssl_read_bytes = tls13_legacy_read_bytes,
308 .ssl_write_bytes = tls13_legacy_write_bytes, 284 .ssl_write_bytes = tls13_legacy_write_bytes,
309 .enc_flags = TLSV1_3_ENC_FLAGS,
310};
311
312static const SSL_METHOD TLS_method_data = {
313 .ssl_dispatch_alert = ssl3_dispatch_alert, 285 .ssl_dispatch_alert = ssl3_dispatch_alert,
314 .num_ciphers = ssl3_num_ciphers, 286 .num_ciphers = ssl3_num_ciphers,
315 .get_cipher = ssl3_get_cipher, 287 .get_cipher = ssl3_get_cipher,
316 .get_cipher_by_char = ssl3_get_cipher_by_char, 288 .get_cipher_by_char = ssl3_get_cipher_by_char,
317 .put_cipher_by_char = ssl3_put_cipher_by_char, 289 .put_cipher_by_char = ssl3_put_cipher_by_char,
318 .internal = &TLS_method_internal_data, 290 .enc_flags = TLSV1_3_ENC_FLAGS,
319}; 291};
320#endif 292#endif
321 293
322static const SSL_METHOD_INTERNAL TLS_legacy_method_internal_data = { 294static const SSL_METHOD TLS_legacy_method_data = {
323 .dtls = 0, 295 .dtls = 0,
324 .server = 1, 296 .server = 1,
325 .version = TLS1_2_VERSION, 297 .version = TLS1_2_VERSION,
@@ -336,20 +308,16 @@ static const SSL_METHOD_INTERNAL TLS_legacy_method_internal_data = {
336 .ssl_pending = ssl3_pending, 308 .ssl_pending = ssl3_pending,
337 .ssl_read_bytes = ssl3_read_bytes, 309 .ssl_read_bytes = ssl3_read_bytes,
338 .ssl_write_bytes = ssl3_write_bytes, 310 .ssl_write_bytes = ssl3_write_bytes,
339 .enc_flags = TLSV1_2_ENC_FLAGS,
340};
341
342static const SSL_METHOD TLS_legacy_method_data = {
343 .ssl_dispatch_alert = ssl3_dispatch_alert, 311 .ssl_dispatch_alert = ssl3_dispatch_alert,
344 .num_ciphers = ssl3_num_ciphers, 312 .num_ciphers = ssl3_num_ciphers,
345 .get_cipher = ssl3_get_cipher, 313 .get_cipher = ssl3_get_cipher,
346 .get_cipher_by_char = ssl3_get_cipher_by_char, 314 .get_cipher_by_char = ssl3_get_cipher_by_char,
347 .put_cipher_by_char = ssl3_put_cipher_by_char, 315 .put_cipher_by_char = ssl3_put_cipher_by_char,
348 .internal = &TLS_legacy_method_internal_data, 316 .enc_flags = TLSV1_2_ENC_FLAGS,
349}; 317};
350 318
351#if defined(LIBRESSL_HAS_TLS1_3_CLIENT) 319#if defined(LIBRESSL_HAS_TLS1_3_CLIENT)
352static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { 320static const SSL_METHOD TLS_client_method_data = {
353 .dtls = 0, 321 .dtls = 0,
354 .server = 0, 322 .server = 0,
355 .version = TLS1_3_VERSION, 323 .version = TLS1_3_VERSION,
@@ -366,21 +334,17 @@ static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = {
366 .ssl_pending = tls13_legacy_pending, 334 .ssl_pending = tls13_legacy_pending,
367 .ssl_read_bytes = tls13_legacy_read_bytes, 335 .ssl_read_bytes = tls13_legacy_read_bytes,
368 .ssl_write_bytes = tls13_legacy_write_bytes, 336 .ssl_write_bytes = tls13_legacy_write_bytes,
369 .enc_flags = TLSV1_3_ENC_FLAGS,
370};
371
372static const SSL_METHOD TLS_client_method_data = {
373 .ssl_dispatch_alert = ssl3_dispatch_alert, 337 .ssl_dispatch_alert = ssl3_dispatch_alert,
374 .num_ciphers = ssl3_num_ciphers, 338 .num_ciphers = ssl3_num_ciphers,
375 .get_cipher = ssl3_get_cipher, 339 .get_cipher = ssl3_get_cipher,
376 .get_cipher_by_char = ssl3_get_cipher_by_char, 340 .get_cipher_by_char = ssl3_get_cipher_by_char,
377 .put_cipher_by_char = ssl3_put_cipher_by_char, 341 .put_cipher_by_char = ssl3_put_cipher_by_char,
378 .internal = &TLS_client_method_internal_data, 342 .enc_flags = TLSV1_3_ENC_FLAGS,
379}; 343};
380 344
381#else 345#else
382 346
383static const SSL_METHOD_INTERNAL TLS_legacy_client_method_internal_data = { 347static const SSL_METHOD TLS_legacy_client_method_data = {
384 .dtls = 0, 348 .dtls = 0,
385 .server = 0, 349 .server = 0,
386 .version = TLS1_2_VERSION, 350 .version = TLS1_2_VERSION,
@@ -397,20 +361,16 @@ static const SSL_METHOD_INTERNAL TLS_legacy_client_method_internal_data = {
397 .ssl_pending = ssl3_pending, 361 .ssl_pending = ssl3_pending,
398 .ssl_read_bytes = ssl3_read_bytes, 362 .ssl_read_bytes = ssl3_read_bytes,
399 .ssl_write_bytes = ssl3_write_bytes, 363 .ssl_write_bytes = ssl3_write_bytes,
400 .enc_flags = TLSV1_2_ENC_FLAGS,
401};
402
403static const SSL_METHOD TLS_legacy_client_method_data = {
404 .ssl_dispatch_alert = ssl3_dispatch_alert, 364 .ssl_dispatch_alert = ssl3_dispatch_alert,
405 .num_ciphers = ssl3_num_ciphers, 365 .num_ciphers = ssl3_num_ciphers,
406 .get_cipher = ssl3_get_cipher, 366 .get_cipher = ssl3_get_cipher,
407 .get_cipher_by_char = ssl3_get_cipher_by_char, 367 .get_cipher_by_char = ssl3_get_cipher_by_char,
408 .put_cipher_by_char = ssl3_put_cipher_by_char, 368 .put_cipher_by_char = ssl3_put_cipher_by_char,
409 .internal = &TLS_legacy_client_method_internal_data, 369 .enc_flags = TLSV1_2_ENC_FLAGS,
410}; 370};
411#endif 371#endif
412 372
413static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = { 373static const SSL_METHOD TLSv1_method_data = {
414 .dtls = 0, 374 .dtls = 0,
415 .server = 1, 375 .server = 1,
416 .version = TLS1_VERSION, 376 .version = TLS1_VERSION,
@@ -427,19 +387,15 @@ static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = {
427 .ssl_pending = ssl3_pending, 387 .ssl_pending = ssl3_pending,
428 .ssl_read_bytes = ssl3_read_bytes, 388 .ssl_read_bytes = ssl3_read_bytes,
429 .ssl_write_bytes = ssl3_write_bytes, 389 .ssl_write_bytes = ssl3_write_bytes,
430 .enc_flags = TLSV1_ENC_FLAGS,
431};
432
433static const SSL_METHOD TLSv1_method_data = {
434 .ssl_dispatch_alert = ssl3_dispatch_alert, 390 .ssl_dispatch_alert = ssl3_dispatch_alert,
435 .num_ciphers = ssl3_num_ciphers, 391 .num_ciphers = ssl3_num_ciphers,
436 .get_cipher = ssl3_get_cipher, 392 .get_cipher = ssl3_get_cipher,
437 .get_cipher_by_char = ssl3_get_cipher_by_char, 393 .get_cipher_by_char = ssl3_get_cipher_by_char,
438 .put_cipher_by_char = ssl3_put_cipher_by_char, 394 .put_cipher_by_char = ssl3_put_cipher_by_char,
439 .internal = &TLSv1_method_internal_data, 395 .enc_flags = TLSV1_ENC_FLAGS,
440}; 396};
441 397
442static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { 398static const SSL_METHOD TLSv1_client_method_data = {
443 .dtls = 0, 399 .dtls = 0,
444 .server = 0, 400 .server = 0,
445 .version = TLS1_VERSION, 401 .version = TLS1_VERSION,
@@ -456,19 +412,15 @@ static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = {
456 .ssl_pending = ssl3_pending, 412 .ssl_pending = ssl3_pending,
457 .ssl_read_bytes = ssl3_read_bytes, 413 .ssl_read_bytes = ssl3_read_bytes,
458 .ssl_write_bytes = ssl3_write_bytes, 414 .ssl_write_bytes = ssl3_write_bytes,
459 .enc_flags = TLSV1_ENC_FLAGS,
460};
461
462static const SSL_METHOD TLSv1_client_method_data = {
463 .ssl_dispatch_alert = ssl3_dispatch_alert, 415 .ssl_dispatch_alert = ssl3_dispatch_alert,
464 .num_ciphers = ssl3_num_ciphers, 416 .num_ciphers = ssl3_num_ciphers,
465 .get_cipher = ssl3_get_cipher, 417 .get_cipher = ssl3_get_cipher,
466 .get_cipher_by_char = ssl3_get_cipher_by_char, 418 .get_cipher_by_char = ssl3_get_cipher_by_char,
467 .put_cipher_by_char = ssl3_put_cipher_by_char, 419 .put_cipher_by_char = ssl3_put_cipher_by_char,
468 .internal = &TLSv1_client_method_internal_data, 420 .enc_flags = TLSV1_ENC_FLAGS,
469}; 421};
470 422
471static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = { 423static const SSL_METHOD TLSv1_1_method_data = {
472 .dtls = 0, 424 .dtls = 0,
473 .server = 1, 425 .server = 1,
474 .version = TLS1_1_VERSION, 426 .version = TLS1_1_VERSION,
@@ -485,19 +437,15 @@ static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = {
485 .ssl_pending = ssl3_pending, 437 .ssl_pending = ssl3_pending,
486 .ssl_read_bytes = ssl3_read_bytes, 438 .ssl_read_bytes = ssl3_read_bytes,
487 .ssl_write_bytes = ssl3_write_bytes, 439 .ssl_write_bytes = ssl3_write_bytes,
488 .enc_flags = TLSV1_1_ENC_FLAGS,
489};
490
491static const SSL_METHOD TLSv1_1_method_data = {
492 .ssl_dispatch_alert = ssl3_dispatch_alert, 440 .ssl_dispatch_alert = ssl3_dispatch_alert,
493 .num_ciphers = ssl3_num_ciphers, 441 .num_ciphers = ssl3_num_ciphers,
494 .get_cipher = ssl3_get_cipher, 442 .get_cipher = ssl3_get_cipher,
495 .get_cipher_by_char = ssl3_get_cipher_by_char, 443 .get_cipher_by_char = ssl3_get_cipher_by_char,
496 .put_cipher_by_char = ssl3_put_cipher_by_char, 444 .put_cipher_by_char = ssl3_put_cipher_by_char,
497 .internal = &TLSv1_1_method_internal_data, 445 .enc_flags = TLSV1_1_ENC_FLAGS,
498}; 446};
499 447
500static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = { 448static const SSL_METHOD TLSv1_1_client_method_data = {
501 .dtls = 0, 449 .dtls = 0,
502 .server = 0, 450 .server = 0,
503 .version = TLS1_1_VERSION, 451 .version = TLS1_1_VERSION,
@@ -514,19 +462,15 @@ static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = {
514 .ssl_pending = ssl3_pending, 462 .ssl_pending = ssl3_pending,
515 .ssl_read_bytes = ssl3_read_bytes, 463 .ssl_read_bytes = ssl3_read_bytes,
516 .ssl_write_bytes = ssl3_write_bytes, 464 .ssl_write_bytes = ssl3_write_bytes,
517 .enc_flags = TLSV1_1_ENC_FLAGS,
518};
519
520static const SSL_METHOD TLSv1_1_client_method_data = {
521 .ssl_dispatch_alert = ssl3_dispatch_alert, 465 .ssl_dispatch_alert = ssl3_dispatch_alert,
522 .num_ciphers = ssl3_num_ciphers, 466 .num_ciphers = ssl3_num_ciphers,
523 .get_cipher = ssl3_get_cipher, 467 .get_cipher = ssl3_get_cipher,
524 .get_cipher_by_char = ssl3_get_cipher_by_char, 468 .get_cipher_by_char = ssl3_get_cipher_by_char,
525 .put_cipher_by_char = ssl3_put_cipher_by_char, 469 .put_cipher_by_char = ssl3_put_cipher_by_char,
526 .internal = &TLSv1_1_client_method_internal_data, 470 .enc_flags = TLSV1_1_ENC_FLAGS,
527}; 471};
528 472
529static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = { 473static const SSL_METHOD TLSv1_2_method_data = {
530 .dtls = 0, 474 .dtls = 0,
531 .server = 1, 475 .server = 1,
532 .version = TLS1_2_VERSION, 476 .version = TLS1_2_VERSION,
@@ -543,19 +487,15 @@ static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = {
543 .ssl_pending = ssl3_pending, 487 .ssl_pending = ssl3_pending,
544 .ssl_read_bytes = ssl3_read_bytes, 488 .ssl_read_bytes = ssl3_read_bytes,
545 .ssl_write_bytes = ssl3_write_bytes, 489 .ssl_write_bytes = ssl3_write_bytes,
546 .enc_flags = TLSV1_2_ENC_FLAGS,
547};
548
549static const SSL_METHOD TLSv1_2_method_data = {
550 .ssl_dispatch_alert = ssl3_dispatch_alert, 490 .ssl_dispatch_alert = ssl3_dispatch_alert,
551 .num_ciphers = ssl3_num_ciphers, 491 .num_ciphers = ssl3_num_ciphers,
552 .get_cipher = ssl3_get_cipher, 492 .get_cipher = ssl3_get_cipher,
553 .get_cipher_by_char = ssl3_get_cipher_by_char, 493 .get_cipher_by_char = ssl3_get_cipher_by_char,
554 .put_cipher_by_char = ssl3_put_cipher_by_char, 494 .put_cipher_by_char = ssl3_put_cipher_by_char,
555 .internal = &TLSv1_2_method_internal_data, 495 .enc_flags = TLSV1_2_ENC_FLAGS,
556}; 496};
557 497
558static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = { 498static const SSL_METHOD TLSv1_2_client_method_data = {
559 .dtls = 0, 499 .dtls = 0,
560 .server = 0, 500 .server = 0,
561 .version = TLS1_2_VERSION, 501 .version = TLS1_2_VERSION,
@@ -572,16 +512,12 @@ static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = {
572 .ssl_pending = ssl3_pending, 512 .ssl_pending = ssl3_pending,
573 .ssl_read_bytes = ssl3_read_bytes, 513 .ssl_read_bytes = ssl3_read_bytes,
574 .ssl_write_bytes = ssl3_write_bytes, 514 .ssl_write_bytes = ssl3_write_bytes,
575 .enc_flags = TLSV1_2_ENC_FLAGS,
576};
577
578static const SSL_METHOD TLSv1_2_client_method_data = {
579 .ssl_dispatch_alert = ssl3_dispatch_alert, 515 .ssl_dispatch_alert = ssl3_dispatch_alert,
580 .num_ciphers = ssl3_num_ciphers, 516 .num_ciphers = ssl3_num_ciphers,
581 .get_cipher = ssl3_get_cipher, 517 .get_cipher = ssl3_get_cipher,
582 .get_cipher_by_char = ssl3_get_cipher_by_char, 518 .get_cipher_by_char = ssl3_get_cipher_by_char,
583 .put_cipher_by_char = ssl3_put_cipher_by_char, 519 .put_cipher_by_char = ssl3_put_cipher_by_char,
584 .internal = &TLSv1_2_client_method_internal_data, 520 .enc_flags = TLSV1_2_ENC_FLAGS,
585}; 521};
586 522
587const SSL_METHOD * 523const SSL_METHOD *
diff --git a/src/lib/libssl/ssl_packet.c b/src/lib/libssl/ssl_packet.c
index 0a0c5a29df..af56dcef7f 100644
--- a/src/lib/libssl/ssl_packet.c
+++ b/src/lib/libssl/ssl_packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_packet.c,v 1.11 2021/05/16 14:10:43 jsing Exp $ */ 1/* $OpenBSD: ssl_packet.c,v 1.12 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -246,8 +246,7 @@ ssl_server_legacy_first_packet(SSL *s)
246 return 1; 246 return 1;
247 247
248 /* Only continue if this is not a version locked method. */ 248 /* Only continue if this is not a version locked method. */
249 if (s->method->internal->min_tls_version == 249 if (s->method->min_tls_version == s->method->max_tls_version)
250 s->method->internal->max_tls_version)
251 return 1; 250 return 1;
252 251
253 if (ssl_is_sslv2_client_hello(&header) == 1) { 252 if (ssl_is_sslv2_client_hello(&header) == 1) {
diff --git a/src/lib/libssl/ssl_versions.c b/src/lib/libssl/ssl_versions.c
index 68e69ebca3..c633b58c25 100644
--- a/src/lib/libssl/ssl_versions.c
+++ b/src/lib/libssl/ssl_versions.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_versions.c,v 1.19 2021/06/27 16:54:14 jsing Exp $ */ 1/* $OpenBSD: ssl_versions.c,v 1.20 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -61,7 +61,7 @@ ssl_version_set_min(const SSL_METHOD *meth, uint16_t proto_ver,
61 uint16_t min_proto, min_version, max_version; 61 uint16_t min_proto, min_version, max_version;
62 62
63 if (proto_ver == 0) { 63 if (proto_ver == 0) {
64 *out_tls_ver = meth->internal->min_tls_version; 64 *out_tls_ver = meth->min_tls_version;
65 *out_proto_ver = 0; 65 *out_proto_ver = 0;
66 return 1; 66 return 1;
67 } 67 }
@@ -69,17 +69,17 @@ ssl_version_set_min(const SSL_METHOD *meth, uint16_t proto_ver,
69 min_version = proto_ver; 69 min_version = proto_ver;
70 max_version = max_tls_ver; 70 max_version = max_tls_ver;
71 71
72 if (meth->internal->dtls) { 72 if (meth->dtls) {
73 if ((min_version = ssl_dtls_to_tls_version(proto_ver)) == 0) 73 if ((min_version = ssl_dtls_to_tls_version(proto_ver)) == 0)
74 return 0; 74 return 0;
75 } 75 }
76 76
77 if (!ssl_clamp_tls_version_range(&min_version, &max_version, 77 if (!ssl_clamp_tls_version_range(&min_version, &max_version,
78 meth->internal->min_tls_version, meth->internal->max_tls_version)) 78 meth->min_tls_version, meth->max_tls_version))
79 return 0; 79 return 0;
80 80
81 min_proto = min_version; 81 min_proto = min_version;
82 if (meth->internal->dtls) { 82 if (meth->dtls) {
83 if ((min_proto = ssl_tls_to_dtls_version(min_version)) == 0) 83 if ((min_proto = ssl_tls_to_dtls_version(min_version)) == 0)
84 return 0; 84 return 0;
85 } 85 }
@@ -96,7 +96,7 @@ ssl_version_set_max(const SSL_METHOD *meth, uint16_t proto_ver,
96 uint16_t max_proto, min_version, max_version; 96 uint16_t max_proto, min_version, max_version;
97 97
98 if (proto_ver == 0) { 98 if (proto_ver == 0) {
99 *out_tls_ver = meth->internal->max_tls_version; 99 *out_tls_ver = meth->max_tls_version;
100 *out_proto_ver = 0; 100 *out_proto_ver = 0;
101 return 1; 101 return 1;
102 } 102 }
@@ -104,17 +104,17 @@ ssl_version_set_max(const SSL_METHOD *meth, uint16_t proto_ver,
104 min_version = min_tls_ver; 104 min_version = min_tls_ver;
105 max_version = proto_ver; 105 max_version = proto_ver;
106 106
107 if (meth->internal->dtls) { 107 if (meth->dtls) {
108 if ((max_version = ssl_dtls_to_tls_version(proto_ver)) == 0) 108 if ((max_version = ssl_dtls_to_tls_version(proto_ver)) == 0)
109 return 0; 109 return 0;
110 } 110 }
111 111
112 if (!ssl_clamp_tls_version_range(&min_version, &max_version, 112 if (!ssl_clamp_tls_version_range(&min_version, &max_version,
113 meth->internal->min_tls_version, meth->internal->max_tls_version)) 113 meth->min_tls_version, meth->max_tls_version))
114 return 0; 114 return 0;
115 115
116 max_proto = max_version; 116 max_proto = max_version;
117 if (meth->internal->dtls) { 117 if (meth->dtls) {
118 if ((max_proto = ssl_tls_to_dtls_version(max_version)) == 0) 118 if ((max_proto = ssl_tls_to_dtls_version(max_version)) == 0)
119 return 0; 119 return 0;
120 } 120 }
@@ -195,8 +195,7 @@ ssl_supported_tls_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver)
195 195
196 /* Limit to the versions supported by this method. */ 196 /* Limit to the versions supported by this method. */
197 if (!ssl_clamp_tls_version_range(&min_version, &max_version, 197 if (!ssl_clamp_tls_version_range(&min_version, &max_version,
198 s->method->internal->min_tls_version, 198 s->method->min_tls_version, s->method->max_tls_version))
199 s->method->internal->max_tls_version))
200 return 0; 199 return 0;
201 200
202 if (min_ver != NULL) 201 if (min_ver != NULL)
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c
index 15afb1bae8..65e2063398 100644
--- a/src/lib/libssl/t1_enc.c
+++ b/src/lib/libssl/t1_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_enc.c,v 1.150 2021/06/13 15:34:41 jsing Exp $ */ 1/* $OpenBSD: t1_enc.c,v 1.151 2021/07/01 17:53:39 jsing 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 *
@@ -389,7 +389,7 @@ tls1_setup_key_block(SSL *s)
389 key_block = NULL; 389 key_block = NULL;
390 390
391 if (!(s->internal->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) && 391 if (!(s->internal->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) &&
392 s->method->internal->version <= TLS1_VERSION) { 392 s->method->version <= TLS1_VERSION) {
393 /* 393 /*
394 * Enable vulnerability countermeasure for CBC ciphers with 394 * Enable vulnerability countermeasure for CBC ciphers with
395 * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) 395 * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt)
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index 72958b7c56..3cb2d8a113 100644
--- a/src/lib/libssl/t1_lib.c
+++ b/src/lib/libssl/t1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_lib.c,v 1.181 2021/06/11 11:13:53 jsing Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.182 2021/07/01 17:53:39 jsing 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 *
@@ -129,7 +129,7 @@ tls1_new(SSL *s)
129{ 129{
130 if (!ssl3_new(s)) 130 if (!ssl3_new(s))
131 return (0); 131 return (0);
132 s->method->internal->ssl_clear(s); 132 s->method->ssl_clear(s);
133 return (1); 133 return (1);
134} 134}
135 135
@@ -147,7 +147,7 @@ void
147tls1_clear(SSL *s) 147tls1_clear(SSL *s)
148{ 148{
149 ssl3_clear(s); 149 ssl3_clear(s);
150 s->version = s->method->internal->version; 150 s->version = s->method->version;
151} 151}
152 152
153static const int nid_list[] = { 153static const int nid_list[] = {
diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c
index 55fefe544f..310a2116b8 100644
--- a/src/lib/libssl/tls13_handshake.c
+++ b/src/lib/libssl/tls13_handshake.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_handshake.c,v 1.68 2021/06/28 18:48:56 tb Exp $ */ 1/* $OpenBSD: tls13_handshake.c,v 1.69 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018-2021 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2018-2021 Theo Buehler <tb@openbsd.org>
4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org>
@@ -535,7 +535,7 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx,
535 tls13_handshake_msg_free(ctx->hs_msg); 535 tls13_handshake_msg_free(ctx->hs_msg);
536 ctx->hs_msg = NULL; 536 ctx->hs_msg = NULL;
537 537
538 if (ctx->ssl->method->internal->version < TLS1_3_VERSION) 538 if (ctx->ssl->method->version < TLS1_3_VERSION)
539 return TLS13_IO_USE_LEGACY; 539 return TLS13_IO_USE_LEGACY;
540 540
541 return ret; 541 return ret;
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c
index cd9ec9942d..beb8952402 100644
--- a/src/lib/libssl/tls13_legacy.c
+++ b/src/lib/libssl/tls13_legacy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_legacy.c,v 1.25 2021/06/28 15:36:51 tb Exp $ */ 1/* $OpenBSD: tls13_legacy.c,v 1.26 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -358,8 +358,8 @@ tls13_use_legacy_client(struct tls13_ctx *ctx)
358 if (!tls13_use_legacy_stack(ctx)) 358 if (!tls13_use_legacy_stack(ctx))
359 return 0; 359 return 0;
360 360
361 s->internal->handshake_func = s->method->internal->ssl_connect; 361 s->internal->handshake_func = s->method->ssl_connect;
362 s->client_version = s->version = s->method->internal->max_tls_version; 362 s->client_version = s->version = s->method->max_tls_version;
363 363
364 return 1; 364 return 1;
365} 365}
@@ -372,8 +372,8 @@ tls13_use_legacy_server(struct tls13_ctx *ctx)
372 if (!tls13_use_legacy_stack(ctx)) 372 if (!tls13_use_legacy_stack(ctx))
373 return 0; 373 return 0;
374 374
375 s->internal->handshake_func = s->method->internal->ssl_accept; 375 s->internal->handshake_func = s->method->ssl_accept;
376 s->client_version = s->version = s->method->internal->max_tls_version; 376 s->client_version = s->version = s->method->max_tls_version;
377 s->server = 1; 377 s->server = 1;
378 378
379 return 1; 379 return 1;
@@ -405,7 +405,7 @@ tls13_legacy_accept(SSL *ssl)
405 405
406 ret = tls13_server_accept(ctx); 406 ret = tls13_server_accept(ctx);
407 if (ret == TLS13_IO_USE_LEGACY) 407 if (ret == TLS13_IO_USE_LEGACY)
408 return ssl->method->internal->ssl_accept(ssl); 408 return ssl->method->ssl_accept(ssl);
409 409
410 return tls13_legacy_return_code(ssl, ret); 410 return tls13_legacy_return_code(ssl, ret);
411} 411}
@@ -420,7 +420,7 @@ tls13_legacy_connect(SSL *ssl)
420 /* XXX drop back to legacy for client auth for now */ 420 /* XXX drop back to legacy for client auth for now */
421 if (ssl->cert->key->privatekey != NULL) { 421 if (ssl->cert->key->privatekey != NULL) {
422 ssl->method = tls_legacy_client_method(); 422 ssl->method = tls_legacy_client_method();
423 return ssl->method->internal->ssl_connect(ssl); 423 return ssl->method->ssl_connect(ssl);
424 } 424 }
425#endif 425#endif
426 426
@@ -444,7 +444,7 @@ tls13_legacy_connect(SSL *ssl)
444 444
445 ret = tls13_client_connect(ctx); 445 ret = tls13_client_connect(ctx);
446 if (ret == TLS13_IO_USE_LEGACY) 446 if (ret == TLS13_IO_USE_LEGACY)
447 return ssl->method->internal->ssl_connect(ssl); 447 return ssl->method->ssl_connect(ssl);
448 448
449 return tls13_legacy_return_code(ssl, ret); 449 return tls13_legacy_return_code(ssl, ret);
450} 450}
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index ff410fbb34..d2c7abbf7c 100644
--- a/src/lib/libssl/tls13_server.c
+++ b/src/lib/libssl/tls13_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_server.c,v 1.83 2021/06/29 19:20:39 jsing Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.84 2021/07/01 17:53:39 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
@@ -282,7 +282,7 @@ tls13_client_hello_recv(struct tls13_ctx *ctx, CBS *cbs)
282 goto err; 282 goto err;
283 283
284 /* See if we switched back to the legacy client method. */ 284 /* See if we switched back to the legacy client method. */
285 if (s->method->internal->version < TLS1_3_VERSION) 285 if (s->method->version < TLS1_3_VERSION)
286 return 1; 286 return 1;
287 287
288 /* 288 /*
@@ -460,7 +460,7 @@ tls13_client_hello_retry_recv(struct tls13_ctx *ctx, CBS *cbs)
460 return 0; 460 return 0;
461 461
462 /* XXX - need further checks. */ 462 /* XXX - need further checks. */
463 if (s->method->internal->version < TLS1_3_VERSION) 463 if (s->method->version < TLS1_3_VERSION)
464 return 0; 464 return 0;
465 465
466 ctx->hs->tls13.hrr = 0; 466 ctx->hs->tls13.hrr = 0;