Skip to content

Commit 6db74d6

Browse files
author
Ivan Nikolchev
committed
enable client side checks for downgrade protection
1 parent cfdfb7c commit 6db74d6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tlslite/tlsconnection.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,26 @@ def _handshakeClientAsyncHelper(self, srpParams, certParams, anonParams,
520520
serverHello = result
521521
cipherSuite = serverHello.cipher_suite
522522

523+
# Check the serverHello.random if it includes the downgrade protection
524+
# values as described in RFC8446 section 4.1.3
525+
526+
# For TLS1.3
527+
if (settings.maxVersion > (3, 3) and self.version <= (3, 3)) and \
528+
(serverHello.random[-8:] == TLS_1_2_DOWNGRADE_SENTINEL or
529+
serverHello.random[-8:] == TLS_1_1_DOWNGRADE_SENTINEL):
530+
for result in self._sendError(AlertDescription.illegal_parameter,
531+
"Connection terminated because "
532+
"of downgrade protection."):
533+
yield result
534+
535+
# For TLS1.2
536+
if settings.maxVersion == (3, 3) and self.version < (3, 3) and \
537+
serverHello.random[-8:] == TLS_1_1_DOWNGRADE_SENTINEL:
538+
for result in self._sendError(AlertDescription.illegal_parameter,
539+
"Connection terminated because "
540+
"of downgrade protection."):
541+
yield result
542+
523543
# if we're doing tls1.3, use the new code as the negotiation is much
524544
# different
525545
ext = serverHello.getExtension(ExtensionType.supported_versions)

0 commit comments

Comments
 (0)