-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add signature_algorithms_cert extension to _serverTLS13Handshake #513
Open
Odinmylord
wants to merge
4
commits into
tlsfuzzer:master
Choose a base branch
from
Odinmylord:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2830,9 +2830,15 @@ def _serverTLS13Handshake(self, settings, clientHello, cipherSuite, | |
cr_settings.dsaSigHashes = [] | ||
valid_sig_algs = self._sigHashesToList(cr_settings) | ||
assert valid_sig_algs | ||
|
||
valid_sig_algs_cert = self._sigHashesToList(cr_settings, | ||
sig_algs_cert=True) | ||
certificate_request = CertificateRequest(self.version) | ||
certificate_request.create(context=ctx, sig_algs=valid_sig_algs) | ||
# if there is no difference the extension can be omitted | ||
if set(valid_sig_algs_cert) != set(valid_sig_algs): | ||
sig_algs_cert_ext = SignatureAlgorithmsCertExtension() | ||
sig_algs_cert_ext.create(valid_sig_algs_cert) | ||
certificate_request.addExtension(sig_algs_cert_ext) | ||
self._queue_message(certificate_request) | ||
|
||
certificate = Certificate(CertificateType.x509, self.version) | ||
|
@@ -4668,7 +4674,7 @@ def _pickServerKeyExchangeSig(settings, clientHello, certList=None, | |
|
||
@staticmethod | ||
def _sigHashesToList(settings, privateKey=None, certList=None, | ||
version=(3, 3)): | ||
version=(3, 3), sig_algs_cert=False): | ||
"""Convert list of valid signature hashes to array of tuples""" | ||
certType = None | ||
publicKey = None | ||
|
@@ -4679,7 +4685,9 @@ def _sigHashesToList(settings, privateKey=None, certList=None, | |
sigAlgs = [] | ||
|
||
if not certType or certType == "Ed25519" or certType == "Ed448": | ||
for sig_scheme in settings.more_sig_schemes: | ||
sig_schemes = settings.more_sig_schemes if not sig_algs_cert else \ | ||
settings.more_sig_schemes_cert | ||
for sig_scheme in sig_schemes: | ||
if version < (3, 3): | ||
# EdDSA is supported only in TLS 1.2 and 1.3 | ||
continue | ||
|
@@ -4688,60 +4696,65 @@ def _sigHashesToList(settings, privateKey=None, certList=None, | |
sigAlgs.append(getattr(SignatureScheme, sig_scheme.lower())) | ||
|
||
if not certType or certType == "ecdsa": | ||
for hashName in settings.ecdsaSigHashes: | ||
hash_names = settings.ecdsaSigHashes if not sig_algs_cert else \ | ||
settings.ecdsa_sig_hashes_cert | ||
for hash_name in hash_names: | ||
# only SHA256, SHA384 and SHA512 are allowed in TLS 1.3 | ||
if version > (3, 3) and hashName in ("sha1", "sha224"): | ||
if version > (3, 3) and hash_name in ("sha1", "sha224"): | ||
continue | ||
|
||
# in TLS 1.3 ECDSA key curve is bound to hash | ||
if publicKey and version > (3, 3): | ||
curve = publicKey.curve_name | ||
matching_hash = TLSConnection._curve_name_to_hash_name( | ||
curve) | ||
if hashName != matching_hash: | ||
if hash_name != matching_hash: | ||
continue | ||
|
||
sigAlgs.append((getattr(HashAlgorithm, hashName), | ||
sigAlgs.append((getattr(HashAlgorithm, hash_name), | ||
SignatureAlgorithm.ecdsa)) | ||
|
||
if not certType or certType == "dsa": | ||
for hashName in settings.dsaSigHashes: | ||
for hash_name in settings.dsaSigHashes: | ||
if version > (3, 3): | ||
continue | ||
|
||
sigAlgs.append((getattr(HashAlgorithm, hashName), | ||
sigAlgs.append((getattr(HashAlgorithm, hash_name), | ||
SignatureAlgorithm.dsa)) | ||
|
||
if not certType or certType in ("rsa", "rsa-pss"): | ||
for schemeName in settings.rsaSchemes: | ||
rsa_schemes = settings.rsaSchemes if not sig_algs_cert else \ | ||
settings.rsa_sig_schemes_cert | ||
for scheme_name in rsa_schemes: | ||
# pkcs#1 v1.5 signatures are not allowed in TLS 1.3 | ||
if version > (3, 3) and schemeName == "pkcs1": | ||
if version > (3, 3) and scheme_name == "pkcs1": | ||
continue | ||
|
||
for hashName in settings.rsaSigHashes: | ||
rsa_sig_hashes = settings.rsaSigHashes if not sig_algs_cert else \ | ||
settings.rsa_sig_hashes_cert | ||
for hash_name in rsa_sig_hashes: | ||
# rsa-pss certificates can't be used to make PKCS#1 v1.5 | ||
# signatures | ||
if certType == "rsa-pss" and schemeName == "pkcs1": | ||
if certType == "rsa-pss" and scheme_name == "pkcs1": | ||
continue | ||
try: | ||
# 1024 bit keys are too small to create valid | ||
# rsa-pss-SHA512 signatures | ||
if schemeName == 'pss' and hashName == 'sha512'\ | ||
if scheme_name == 'pss' and hash_name == 'sha512'\ | ||
and privateKey and privateKey.n < 2**2047: | ||
continue | ||
# advertise support for both rsaEncryption and RSA-PSS OID | ||
# key type | ||
if certType != 'rsa-pss': | ||
sigAlgs.append(getattr(SignatureScheme, | ||
"rsa_{0}_rsae_{1}" | ||
.format(schemeName, hashName))) | ||
.format(scheme_name, hash_name))) | ||
if certType != 'rsa': | ||
sigAlgs.append(getattr(SignatureScheme, | ||
"rsa_{0}_pss_{1}" | ||
.format(schemeName, hashName))) | ||
.format(scheme_name, hash_name))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line too long (84 > 79 characters) |
||
except AttributeError: | ||
if schemeName == 'pkcs1': | ||
sigAlgs.append((getattr(HashAlgorithm, hashName), | ||
if scheme_name == 'pkcs1': | ||
sigAlgs.append((getattr(HashAlgorithm, hash_name), | ||
SignatureAlgorithm.rsa)) | ||
continue | ||
return sigAlgs | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line too long (84 > 79 characters)