diff options
| author | jsing <> | 2026-05-06 15:06:35 +0000 |
|---|---|---|
| committer | jsing <> | 2026-05-06 15:06:35 +0000 |
| commit | 97930339bcae324ce6c463f52bdcdf98c4be2941 (patch) | |
| tree | caa8b3dbcf94d357dc014532cae804dbeea5165b /src/lib/libssl | |
| parent | e162d1d43a0870508c4db32a52b441f1b7d96ebe (diff) | |
| download | openbsd-97930339bcae324ce6c463f52bdcdf98c4be2941.tar.gz openbsd-97930339bcae324ce6c463f52bdcdf98c4be2941.tar.bz2 openbsd-97930339bcae324ce6c463f52bdcdf98c4be2941.zip | |
Get rid of struct dtls1_retransmit_state.
In order to retransmit DTLS messages we potentially need to use the
record protection from a previous epoch. However, DTLS currently also
saves and restores the session, which is unnecessary - all of the
record protection and keys are handled in the TLS record layer.
Remove the rather useless dtls1_retransmit_state struct and just
keep the epoch - keeping pointers hanging around to sessions is pretty
nasty and unnecessary.
ok kenjiro@ tb@
Diffstat (limited to 'src/lib/libssl')
| -rw-r--r-- | src/lib/libssl/d1_both.c | 27 | ||||
| -rw-r--r-- | src/lib/libssl/dtls_local.h | 9 |
2 files changed, 10 insertions, 26 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index 32bbf41966..de915fa4b2 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.92 2026/04/30 15:38:52 jsing Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.93 2026/05/06 15:06:35 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. |
| @@ -928,8 +928,8 @@ dtls1_get_queue_priority(unsigned short seq, int is_ccs) | |||
| 928 | static int | 928 | static int |
| 929 | dtls1_retransmit_message(SSL *s, hm_fragment *frag) | 929 | dtls1_retransmit_message(SSL *s, hm_fragment *frag) |
| 930 | { | 930 | { |
| 931 | struct dtls1_retransmit_state saved_state; | ||
| 932 | unsigned long header_length; | 931 | unsigned long header_length; |
| 932 | uint16_t epoch; | ||
| 933 | int ret; | 933 | int ret; |
| 934 | 934 | ||
| 935 | if (frag->msg_header.is_ccs) | 935 | if (frag->msg_header.is_ccs) |
| @@ -945,25 +945,18 @@ dtls1_retransmit_message(SSL *s, hm_fragment *frag) | |||
| 945 | frag->msg_header.msg_len, frag->msg_header.seq, 0, | 945 | frag->msg_header.msg_len, frag->msg_header.seq, 0, |
| 946 | frag->msg_header.frag_len); | 946 | frag->msg_header.frag_len); |
| 947 | 947 | ||
| 948 | /* save current state */ | 948 | epoch = tls12_record_layer_write_epoch(s->rl); |
| 949 | saved_state.session = s->session; | ||
| 950 | saved_state.epoch = tls12_record_layer_write_epoch(s->rl); | ||
| 951 | 949 | ||
| 952 | s->d1->retransmitting = 1; | 950 | s->d1->retransmitting = 1; |
| 953 | 951 | ||
| 954 | /* restore state in which the message was originally sent */ | 952 | /* Switch to the epoch that was used to send the message. */ |
| 955 | s->session = frag->msg_header.saved_retransmit_state.session; | 953 | if (!tls12_record_layer_use_write_epoch(s->rl, frag->msg_header.epoch)) |
| 956 | if (!tls12_record_layer_use_write_epoch(s->rl, | ||
| 957 | frag->msg_header.saved_retransmit_state.epoch)) | ||
| 958 | return 0; | 954 | return 0; |
| 959 | 955 | ||
| 960 | ret = dtls1_do_write(s, frag->msg_header.is_ccs ? | 956 | ret = dtls1_do_write(s, frag->msg_header.is_ccs ? |
| 961 | SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE); | 957 | SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE); |
| 962 | 958 | ||
| 963 | /* restore current state */ | 959 | if (!tls12_record_layer_use_write_epoch(s->rl, epoch)) |
| 964 | s->session = saved_state.session; | ||
| 965 | if (!tls12_record_layer_use_write_epoch(s->rl, | ||
| 966 | saved_state.epoch)) | ||
| 967 | return 0; | 960 | return 0; |
| 968 | 961 | ||
| 969 | s->d1->retransmitting = 0; | 962 | s->d1->retransmitting = 0; |
| @@ -1020,6 +1013,7 @@ dtls1_buffer_message(SSL *s, int is_ccs) | |||
| 1020 | (is_ccs ? DTLS1_CCS_HEADER_LENGTH : DTLS1_HM_HEADER_LENGTH) == | 1013 | (is_ccs ? DTLS1_CCS_HEADER_LENGTH : DTLS1_HM_HEADER_LENGTH) == |
| 1021 | (unsigned int)s->init_num); | 1014 | (unsigned int)s->init_num); |
| 1022 | 1015 | ||
| 1016 | frag->msg_header.epoch = tls12_record_layer_write_epoch(s->rl); | ||
| 1023 | frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; | 1017 | frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; |
| 1024 | frag->msg_header.seq = s->d1->w_msg_hdr.seq; | 1018 | frag->msg_header.seq = s->d1->w_msg_hdr.seq; |
| 1025 | frag->msg_header.type = s->d1->w_msg_hdr.type; | 1019 | frag->msg_header.type = s->d1->w_msg_hdr.type; |
| @@ -1027,11 +1021,6 @@ dtls1_buffer_message(SSL *s, int is_ccs) | |||
| 1027 | frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; | 1021 | frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; |
| 1028 | frag->msg_header.is_ccs = is_ccs; | 1022 | frag->msg_header.is_ccs = is_ccs; |
| 1029 | 1023 | ||
| 1030 | /* save current state*/ | ||
| 1031 | frag->msg_header.saved_retransmit_state.session = s->session; | ||
| 1032 | frag->msg_header.saved_retransmit_state.epoch = | ||
| 1033 | tls12_record_layer_write_epoch(s->rl); | ||
| 1034 | |||
| 1035 | memset(seq64be, 0, sizeof(seq64be)); | 1024 | memset(seq64be, 0, sizeof(seq64be)); |
| 1036 | seq64be[6] = (unsigned char)(dtls1_get_queue_priority( | 1025 | seq64be[6] = (unsigned char)(dtls1_get_queue_priority( |
| 1037 | frag->msg_header.seq, frag->msg_header.is_ccs) >> 8); | 1026 | frag->msg_header.seq, frag->msg_header.is_ccs) >> 8); |
| @@ -1060,7 +1049,7 @@ dtls1_clear_record_buffer(SSL *s) | |||
| 1060 | frag = item->data; | 1049 | frag = item->data; |
| 1061 | if (frag->msg_header.is_ccs) | 1050 | if (frag->msg_header.is_ccs) |
| 1062 | tls12_record_layer_write_epoch_done(s->rl, | 1051 | tls12_record_layer_write_epoch_done(s->rl, |
| 1063 | frag->msg_header.saved_retransmit_state.epoch); | 1052 | frag->msg_header.epoch); |
| 1064 | dtls1_hm_fragment_free(frag); | 1053 | dtls1_hm_fragment_free(frag); |
| 1065 | pitem_free(item); | 1054 | pitem_free(item); |
| 1066 | } | 1055 | } |
diff --git a/src/lib/libssl/dtls_local.h b/src/lib/libssl/dtls_local.h index 3352b31d3c..5a85bba607 100644 --- a/src/lib/libssl/dtls_local.h +++ b/src/lib/libssl/dtls_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dtls_local.h,v 1.3 2026/04/29 14:59:26 jsing Exp $ */ | 1 | /* $OpenBSD: dtls_local.h,v 1.4 2026/05/06 15:06:35 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. |
| @@ -77,19 +77,14 @@ typedef struct dtls1_bitmap_st { | |||
| 77 | encoding */ | 77 | encoding */ |
| 78 | } DTLS1_BITMAP; | 78 | } DTLS1_BITMAP; |
| 79 | 79 | ||
| 80 | struct dtls1_retransmit_state { | ||
| 81 | SSL_SESSION *session; | ||
| 82 | unsigned short epoch; | ||
| 83 | }; | ||
| 84 | |||
| 85 | struct hm_header_st { | 80 | struct hm_header_st { |
| 81 | uint16_t epoch; | ||
| 86 | unsigned char type; | 82 | unsigned char type; |
| 87 | unsigned long msg_len; | 83 | unsigned long msg_len; |
| 88 | unsigned short seq; | 84 | unsigned short seq; |
| 89 | unsigned long frag_off; | 85 | unsigned long frag_off; |
| 90 | unsigned long frag_len; | 86 | unsigned long frag_len; |
| 91 | unsigned int is_ccs; | 87 | unsigned int is_ccs; |
| 92 | struct dtls1_retransmit_state saved_retransmit_state; | ||
| 93 | }; | 88 | }; |
| 94 | 89 | ||
| 95 | struct dtls1_timeout_st { | 90 | struct dtls1_timeout_st { |
