diff options
author | jsing <> | 2020-10-15 18:00:31 +0000 |
---|---|---|
committer | jsing <> | 2020-10-15 18:00:31 +0000 |
commit | 698949bfcc12ecdf8b10bdffc544350feeeb348d (patch) | |
tree | f3fb0ed66ad14bbab23fd0e914d2f89440281943 /src | |
parent | 51e760a277d50f30ec1b1c9efe5f0d448e93e3e9 (diff) | |
download | openbsd-698949bfcc12ecdf8b10bdffc544350feeeb348d.tar.gz openbsd-698949bfcc12ecdf8b10bdffc544350feeeb348d.tar.bz2 openbsd-698949bfcc12ecdf8b10bdffc544350feeeb348d.zip |
Unbreak DTLS retransmissions for flights that include a CCS.
When retransmitting a flight that includes a CCS, the record protection
from the previous epoch has to be used to send the messages up to and
including the CCS, with messages after the CCS using record protection
from the current epoch. The code that restores the record protection state
failed to work correctly with the new TLSv1.2 record layer.
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/d1_both.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index 64b9818f52..f554834765 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.61 2020/10/11 03:47:59 jsing Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.62 2020/10/15 18:00:31 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. |
@@ -1055,18 +1055,18 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, | |||
1055 | frag->msg_header.frag_len); | 1055 | frag->msg_header.frag_len); |
1056 | 1056 | ||
1057 | /* save current state */ | 1057 | /* save current state */ |
1058 | saved_state.enc_write_ctx = s->internal->enc_write_ctx; | ||
1059 | saved_state.write_hash = s->internal->write_hash; | ||
1060 | saved_state.session = s->session; | 1058 | saved_state.session = s->session; |
1061 | saved_state.epoch = D1I(s)->w_epoch; | 1059 | saved_state.epoch = D1I(s)->w_epoch; |
1062 | 1060 | ||
1063 | D1I(s)->retransmitting = 1; | 1061 | D1I(s)->retransmitting = 1; |
1064 | 1062 | ||
1065 | /* restore state in which the message was originally sent */ | 1063 | /* restore state in which the message was originally sent */ |
1066 | s->internal->enc_write_ctx = frag->msg_header.saved_retransmit_state.enc_write_ctx; | ||
1067 | s->internal->write_hash = frag->msg_header.saved_retransmit_state.write_hash; | ||
1068 | s->session = frag->msg_header.saved_retransmit_state.session; | 1064 | s->session = frag->msg_header.saved_retransmit_state.session; |
1069 | D1I(s)->w_epoch = frag->msg_header.saved_retransmit_state.epoch; | 1065 | D1I(s)->w_epoch = frag->msg_header.saved_retransmit_state.epoch; |
1066 | if (!tls12_record_layer_set_write_cipher_hash(s->internal->rl, | ||
1067 | frag->msg_header.saved_retransmit_state.enc_write_ctx, | ||
1068 | frag->msg_header.saved_retransmit_state.write_hash, 0)) | ||
1069 | return 0; | ||
1070 | 1070 | ||
1071 | if (frag->msg_header.saved_retransmit_state.epoch == | 1071 | if (frag->msg_header.saved_retransmit_state.epoch == |
1072 | saved_state.epoch - 1) { | 1072 | saved_state.epoch - 1) { |
@@ -1080,10 +1080,11 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, | |||
1080 | SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE); | 1080 | SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE); |
1081 | 1081 | ||
1082 | /* restore current state */ | 1082 | /* restore current state */ |
1083 | s->internal->enc_write_ctx = saved_state.enc_write_ctx; | ||
1084 | s->internal->write_hash = saved_state.write_hash; | ||
1085 | s->session = saved_state.session; | 1083 | s->session = saved_state.session; |
1086 | D1I(s)->w_epoch = saved_state.epoch; | 1084 | D1I(s)->w_epoch = saved_state.epoch; |
1085 | if (!tls12_record_layer_set_write_cipher_hash(s->internal->rl, | ||
1086 | s->internal->enc_write_ctx, s->internal->write_hash, 0)) | ||
1087 | return 0; | ||
1087 | 1088 | ||
1088 | if (frag->msg_header.saved_retransmit_state.epoch == | 1089 | if (frag->msg_header.saved_retransmit_state.epoch == |
1089 | saved_state.epoch - 1) { | 1090 | saved_state.epoch - 1) { |