summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_pkt.c
diff options
context:
space:
mode:
authorjsing <>2022-03-12 12:53:03 +0000
committerjsing <>2022-03-12 12:53:03 +0000
commit924b94dac6d48df7daea80927390c63e10863ed6 (patch)
tree0822cee7fbb7194d5613d2baad06f9531f240e4a /src/lib/libssl/d1_pkt.c
parent745a0da49b7b262611e528bfb7f6803314c4650f (diff)
downloadopenbsd-924b94dac6d48df7daea80927390c63e10863ed6.tar.gz
openbsd-924b94dac6d48df7daea80927390c63e10863ed6.tar.bz2
openbsd-924b94dac6d48df7daea80927390c63e10863ed6.zip
Factor out change cipher spec handing code in the legacy stack.
Factor out the code that handles the processing of a change cipher spec message that has been read in the legacy stack, deduplicating code in the DTLS stack. ok inoguchi@ tb@
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/d1_pkt.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index e07fc7e3f9..6ed04395b9 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.118 2022/02/21 18:22:20 jsing Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.119 2022/03/12 12:53:03 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.
@@ -748,33 +748,8 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
748 } 748 }
749 749
750 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { 750 if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) {
751 /* 'Change Cipher Spec' is just a single byte, so we know 751 if ((ret = ssl3_read_change_cipher_spec(s)) <= 0)
752 * exactly what the record payload has to look like */ 752 return ret;
753 /* XDTLS: check that epoch is consistent */
754 if ((rr->length != DTLS1_CCS_HEADER_LENGTH) ||
755 (rr->off != 0) || (rr->data[0] != SSL3_MT_CCS)) {
756 al = SSL_AD_DECODE_ERROR;
757 SSLerror(s, SSL_R_BAD_CHANGE_CIPHER_SPEC);
758 goto fatal_err;
759 }
760
761 ssl_msg_callback(s, 0, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1);
762
763 /* We can't process a CCS now, because previous handshake
764 * messages are still missing, so just drop it.
765 */
766 if (!s->d1->change_cipher_spec_ok) {
767 rr->length = 0;
768 goto start;
769 }
770
771 s->d1->change_cipher_spec_ok = 0;
772
773 s->s3->change_cipher_spec = 1;
774 if (!ssl3_do_change_cipher_spec(s))
775 goto err;
776
777 rr->length = 0;
778 goto start; 753 goto start;
779 } 754 }
780 755
@@ -872,7 +847,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
872 847
873 fatal_err: 848 fatal_err:
874 ssl3_send_alert(s, SSL3_AL_FATAL, al); 849 ssl3_send_alert(s, SSL3_AL_FATAL, al);
875 err: 850
876 return (-1); 851 return (-1);
877} 852}
878 853