Skip to content

Commit

Permalink
do not allow KEMs in TLS 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Oct 18, 2024
1 parent 0eb44e9 commit 256524b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tlslite/tlsconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ def _handshakeServerAsyncHelper(self, verifierDB,
dhGroups)
elif cipherSuite in CipherSuite.ecdheCertSuites or \
cipherSuite in CipherSuite.ecdheEcdsaSuites:
acceptedCurves = self._curveNamesToList(settings)
acceptedCurves = self._curveNamesToList(settings, version)
defaultCurve = getattr(GroupName, settings.defaultCurve)
keyExchange = ECDHE_RSAKeyExchange(cipherSuite,
clientHello,
Expand All @@ -2468,7 +2468,7 @@ def _handshakeServerAsyncHelper(self, verifierDB,
serverHello, settings.dhParams,
dhGroups)
else:
acceptedCurves = self._curveNamesToList(settings)
acceptedCurves = self._curveNamesToList(settings, version)
defaultCurve = getattr(GroupName, settings.defaultCurve)
keyExchange = AECDHKeyExchange(cipherSuite, clientHello,
serverHello, acceptedCurves,
Expand Down Expand Up @@ -3579,7 +3579,7 @@ def _serverGetClientHello(self, settings, private_key, cert_chain,
AlertDescription.decode_error,
"Received malformed supported_groups extension"):
yield result
serverGroups = self._curveNamesToList(settings)
serverGroups = self._curveNamesToList(settings, version)
ecGroupIntersect = getFirstMatching(clientGroups, serverGroups)
# RFC 7919 groups
serverGroups = self._groupNamesToList(settings)
Expand Down Expand Up @@ -4935,10 +4935,11 @@ def _sigHashesToList(settings, privateKey=None, certList=None,
return sigAlgs

@staticmethod
def _curveNamesToList(settings):
def _curveNamesToList(settings, version=(3, 4)):
"""Convert list of acceptable curves to array identifiers"""
ret = [getattr(GroupName, val) for val in settings.eccCurves]
if settings.maxVersion < (3, 4) and (3, 4) not in settings.versions:
if (settings.maxVersion < (3, 4) and (3, 4) not in settings.versions)\
or version < (3, 4):
# if we don't support TLS 1.3, filter out KEMs
ret = [i for i in ret if i not in GroupName.allKEM]
return ret
Expand Down

0 comments on commit 256524b

Please sign in to comment.