diff options
author | jsing <> | 2021-07-21 07:51:12 +0000 |
---|---|---|
committer | jsing <> | 2021-07-21 07:51:12 +0000 |
commit | 79b1c4fd5d0d72bf2e38130064b797ecc99c1cbe (patch) | |
tree | 48b0f617acae7d3ff31ef0ae1660881904e23310 /src | |
parent | bf8b2c9ec0c609c82b5461ea29f83549dc7ac156 (diff) | |
download | openbsd-79b1c4fd5d0d72bf2e38130064b797ecc99c1cbe.tar.gz openbsd-79b1c4fd5d0d72bf2e38130064b797ecc99c1cbe.tar.bz2 openbsd-79b1c4fd5d0d72bf2e38130064b797ecc99c1cbe.zip |
Silently discard invalid DTLS records.
Per RFC 6347 section 4.1.2.1, DTLS should silently discard invalid records,
including those that have a bad MAC. When converting to the new record
layer, we inadvertantly switched to standard TLS behaviour, where an
invalid record is fatal. This restores the previous behaviour.
Issue noted by inoguchi@
ok inoguchi@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 2610206797..4e773a42bb 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.101 2021/07/19 08:42:24 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.102 2021/07/21 07:51:12 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. |
@@ -323,14 +323,22 @@ dtls1_process_record(SSL *s) | |||
323 | if (alert_desc == 0) | 323 | if (alert_desc == 0) |
324 | goto err; | 324 | goto err; |
325 | 325 | ||
326 | /* | ||
327 | * DTLS should silently discard invalid records, including those | ||
328 | * with a bad MAC, as per RFC 6347 section 4.1.2.1. | ||
329 | */ | ||
330 | if (alert_desc == SSL_AD_BAD_RECORD_MAC) { | ||
331 | out_len = 0; | ||
332 | goto done; | ||
333 | } | ||
334 | |||
326 | if (alert_desc == SSL_AD_RECORD_OVERFLOW) | 335 | if (alert_desc == SSL_AD_RECORD_OVERFLOW) |
327 | SSLerror(s, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); | 336 | SSLerror(s, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); |
328 | else if (alert_desc == SSL_AD_BAD_RECORD_MAC) | ||
329 | SSLerror(s, SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); | ||
330 | 337 | ||
331 | goto fatal_err; | 338 | goto fatal_err; |
332 | } | 339 | } |
333 | 340 | ||
341 | done: | ||
334 | rr->data = out; | 342 | rr->data = out; |
335 | rr->length = out_len; | 343 | rr->length = out_len; |
336 | rr->off = 0; | 344 | rr->off = 0; |
@@ -345,7 +353,6 @@ dtls1_process_record(SSL *s) | |||
345 | return (0); | 353 | return (0); |
346 | } | 354 | } |
347 | 355 | ||
348 | |||
349 | /* Call this to get a new input record. | 356 | /* Call this to get a new input record. |
350 | * It will return <= 0 if more data is needed, normally due to an error | 357 | * It will return <= 0 if more data is needed, normally due to an error |
351 | * or non-blocking IO. | 358 | * or non-blocking IO. |