diff --git a/mtproto.php b/mtproto.php index ddfa1198..a1385074 100755 --- a/mtproto.php +++ b/mtproto.php @@ -187,6 +187,7 @@ class Session } $x = $this->struct->unpack('struct->unpack('<8sI', substr($packet, 12, 12)); $data = substr($packet, 24, (24 + $message_length) - 24); @@ -210,6 +211,7 @@ class Session public function method_call($method, $kwargs) { + //var_dump($kwargs); foreach (range(1, $this->MAX_RETRY) as $i) { try { $this->send_message($this->tl->serialize_method($method, $kwargs)); @@ -230,6 +232,7 @@ class Session $ResPQ = $this->method_call('req_pq', ['nonce' => $nonce]); $server_nonce = $ResPQ['server_nonce']; $public_key_fingerprint = $ResPQ['server_public_key_fingerprints'][0]; + var_dump($public_key_fingerprint); $pq_bytes = $ResPQ['pq']; $pq = new \phpseclib\Math\BigInteger($pq_bytes, 256); @@ -273,7 +276,7 @@ class Session pyjslib_printnl(sprintf('Server-client time delta = %.1f s', $this->timedelta)); $dh_prime = $this->struct->unpack('>Q', $dh_prime_str); $g_a = $this->struct->unpack('>Q', $g_a_str); - assert($this->PrimeModule->isPrime($dh_prime)); + assert($this->PrimeModule->isprime($dh_prime)); $retry_id = 0; $b_str = \phpseclib\Crypt\Random::string(256); $b = $this->struct->unpack('>Q', $b_str); diff --git a/mtproto.py b/mtproto.py index 00043b83..fe97fd28 100644 --- a/mtproto.py +++ b/mtproto.py @@ -6,6 +6,7 @@ Created on Tue Sep 2 19:26:15 2014 @author: Sammy Pfeiffer """ from binascii import crc32 as originalcrc32 +from binascii import hexlify from time import time import io import os.path @@ -125,6 +126,7 @@ class Session: return data def method_call(self, method, **kwargs): + #print(kwargs) for i in range(1, self.MAX_RETRY): try: self.send_message(TL.serialize_method(method, **kwargs)) @@ -169,7 +171,6 @@ class Session: random_bytes = os.urandom(255-len(data)-len(sha_digest)) to_encrypt = sha_digest + data + random_bytes encrypted_data = key.encrypt(to_encrypt, 0)[0] - print("Starting Diffie Hellman key exchange") server_dh_params = self.method_call('req_DH_params', nonce=nonce,