Delete unreachable DTLS check. It is impossible for us to have an unconsumed ChangeCipherSpec message in dtls_has_unprocessed_handshake_data. dtls_has_unprocessed_handshake_data is only called in dtls1_set_read_state and, in DTLS 1.2 and earlier, we only ever switch the cipher state immediately after consuming ChangeCipherSpec. Remove this because later commits will check has_unprocessed_handshake_data in more places and we have a test (StrayChangeCipherSpec) which asserts we do tolerate arbitrarily early ChangeCipherSpecs messages. There may be something to be said for rejecting this (the peer would have to be doing something weird and sending ChangeCipherSpec in the wrong flight), but ChangeCipherSpec in DTLS is predictable and informationless, so this is probably not worth worrying about. Change-Id: I1bc2952c0ba5231a7f962b9f7ca4c63271ec079f Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39986 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/d1_both.cc b/ssl/d1_both.cc index 2b652d1..c7f85c7 100644 --- a/ssl/d1_both.cc +++ b/ssl/d1_both.cc
@@ -437,10 +437,6 @@ } bool dtls_has_unprocessed_handshake_data(const SSL *ssl) { - if (ssl->d1->has_change_cipher_spec) { - return true; - } - size_t current = ssl->d1->handshake_read_seq % SSL_MAX_HANDSHAKE_FLIGHT; for (size_t i = 0; i < SSL_MAX_HANDSHAKE_FLIGHT; i++) { // Skip the current message.
diff --git a/ssl/dtls_method.cc b/ssl/dtls_method.cc index 0ce7c1f..4b369b6 100644 --- a/ssl/dtls_method.cc +++ b/ssl/dtls_method.cc
@@ -90,6 +90,7 @@ OPENSSL_memset(ssl->s3->read_sequence, 0, sizeof(ssl->s3->read_sequence)); ssl->s3->aead_read_ctx = std::move(aead_ctx); + ssl->d1->has_change_cipher_spec = 0; return true; }