Skip to content

Commit

Permalink
Merge pull request #854 from tlsfuzzer/hrr-detection
Browse files Browse the repository at this point in the history
report HelloRetryRequest as such in unexpected message exception
  • Loading branch information
tomato42 committed Aug 17, 2023
2 parents 59a1117 + 08c9ca1 commit 58b4205
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/test_tlsfuzzer_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ def test_guess_response_with_handshake(self):

self.assertEqual("Handshake(client_hello)",
guess_response(content_type, data))

def test_guess_response_with_hello_retry_request(self):
content_type = constants.ContentType.handshake
data = bytearray([constants.HandshakeType.server_hello,
0, 0, 34, # length
3, 3] # version number
) + constants.TLS_1_3_HRR

self.assertEqual("Handshake(server_hello, hello_retry_request)",
guess_response(content_type, data))

def test_guess_response_with_invalid_handshake(self):
content_type = constants.ContentType.handshake
data = bytearray()
Expand Down
5 changes: 4 additions & 1 deletion tlsfuzzer/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tlslite.handshakehashes import HandshakeHashes
from tlslite.errors import TLSAbruptCloseError
from tlslite.constants import ContentType, HandshakeType, AlertLevel, \
AlertDescription, SSL2HandshakeType, CipherSuite
AlertDescription, SSL2HandshakeType, CipherSuite, TLS_1_3_HRR
from .expect import ExpectClose, ExpectNoMessage, ExpectAlert

class ConnectionState(object):
Expand Down Expand Up @@ -158,6 +158,9 @@ def guess_response(content_type, data, ssl2=False):
if ssl2:
return "Handshake({0})".format(SSL2HandshakeType.toStr(data[0]))
else:
if data[0] == HandshakeType.server_hello and \
data[6:6+32] == TLS_1_3_HRR:
return "Handshake(server_hello, hello_retry_request)"
return "Handshake({0})".format(HandshakeType.toStr(data[0]))
elif content_type == ContentType.application_data:
return "ApplicationData(len={0})".format(len(data))
Expand Down

0 comments on commit 58b4205

Please sign in to comment.