Skip to content

Commit

Permalink
feat(tls)!: Readd minimal signature algorithms extension
Browse files Browse the repository at this point in the history
Some implementations alerts internal error if there is no signature
algorithms extension in the client hello message
  • Loading branch information
c0r0n3r committed Nov 13, 2021
1 parent 5e3fe90 commit 7589d7c
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions dheater/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import attr
import urllib3

from cryptoparser.common.algorithm import Authentication
from cryptoparser.common.exception import InvalidType, NotEnoughData

from cryptoparser.tls.algorithm import TlsSignatureAndHashAlgorithm
from cryptoparser.tls.ciphersuite import TlsCipherSuite
from cryptoparser.tls.extension import TlsExtensionType, TlsExtensionsClient
from cryptoparser.tls.record import TlsRecord
from cryptoparser.tls.subprotocol import TlsHandshakeType, TlsCipherSuiteVector
from cryptoparser.tls.subprotocol import TlsHandshakeType
from cryptoparser.tls.version import TlsProtocolVersionFinal, TlsVersion

from cryptoparser.ssh.record import SshRecordInit, SshRecordKexDH, SshRecordKexDHGroup
Expand All @@ -39,6 +40,7 @@
from cryptolyzer.tls.client import (
L7ClientTlsBase,
TlsHandshakeClientHelloKeyExchangeDHE,
TlsHandshakeClientHelloSpecalization,
)
import cryptolyzer.ssh.dhparams
import cryptolyzer.ssh.ciphers
Expand Down Expand Up @@ -279,13 +281,26 @@ def _get_client(self):

def _prepare_packets(self):
protocol_version = TlsProtocolVersionFinal(TlsVersion.TLS1_2)
client_hello = TlsHandshakeClientHelloKeyExchangeDHE(protocol_version, self.uri.host)
client_hello.cipher_suites = TlsCipherSuiteVector([self.pre_check_result.cipher_suite, ])
client_hello.extensions = TlsExtensionsClient([
extension
for extension in client_hello.extensions
if extension.extension_type != TlsExtensionType.SIGNATURE_ALGORITHMS
])
cipher_suite = self.pre_check_result.cipher_suite
if cipher_suite.value.authentication == Authentication.RSA:
signature_algorithms = [
TlsSignatureAndHashAlgorithm.RSA_SHA256,
TlsSignatureAndHashAlgorithm.RSA_SHA1,
]
elif cipher_suite.value.authentication == Authentication.ECDSA:
signature_algorithms = [
TlsSignatureAndHashAlgorithm.ECDSA_SHA256,
TlsSignatureAndHashAlgorithm.ECDSA_SHA1,
]

client_hello = TlsHandshakeClientHelloSpecalization(
hostname=self.uri.host,
protocol_versions=[protocol_version, ],
cipher_suites=[cipher_suite, ],
named_curves=[],
signature_algorithms=signature_algorithms,
extensions=[],
)
client_hello_bytes = TlsRecord(client_hello.compose()).compose()

return client_hello_bytes
Expand Down

0 comments on commit 7589d7c

Please sign in to comment.