summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2021-10-25 10:09:28 +0000
committerjsing <>2021-10-25 10:09:28 +0000
commitca06f0eb8077fb22dbd7cd11aa65d4c1e3b1c452 (patch)
tree708ee9c17db413f47b181607dd993676182e3daa /src
parentb56105c2617b86206d3688dd7940aa6e553af6e1 (diff)
downloadopenbsd-ca06f0eb8077fb22dbd7cd11aa65d4c1e3b1c452.tar.gz
openbsd-ca06f0eb8077fb22dbd7cd11aa65d4c1e3b1c452.tar.bz2
openbsd-ca06f0eb8077fb22dbd7cd11aa65d4c1e3b1c452.zip
Use ssl_force_want_read() in the DTLS code.
Also mop up some mostly unhelpful comments while here. ok beck@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/d1_pkt.c37
-rw-r--r--src/lib/libssl/ssl_locl.h4
-rw-r--r--src/lib/libssl/ssl_pkt.c18
3 files changed, 15 insertions, 44 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index 7aea85a4c4..9601a39e3a 100644
--- a/src/lib/libssl/d1_pkt.c
+++ b/src/lib/libssl/d1_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_pkt.c,v 1.113 2021/10/23 13:36:03 jsing Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.114 2021/10/25 10:09:28 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.
@@ -654,14 +654,9 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
654 * Application data while renegotiating is allowed. 654 * Application data while renegotiating is allowed.
655 * Try reading again. 655 * Try reading again.
656 */ 656 */
657 BIO *bio;
658
659 S3I(s)->in_read_app_data = 2; 657 S3I(s)->in_read_app_data = 2;
660 bio = SSL_get_rbio(s); 658 ssl_force_want_read(s);
661 s->internal->rwstate = SSL_READING; 659 return -1;
662 BIO_clear_retry_flags(bio);
663 BIO_set_retry_read(bio);
664 return (-1);
665 } else { 660 } else {
666 /* Not certain if this is the right error handling */ 661 /* Not certain if this is the right error handling */
667 al = SSL_AD_UNEXPECTED_MESSAGE; 662 al = SSL_AD_UNEXPECTED_MESSAGE;
@@ -714,17 +709,8 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
714 } 709 }
715 710
716 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { 711 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) {
717 if (S3I(s)->rbuf.left == 0) /* no read-ahead left? */ 712 if (S3I(s)->rbuf.left == 0) {
718 { 713 ssl_force_want_read(s);
719 BIO *bio;
720 /* In the case where we try to read application data,
721 * but we trigger an SSL handshake, we return -1 with
722 * the retry option set. Otherwise renegotiation may
723 * cause nasty problems in the blocking world */
724 s->internal->rwstate = SSL_READING;
725 bio = SSL_get_rbio(s);
726 BIO_clear_retry_flags(bio);
727 BIO_set_retry_read(bio);
728 return (-1); 714 return (-1);
729 } 715 }
730 } 716 }
@@ -851,17 +837,8 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
851 } 837 }
852 838
853 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { 839 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) {
854 if (S3I(s)->rbuf.left == 0) /* no read-ahead left? */ 840 if (S3I(s)->rbuf.left == 0) {
855 { 841 ssl_force_want_read(s);
856 BIO *bio;
857 /* In the case where we try to read application data,
858 * but we trigger an SSL handshake, we return -1 with
859 * the retry option set. Otherwise renegotiation may
860 * cause nasty problems in the blocking world */
861 s->internal->rwstate = SSL_READING;
862 bio = SSL_get_rbio(s);
863 BIO_clear_retry_flags(bio);
864 BIO_set_retry_read(bio);
865 return (-1); 842 return (-1);
866 } 843 }
867 } 844 }
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 01c22762ef..27bf5ec41f 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.367 2021/10/25 10:01:46 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.368 2021/10/25 10:09:28 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 *
@@ -1372,6 +1372,8 @@ int ssl3_renegotiate(SSL *ssl);
1372 1372
1373int ssl3_renegotiate_check(SSL *ssl); 1373int ssl3_renegotiate_check(SSL *ssl);
1374 1374
1375void ssl_force_want_read(SSL *s);
1376
1375int ssl3_dispatch_alert(SSL *s); 1377int ssl3_dispatch_alert(SSL *s);
1376int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); 1378int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
1377int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); 1379int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c
index 049a7df3c3..8a5f97e5c7 100644
--- a/src/lib/libssl/ssl_pkt.c
+++ b/src/lib/libssl/ssl_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_pkt.c,v 1.50 2021/08/30 19:25:43 jsing Exp $ */ 1/* $OpenBSD: ssl_pkt.c,v 1.51 2021/10/25 10:09:28 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 *
@@ -127,14 +127,15 @@ static int ssl3_get_record(SSL *s);
127 * Force a WANT_READ return for certain error conditions where 127 * Force a WANT_READ return for certain error conditions where
128 * we don't want to spin internally. 128 * we don't want to spin internally.
129 */ 129 */
130static void 130void
131ssl_force_want_read(SSL *s) 131ssl_force_want_read(SSL *s)
132{ 132{
133 BIO * bio; 133 BIO *bio;
134 134
135 bio = SSL_get_rbio(s); 135 bio = SSL_get_rbio(s);
136 BIO_clear_retry_flags(bio); 136 BIO_clear_retry_flags(bio);
137 BIO_set_retry_read(bio); 137 BIO_set_retry_read(bio);
138
138 s->internal->rwstate = SSL_READING; 139 s->internal->rwstate = SSL_READING;
139} 140}
140 141
@@ -931,11 +932,6 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
931 932
932 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { 933 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) {
933 if (S3I(s)->rbuf.left == 0) { 934 if (S3I(s)->rbuf.left == 0) {
934 /* no read-ahead left? */
935 /* In the case where we try to read application data,
936 * but we trigger an SSL handshake, we return -1 with
937 * the retry option set. Otherwise renegotiation may
938 * cause nasty problems in the blocking world */
939 ssl_force_want_read(s); 935 ssl_force_want_read(s);
940 return (-1); 936 return (-1);
941 } 937 }
@@ -1079,11 +1075,7 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
1079 } 1075 }
1080 1076
1081 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { 1077 if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) {
1082 if (S3I(s)->rbuf.left == 0) { /* no read-ahead left? */ 1078 if (S3I(s)->rbuf.left == 0) {
1083 /* In the case where we try to read application data,
1084 * but we trigger an SSL handshake, we return -1 with
1085 * the retry option set. Otherwise renegotiation may
1086 * cause nasty problems in the blocking world */
1087 ssl_force_want_read(s); 1079 ssl_force_want_read(s);
1088 return (-1); 1080 return (-1);
1089 } 1081 }