Skip to content

Commit

Permalink
Merge pull request #801 from tlsfuzzer/fips-certificate-verify
Browse files Browse the repository at this point in the history
certificate-verify: allow setting the cipher to use
  • Loading branch information
tomato42 committed Sep 5, 2022
2 parents ad0ec24 + e514a41 commit 75bb4ad
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions scripts/test-certificate-verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from tlsfuzzer.helpers import RSA_SIG_ALL


version = 9
version = 10


def help_msg():
Expand All @@ -53,6 +53,8 @@ def help_msg():
print(" -k file.pem file with private key for client")
print(" -c file.pem file with certificate for client")
print(" -d negotiate (EC)DHE instead of RSA key exchange")
print(" -C ciph Use specified ciphersuite. Either numerical value or")
print(" IETF name.")
print(" --help this message")


Expand All @@ -67,9 +69,10 @@ def main():
private_key = None
cert = None
dhe = False
ciphers = None

argv = sys.argv[1:]
opts, args = getopt.getopt(argv, "h:p:e:x:X:n:k:c:d", ["help"])
opts, args = getopt.getopt(argv, "h:p:e:x:X:n:k:c:dC:", ["help"])
for opt, arg in opts:
if opt == '-h':
host = arg
Expand All @@ -88,6 +91,14 @@ def main():
num_limit = int(arg)
elif opt == '-d':
dhe = True
elif opt == '-C':
if arg[:2] == '0x':
ciphers = [int(arg, 16)]
else:
try:
ciphers = [getattr(CipherSuite, arg)]
except AttributeError:
ciphers = [int(arg)]
elif opt == '--help':
help_msg()
sys.exit(0)
Expand Down Expand Up @@ -115,6 +126,21 @@ def main():
else:
run_only = None

if ciphers:
if not dhe:
# by default send minimal set of extensions, but allow user
# to override it
dhe = ciphers[0] in CipherSuite.ecdhAllSuites or \
ciphers[0] in CipherSuite.dhAllSuites
else:
if dhe:
ciphers = [CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA]
else:
ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA]
ciphers.append(CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV)

conversations = {}

# sanity check for Client Certificates
Expand All @@ -132,12 +158,6 @@ def main():
GroupName.ffdhe2048]
ext[ExtensionType.supported_groups] = SupportedGroupsExtension()\
.create(groups)
ciphers = [CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
else:
ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
node = node.add_child(ClientHelloGenerator(ciphers, extensions=ext))
node = node.add_child(ExpectServerHello(version=(3, 3)))
node = node.add_child(ExpectCertificate())
Expand Down Expand Up @@ -176,12 +196,6 @@ def main():
GroupName.ffdhe2048]
ext[ExtensionType.supported_groups] = SupportedGroupsExtension()\
.create(groups)
ciphers = [CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
else:
ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
node = node.add_child(ClientHelloGenerator(ciphers, extensions=ext))
node = node.add_child(ExpectServerHello(version=(3, 3)))
node = node.add_child(ExpectCertificate())
Expand Down Expand Up @@ -226,12 +240,6 @@ def main():
GroupName.ffdhe2048]
ext[ExtensionType.supported_groups] = SupportedGroupsExtension()\
.create(groups)
ciphers = [CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
else:
ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
node = node.add_child(ClientHelloGenerator(ciphers, extensions=ext))
node = node.add_child(ExpectServerHello(version=(3, 3)))
node = node.add_child(ExpectCertificate())
Expand Down Expand Up @@ -273,12 +281,6 @@ def main():
GroupName.ffdhe2048]
ext[ExtensionType.supported_groups] = SupportedGroupsExtension()\
.create(groups)
ciphers = [CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
else:
ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
node = node.add_child(ClientHelloGenerator(ciphers, extensions=ext))
node = node.add_child(ExpectServerHello(version=(3, 3)))
node = node.add_child(ExpectCertificate())
Expand Down

0 comments on commit 75bb4ad

Please sign in to comment.