diff options
Diffstat (limited to 'src/lib/libssl/d1_pkt.c')
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 12a711324a..e884f2d592 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.116 2021/11/09 18:40:21 bcook Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.117 2022/02/05 14:54:10 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. |
@@ -191,12 +191,12 @@ static int dtls1_process_record(SSL *s); | |||
191 | static int | 191 | static int |
192 | dtls1_copy_record(SSL *s, DTLS1_RECORD_DATA_INTERNAL *rdata) | 192 | dtls1_copy_record(SSL *s, DTLS1_RECORD_DATA_INTERNAL *rdata) |
193 | { | 193 | { |
194 | ssl3_release_buffer(&S3I(s)->rbuf); | 194 | ssl3_release_buffer(&s->s3->rbuf); |
195 | 195 | ||
196 | s->internal->packet = rdata->packet; | 196 | s->internal->packet = rdata->packet; |
197 | s->internal->packet_length = rdata->packet_length; | 197 | s->internal->packet_length = rdata->packet_length; |
198 | memcpy(&(S3I(s)->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); | 198 | memcpy(&(s->s3->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); |
199 | memcpy(&(S3I(s)->rrec), &(rdata->rrec), sizeof(SSL3_RECORD_INTERNAL)); | 199 | memcpy(&(s->s3->rrec), &(rdata->rrec), sizeof(SSL3_RECORD_INTERNAL)); |
200 | 200 | ||
201 | return (1); | 201 | return (1); |
202 | } | 202 | } |
@@ -218,15 +218,15 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) | |||
218 | 218 | ||
219 | rdata->packet = s->internal->packet; | 219 | rdata->packet = s->internal->packet; |
220 | rdata->packet_length = s->internal->packet_length; | 220 | rdata->packet_length = s->internal->packet_length; |
221 | memcpy(&(rdata->rbuf), &(S3I(s)->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); | 221 | memcpy(&(rdata->rbuf), &(s->s3->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); |
222 | memcpy(&(rdata->rrec), &(S3I(s)->rrec), sizeof(SSL3_RECORD_INTERNAL)); | 222 | memcpy(&(rdata->rrec), &(s->s3->rrec), sizeof(SSL3_RECORD_INTERNAL)); |
223 | 223 | ||
224 | item->data = rdata; | 224 | item->data = rdata; |
225 | 225 | ||
226 | s->internal->packet = NULL; | 226 | s->internal->packet = NULL; |
227 | s->internal->packet_length = 0; | 227 | s->internal->packet_length = 0; |
228 | memset(&(S3I(s)->rbuf), 0, sizeof(SSL3_BUFFER_INTERNAL)); | 228 | memset(&(s->s3->rbuf), 0, sizeof(SSL3_BUFFER_INTERNAL)); |
229 | memset(&(S3I(s)->rrec), 0, sizeof(SSL3_RECORD_INTERNAL)); | 229 | memset(&(s->s3->rrec), 0, sizeof(SSL3_RECORD_INTERNAL)); |
230 | 230 | ||
231 | if (!ssl3_setup_buffers(s)) | 231 | if (!ssl3_setup_buffers(s)) |
232 | goto err; | 232 | goto err; |
@@ -293,7 +293,7 @@ dtls1_process_buffered_record(SSL *s) | |||
293 | static int | 293 | static int |
294 | dtls1_process_record(SSL *s) | 294 | dtls1_process_record(SSL *s) |
295 | { | 295 | { |
296 | SSL3_RECORD_INTERNAL *rr = &(S3I(s)->rrec); | 296 | SSL3_RECORD_INTERNAL *rr = &(s->s3->rrec); |
297 | uint8_t alert_desc; | 297 | uint8_t alert_desc; |
298 | uint8_t *out; | 298 | uint8_t *out; |
299 | size_t out_len; | 299 | size_t out_len; |
@@ -349,7 +349,7 @@ dtls1_process_record(SSL *s) | |||
349 | int | 349 | int |
350 | dtls1_get_record(SSL *s) | 350 | dtls1_get_record(SSL *s) |
351 | { | 351 | { |
352 | SSL3_RECORD_INTERNAL *rr = &(S3I(s)->rrec); | 352 | SSL3_RECORD_INTERNAL *rr = &(s->s3->rrec); |
353 | unsigned char *p = NULL; | 353 | unsigned char *p = NULL; |
354 | DTLS1_BITMAP *bitmap; | 354 | DTLS1_BITMAP *bitmap; |
355 | unsigned int is_next_epoch; | 355 | unsigned int is_next_epoch; |
@@ -517,7 +517,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
517 | unsigned int n; | 517 | unsigned int n; |
518 | SSL3_RECORD_INTERNAL *rr; | 518 | SSL3_RECORD_INTERNAL *rr; |
519 | 519 | ||
520 | if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ | 520 | if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ |
521 | if (!ssl3_setup_buffers(s)) | 521 | if (!ssl3_setup_buffers(s)) |
522 | return (-1); | 522 | return (-1); |
523 | 523 | ||
@@ -554,17 +554,17 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
554 | 554 | ||
555 | s->internal->rwstate = SSL_NOTHING; | 555 | s->internal->rwstate = SSL_NOTHING; |
556 | 556 | ||
557 | /* S3I(s)->rrec.type - is the type of record | 557 | /* s->s3->rrec.type - is the type of record |
558 | * S3I(s)->rrec.data, - data | 558 | * s->s3->rrec.data, - data |
559 | * S3I(s)->rrec.off, - offset into 'data' for next read | 559 | * s->s3->rrec.off, - offset into 'data' for next read |
560 | * S3I(s)->rrec.length, - number of bytes. */ | 560 | * s->s3->rrec.length, - number of bytes. */ |
561 | rr = &(S3I(s)->rrec); | 561 | rr = &(s->s3->rrec); |
562 | 562 | ||
563 | /* We are not handshaking and have no data yet, | 563 | /* We are not handshaking and have no data yet, |
564 | * so process data buffered during the last handshake | 564 | * so process data buffered during the last handshake |
565 | * in advance, if any. | 565 | * in advance, if any. |
566 | */ | 566 | */ |
567 | if (S3I(s)->hs.state == SSL_ST_OK && rr->length == 0) | 567 | if (s->s3->hs.state == SSL_ST_OK && rr->length == 0) |
568 | dtls1_retrieve_buffered_record(s, &(s->d1->buffered_app_data)); | 568 | dtls1_retrieve_buffered_record(s, &(s->d1->buffered_app_data)); |
569 | 569 | ||
570 | /* Check for timeout */ | 570 | /* Check for timeout */ |
@@ -591,7 +591,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
591 | 591 | ||
592 | /* we now have a packet which can be read and processed */ | 592 | /* we now have a packet which can be read and processed */ |
593 | 593 | ||
594 | if (S3I(s)->change_cipher_spec /* set when we receive ChangeCipherSpec, | 594 | if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, |
595 | * reset by ssl3_get_finished */ | 595 | * reset by ssl3_get_finished */ |
596 | && (rr->type != SSL3_RT_HANDSHAKE)) { | 596 | && (rr->type != SSL3_RT_HANDSHAKE)) { |
597 | /* We now have application data between CCS and Finished. | 597 | /* We now have application data between CCS and Finished. |
@@ -667,7 +667,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
667 | * Application data while renegotiating is allowed. | 667 | * Application data while renegotiating is allowed. |
668 | * Try reading again. | 668 | * Try reading again. |
669 | */ | 669 | */ |
670 | S3I(s)->in_read_app_data = 2; | 670 | s->s3->in_read_app_data = 2; |
671 | ssl_force_want_read(s); | 671 | ssl_force_want_read(s); |
672 | return -1; | 672 | return -1; |
673 | } else { | 673 | } else { |
@@ -708,7 +708,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
708 | 708 | ||
709 | if (SSL_is_init_finished(s) && | 709 | if (SSL_is_init_finished(s) && |
710 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && | 710 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && |
711 | !S3I(s)->renegotiate) { | 711 | !s->s3->renegotiate) { |
712 | s->d1->handshake_read_seq++; | 712 | s->d1->handshake_read_seq++; |
713 | s->internal->new_session = 1; | 713 | s->internal->new_session = 1; |
714 | ssl3_renegotiate(s); | 714 | ssl3_renegotiate(s); |
@@ -722,7 +722,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
722 | } | 722 | } |
723 | 723 | ||
724 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { | 724 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { |
725 | if (S3I(s)->rbuf.left == 0) { | 725 | if (s->s3->rbuf.left == 0) { |
726 | ssl_force_want_read(s); | 726 | ssl_force_want_read(s); |
727 | return (-1); | 727 | return (-1); |
728 | } | 728 | } |
@@ -746,14 +746,14 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
746 | (alert_level << 8) | alert_descr); | 746 | (alert_level << 8) | alert_descr); |
747 | 747 | ||
748 | if (alert_level == SSL3_AL_WARNING) { | 748 | if (alert_level == SSL3_AL_WARNING) { |
749 | S3I(s)->warn_alert = alert_descr; | 749 | s->s3->warn_alert = alert_descr; |
750 | if (alert_descr == SSL_AD_CLOSE_NOTIFY) { | 750 | if (alert_descr == SSL_AD_CLOSE_NOTIFY) { |
751 | s->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; | 751 | s->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; |
752 | return (0); | 752 | return (0); |
753 | } | 753 | } |
754 | } else if (alert_level == SSL3_AL_FATAL) { | 754 | } else if (alert_level == SSL3_AL_FATAL) { |
755 | s->internal->rwstate = SSL_NOTHING; | 755 | s->internal->rwstate = SSL_NOTHING; |
756 | S3I(s)->fatal_alert = alert_descr; | 756 | s->s3->fatal_alert = alert_descr; |
757 | SSLerror(s, SSL_AD_REASON_OFFSET + alert_descr); | 757 | SSLerror(s, SSL_AD_REASON_OFFSET + alert_descr); |
758 | ERR_asprintf_error_data("SSL alert number %d", | 758 | ERR_asprintf_error_data("SSL alert number %d", |
759 | alert_descr); | 759 | alert_descr); |
@@ -799,7 +799,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
799 | 799 | ||
800 | s->d1->change_cipher_spec_ok = 0; | 800 | s->d1->change_cipher_spec_ok = 0; |
801 | 801 | ||
802 | S3I(s)->change_cipher_spec = 1; | 802 | s->s3->change_cipher_spec = 1; |
803 | if (!ssl3_do_change_cipher_spec(s)) | 803 | if (!ssl3_do_change_cipher_spec(s)) |
804 | goto err; | 804 | goto err; |
805 | 805 | ||
@@ -835,9 +835,9 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
835 | goto start; | 835 | goto start; |
836 | } | 836 | } |
837 | 837 | ||
838 | if (((S3I(s)->hs.state&SSL_ST_MASK) == SSL_ST_OK) && | 838 | if (((s->s3->hs.state&SSL_ST_MASK) == SSL_ST_OK) && |
839 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { | 839 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { |
840 | S3I(s)->hs.state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; | 840 | s->s3->hs.state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; |
841 | s->internal->renegotiate = 1; | 841 | s->internal->renegotiate = 1; |
842 | s->internal->new_session = 1; | 842 | s->internal->new_session = 1; |
843 | } | 843 | } |
@@ -850,7 +850,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
850 | } | 850 | } |
851 | 851 | ||
852 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { | 852 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { |
853 | if (S3I(s)->rbuf.left == 0) { | 853 | if (s->s3->rbuf.left == 0) { |
854 | ssl_force_want_read(s); | 854 | ssl_force_want_read(s); |
855 | return (-1); | 855 | return (-1); |
856 | } | 856 | } |
@@ -881,15 +881,15 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
881 | * at this point (session renegotiation not yet started), | 881 | * at this point (session renegotiation not yet started), |
882 | * we will indulge it. | 882 | * we will indulge it. |
883 | */ | 883 | */ |
884 | if (S3I(s)->in_read_app_data && | 884 | if (s->s3->in_read_app_data && |
885 | (S3I(s)->total_renegotiations != 0) && | 885 | (s->s3->total_renegotiations != 0) && |
886 | (((S3I(s)->hs.state & SSL_ST_CONNECT) && | 886 | (((s->s3->hs.state & SSL_ST_CONNECT) && |
887 | (S3I(s)->hs.state >= SSL3_ST_CW_CLNT_HELLO_A) && | 887 | (s->s3->hs.state >= SSL3_ST_CW_CLNT_HELLO_A) && |
888 | (S3I(s)->hs.state <= SSL3_ST_CR_SRVR_HELLO_A)) || ( | 888 | (s->s3->hs.state <= SSL3_ST_CR_SRVR_HELLO_A)) || ( |
889 | (S3I(s)->hs.state & SSL_ST_ACCEPT) && | 889 | (s->s3->hs.state & SSL_ST_ACCEPT) && |
890 | (S3I(s)->hs.state <= SSL3_ST_SW_HELLO_REQ_A) && | 890 | (s->s3->hs.state <= SSL3_ST_SW_HELLO_REQ_A) && |
891 | (S3I(s)->hs.state >= SSL3_ST_SR_CLNT_HELLO_A)))) { | 891 | (s->s3->hs.state >= SSL3_ST_SR_CLNT_HELLO_A)))) { |
892 | S3I(s)->in_read_app_data = 2; | 892 | s->s3->in_read_app_data = 2; |
893 | return (-1); | 893 | return (-1); |
894 | } else { | 894 | } else { |
895 | al = SSL_AD_UNEXPECTED_MESSAGE; | 895 | al = SSL_AD_UNEXPECTED_MESSAGE; |
@@ -947,7 +947,7 @@ dtls1_write_bytes(SSL *s, int type, const void *buf, int len) | |||
947 | int | 947 | int |
948 | do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | 948 | do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) |
949 | { | 949 | { |
950 | SSL3_BUFFER_INTERNAL *wb = &(S3I(s)->wbuf); | 950 | SSL3_BUFFER_INTERNAL *wb = &(s->s3->wbuf); |
951 | size_t out_len; | 951 | size_t out_len; |
952 | CBB cbb; | 952 | CBB cbb; |
953 | int ret; | 953 | int ret; |
@@ -964,7 +964,7 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
964 | } | 964 | } |
965 | 965 | ||
966 | /* If we have an alert to send, let's send it */ | 966 | /* If we have an alert to send, let's send it */ |
967 | if (S3I(s)->alert_dispatch) { | 967 | if (s->s3->alert_dispatch) { |
968 | if ((ret = ssl3_dispatch_alert(s)) <= 0) | 968 | if ((ret = ssl3_dispatch_alert(s)) <= 0) |
969 | return (ret); | 969 | return (ret); |
970 | /* If it went, fall through and send more stuff. */ | 970 | /* If it went, fall through and send more stuff. */ |
@@ -992,10 +992,10 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
992 | * Memorize arguments so that ssl3_write_pending can detect | 992 | * Memorize arguments so that ssl3_write_pending can detect |
993 | * bad write retries later. | 993 | * bad write retries later. |
994 | */ | 994 | */ |
995 | S3I(s)->wpend_tot = len; | 995 | s->s3->wpend_tot = len; |
996 | S3I(s)->wpend_buf = buf; | 996 | s->s3->wpend_buf = buf; |
997 | S3I(s)->wpend_type = type; | 997 | s->s3->wpend_type = type; |
998 | S3I(s)->wpend_ret = len; | 998 | s->s3->wpend_ret = len; |
999 | 999 | ||
1000 | /* We now just need to write the buffer. */ | 1000 | /* We now just need to write the buffer. */ |
1001 | return ssl3_write_pending(s, type, buf, len); | 1001 | return ssl3_write_pending(s, type, buf, len); |