summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_pkt.c
diff options
context:
space:
mode:
authorjsing <>2021-08-30 19:25:43 +0000
committerjsing <>2021-08-30 19:25:43 +0000
commita376b9cd8ffd396f270e597131a83af4f639bd93 (patch)
tree8e3bea79ab1dea102b95252a7e2c36c06522e41d /src/lib/libssl/d1_pkt.c
parentcedbde20c0ecfb870c00ce4fe4401f89a9397b6d (diff)
downloadopenbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.tar.gz
openbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.tar.bz2
openbsd-a376b9cd8ffd396f270e597131a83af4f639bd93.zip
Clean up and simplify info and msg callbacks.
The info and msg callbacks result in duplication - both for code that refers to the function pointers and for the call sites. Avoid this by providing typedefs for the function pointers and pulling the calling sequences into their own functions. ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/d1_pkt.c')
-rw-r--r--src/lib/libssl/d1_pkt.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index 4f0678f0b8..f99b8ff371 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.106 2021/08/30 19:12:25 jsing Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.107 2021/08/30 19:25:43 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.
@@ -515,10 +515,9 @@ dtls1_get_record(SSL *s)
515int 515int
516dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) 516dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
517{ 517{
518 int al, i, j, ret; 518 int al, i, ret;
519 unsigned int n; 519 unsigned int n;
520 SSL3_RECORD_INTERNAL *rr; 520 SSL3_RECORD_INTERNAL *rr;
521 void (*cb)(const SSL *ssl, int type2, int val) = NULL;
522 521
523 if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ 522 if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */
524 if (!ssl3_setup_buffers(s)) 523 if (!ssl3_setup_buffers(s))
@@ -727,9 +726,8 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
727 726
728 /* no need to check sequence number on HELLO REQUEST messages */ 727 /* no need to check sequence number on HELLO REQUEST messages */
729 728
730 if (s->internal->msg_callback) 729 ssl_msg_callback(s, 0, SSL3_RT_HANDSHAKE,
731 s->internal->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, 730 D1I(s)->handshake_fragment, 4);
732 D1I(s)->handshake_fragment, 4, s, s->internal->msg_callback_arg);
733 731
734 if (SSL_is_init_finished(s) && 732 if (SSL_is_init_finished(s) &&
735 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && 733 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
@@ -774,19 +772,10 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
774 772
775 D1I(s)->alert_fragment_len = 0; 773 D1I(s)->alert_fragment_len = 0;
776 774
777 if (s->internal->msg_callback) 775 ssl_msg_callback(s, 0, SSL3_RT_ALERT, D1I(s)->alert_fragment, 2);
778 s->internal->msg_callback(0, s->version, SSL3_RT_ALERT,
779 D1I(s)->alert_fragment, 2, s, s->internal->msg_callback_arg);
780 776
781 if (s->internal->info_callback != NULL) 777 ssl_info_callback(s, SSL_CB_READ_ALERT,
782 cb = s->internal->info_callback; 778 (alert_level << 8) | alert_descr);
783 else if (s->ctx->internal->info_callback != NULL)
784 cb = s->ctx->internal->info_callback;
785
786 if (cb != NULL) {
787 j = (alert_level << 8) | alert_descr;
788 cb(s, SSL_CB_READ_ALERT, j);
789 }
790 779
791 if (alert_level == SSL3_AL_WARNING) { 780 if (alert_level == SSL3_AL_WARNING) {
792 S3I(s)->warn_alert = alert_descr; 781 S3I(s)->warn_alert = alert_descr;
@@ -832,9 +821,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
832 821
833 rr->length = 0; 822 rr->length = 0;
834 823
835 if (s->internal->msg_callback) 824 ssl_msg_callback(s, 0, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1);
836 s->internal->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC,
837 rr->data, 1, s, s->internal->msg_callback_arg);
838 825
839 /* We can't process a CCS now, because previous handshake 826 /* We can't process a CCS now, because previous handshake
840 * messages are still missing, so just drop it. 827 * messages are still missing, so just drop it.