Skip to content

Commit

Permalink
chore!: Follow changes in CryproLyzer up to its version 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
c0r0n3r committed Dec 27, 2023
1 parent cf5f7ad commit 79bbd8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions dheater/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

from cryptodatahub.common.algorithm import Authentication
from cryptodatahub.common.parameter import DHParamWellKnown
from cryptodatahub.tls.algorithm import TlsCipherSuite, TlsNamedCurve, TlsSignatureAndHashAlgorithm

from cryptoparser.common.exception import InvalidType, NotEnoughData

from cryptoparser.tls.algorithm import TlsSignatureAndHashAlgorithm
from cryptoparser.tls.ciphersuite import TlsCipherSuite
from cryptoparser.tls.extension import TlsNamedCurve, TlsExtensionEllipticCurves
from cryptoparser.tls.extension import (
TlsExtensionsClient,
TlsExtensionKeyShareClient,
TlsExtensionKeyShareReservedClient,
TlsExtensionType,
)
from cryptoparser.tls.record import TlsRecord
from cryptoparser.tls.subprotocol import TlsHandshakeType
from cryptoparser.tls.version import TlsProtocolVersion, TlsVersion
Expand All @@ -49,6 +53,7 @@
L7ClientTlsBase,
TlsHandshakeClientHelloKeyExchangeDHE,
TlsHandshakeClientHelloSpecalization,
key_share_entry_from_named_curve,
)
from cryptolyzer.tls.exception import TlsAlert
import cryptolyzer.tls.dhparams
Expand Down Expand Up @@ -457,16 +462,24 @@ def _prepare_packets(self):

client_hello_class = TlsHandshakeClientHelloSpecalization
if protocol_version > TlsProtocolVersion(TlsVersion.TLS1_2):
signature_algorithms = None
extensions = client_hello_class._get_tls1_3_extensions( # pylint: disable=protected-access
[protocol_version, ], [self.pre_check_result.dh_public_key, ], signature_algorithms
)
extensions.append(TlsExtensionEllipticCurves([self.pre_check_result.dh_public_key, ]))
client_hello = TlsHandshakeClientHelloKeyExchangeDHE(
protocol_version=protocol_version,
hostname=self.uri.host,
named_curves=[self.pre_check_result.dh_public_key, ]
)

extensions = [
extension
for extension in client_hello.extensions
if extension.extension_type not in (TlsExtensionType.KEY_SHARE, TlsExtensionType.KEY_SHARE_RESERVED)
]

key_share_entry = key_share_entry_from_named_curve(self.pre_check_result.dh_public_key)

client_hello.extensions = TlsExtensionsClient(extensions + [
TlsExtensionKeyShareClient([key_share_entry]),
TlsExtensionKeyShareReservedClient([key_share_entry]),
])
else:
client_hello = client_hello_class(
protocol_versions=[protocol_version, ],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
attrs>=19.2.0
cryptolyzer>=0.11.0
cryptolyzer==0.12.1
urllib3

0 comments on commit 79bbd8a

Please sign in to comment.