diff options
-rw-r--r-- | src/lib/libssl/tls13_record_layer.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c index 341bceeabc..7664feffc0 100644 --- a/src/lib/libssl/tls13_record_layer.c +++ b/src/lib/libssl/tls13_record_layer.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_record_layer.c,v 1.29 2020/03/13 16:03:27 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_record_layer.c,v 1.30 2020/03/16 15:11:35 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -166,18 +166,25 @@ tls13_record_layer_rbuf(struct tls13_record_layer *rl, CBS *cbs) | |||
166 | CBS_dup(&rl->rbuf_cbs, cbs); | 166 | CBS_dup(&rl->rbuf_cbs, cbs); |
167 | } | 167 | } |
168 | 168 | ||
169 | uint8_t tls13_max_seq_num[TLS13_RECORD_SEQ_NUM_LEN] = { | ||
170 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
171 | }; | ||
172 | |||
169 | int | 173 | int |
170 | tls13_record_layer_inc_seq_num(uint8_t *seq_num) | 174 | tls13_record_layer_inc_seq_num(uint8_t *seq_num) |
171 | { | 175 | { |
172 | size_t i; | 176 | int i; |
173 | 177 | ||
174 | for (i = TLS13_RECORD_SEQ_NUM_LEN - 1; i > 0; i--) { | 178 | /* RFC 8446 section 5.3 - sequence numbers must not wrap. */ |
179 | if (memcmp(seq_num, tls13_max_seq_num, TLS13_RECORD_SEQ_NUM_LEN) == 0) | ||
180 | return 0; | ||
181 | |||
182 | for (i = TLS13_RECORD_SEQ_NUM_LEN - 1; i >= 0; i--) { | ||
175 | if (++seq_num[i] != 0) | 183 | if (++seq_num[i] != 0) |
176 | break; | 184 | break; |
177 | } | 185 | } |
178 | 186 | ||
179 | /* RFC 8446 section 5.3 - sequence numbers must not wrap. */ | 187 | return 1; |
180 | return (i != 0 || ++seq_num[0] != 0); | ||
181 | } | 188 | } |
182 | 189 | ||
183 | static int | 190 | static int |