|
@@ -14,7 +14,7 @@ from types import SimpleNamespace
|
|
from nacl.public import PrivateKey
|
|
from nacl.public import PrivateKey
|
|
from nacl.bindings import crypto_scalarmult
|
|
from nacl.bindings import crypto_scalarmult
|
|
import hashlib
|
|
import hashlib
|
|
-from tls.Crypto.PublicKey import RSA
|
|
|
|
|
|
+from Crypto.PublicKey import RSA
|
|
|
|
|
|
# from Cryptography import x509
|
|
# from Cryptography import x509
|
|
# from OpenSSL.crypto import load_certificate, FILETYPE_ASN1
|
|
# from OpenSSL.crypto import load_certificate, FILETYPE_ASN1
|
|
@@ -575,7 +575,7 @@ class TLSClientSession:
|
|
self.client = None
|
|
self.client = None
|
|
self.server = None
|
|
self.server = None
|
|
self.session_tickets = []
|
|
self.session_tickets = []
|
|
- gBackPrint("tls"," started")
|
|
|
|
|
|
+ gBackPrint("tls", " started")
|
|
|
|
|
|
def unpack_server_hello(self, mv: memoryview):
|
|
def unpack_server_hello(self, mv: memoryview):
|
|
assert mv[:2] == b"\x03\x03", "version must be 0x0303"
|
|
assert mv[:2] == b"\x03\x03", "version must be 0x0303"
|
|
@@ -662,7 +662,6 @@ class TLSClientSession:
|
|
raise Exception(f"unknown handshake type {handshake_type}")
|
|
raise Exception(f"unknown handshake type {handshake_type}")
|
|
mv = mv[4+length:]
|
|
mv = mv[4+length:]
|
|
|
|
|
|
-
|
|
|
|
def tls_response(self, mv: memoryview):
|
|
def tls_response(self, mv: memoryview):
|
|
head = memoryview(mv[:5])
|
|
head = memoryview(mv[:5])
|
|
assert head[1:
|
|
assert head[1:
|
|
@@ -705,7 +704,7 @@ class TLSClientSession:
|
|
b'' + bytes.fromhex(self.handshake_context.decode())
|
|
b'' + bytes.fromhex(self.handshake_context.decode())
|
|
)
|
|
)
|
|
simplePrint("s_hand_traf_s",
|
|
simplePrint("s_hand_traf_s",
|
|
- secret.hex())
|
|
|
|
|
|
+ secret.hex())
|
|
|
|
|
|
self.peer_cipher = TLSCipher(secret)
|
|
self.peer_cipher = TLSCipher(secret)
|
|
simplePrint("peer_cipher", self.peer_cipher)
|
|
simplePrint("peer_cipher", self.peer_cipher)
|
|
@@ -717,11 +716,11 @@ class TLSClientSession:
|
|
)
|
|
)
|
|
self.client_handshake_traffic_secret = client_handshake_traffic_secret
|
|
self.client_handshake_traffic_secret = client_handshake_traffic_secret
|
|
simplePrint("c_hand_traf_s",
|
|
simplePrint("c_hand_traf_s",
|
|
- client_handshake_traffic_secret.hex())
|
|
|
|
|
|
+ client_handshake_traffic_secret.hex())
|
|
|
|
|
|
elif head[0] == ContentType.application_data:
|
|
elif head[0] == ContentType.application_data:
|
|
plaintext = self.peer_cipher.decrypt(content, head).rstrip(b"\x00")
|
|
plaintext = self.peer_cipher.decrypt(content, head).rstrip(b"\x00")
|
|
- simplePrint("plaintext", plaintext.hex(), type(plaintext))
|
|
|
|
|
|
+ simplePrint("plaintext", (plaintext.hex(), type(plaintext)))
|
|
|
|
|
|
content_type = ContentType.from_value(plaintext[-1])
|
|
content_type = ContentType.from_value(plaintext[-1])
|
|
simplePrint(" content_type", content_type)
|
|
simplePrint(" content_type", content_type)
|
|
@@ -737,7 +736,8 @@ class TLSClientSession:
|
|
client_finished_data = HandshakeType.finished.pack_data(
|
|
client_finished_data = HandshakeType.finished.pack_data(
|
|
client_finished
|
|
client_finished
|
|
)
|
|
)
|
|
- simplePrint("client_finished_data", client_finished_data.hex())
|
|
|
|
|
|
+ simplePrint("client_finished_data",
|
|
|
|
+ client_finished_data.hex())
|
|
|
|
|
|
inner_plaintext = client_finished_data + b'\x16'
|
|
inner_plaintext = client_finished_data + b'\x16'
|
|
simplePrint("inner_plaintext", inner_plaintext.hex())
|
|
simplePrint("inner_plaintext", inner_plaintext.hex())
|
|
@@ -818,4 +818,3 @@ class TLSClientSession:
|
|
|
|
|
|
def pack_canceled(self) -> bytes:
|
|
def pack_canceled(self) -> bytes:
|
|
return self.pack_warning(AlertDescription.user_canceled)
|
|
return self.pack_warning(AlertDescription.user_canceled)
|
|
-
|
|
|