diff --git a/composer.lock b/composer.lock index da993134..79f7f6ad 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages": [ { "name": "danog/phpstruct", - "version": "1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/danog/PHPStruct.git", - "reference": "ac1d7a0b1eb54d5b10dca553be816c8fb0881e47" + "reference": "635b6a57a903b976c56c1283d00ee26b8a1b175d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/danog/PHPStruct/zipball/ac1d7a0b1eb54d5b10dca553be816c8fb0881e47", - "reference": "ac1d7a0b1eb54d5b10dca553be816c8fb0881e47", + "url": "https://api.github.com/repos/danog/PHPStruct/zipball/635b6a57a903b976c56c1283d00ee26b8a1b175d", + "reference": "635b6a57a903b976c56c1283d00ee26b8a1b175d", "shasum": "" }, "require": { @@ -53,7 +53,7 @@ "struct", "unpack" ], - "time": "2016-07-29 15:13:54" + "time": "2016-08-14 17:51:55" }, { "name": "paragonie/constant_time_encoding", diff --git a/src/danog/MadelineProto/RSA.php b/src/danog/MadelineProto/RSA.php index 6cc69029..4996c9fa 100644 --- a/src/danog/MadelineProto/RSA.php +++ b/src/danog/MadelineProto/RSA.php @@ -18,7 +18,7 @@ class RSA extends TL\TL public $n; // phpseclib\Math\BigInteger class public $e; // phpseclib\Math\BigInteger class public $fp; // phpseclib\Math\BigInteger class - public $fp_float; // float + public $fp_bytes; // bytes public function __construct($key) { @@ -27,8 +27,8 @@ class RSA extends TL\TL $this->n = $this->key->modulus; $this->e = $this->key->exponent; - $this->fp = new \phpseclib\Math\BigInteger(strrev(substr(sha1($this->serialize_param('bytes', $this->n->toBytes()).$this->serialize_param('bytes', $this->e->toBytes()), true), -8)), -256); - $this->fp_float = (float) $this->fp->toString(); + $this->fp_bytes = substr(sha1($this->serialize_param('bytes', $this->n->toBytes()).$this->serialize_param('bytes', $this->e->toBytes()), true), -8); + $this->fp = new \phpseclib\Math\BigInteger(strrev($this->fp_bytes), -256); } public function encrypt($data) diff --git a/src/danog/MadelineProto/Session.php b/src/danog/MadelineProto/Session.php index 22a80253..af64736a 100644 --- a/src/danog/MadelineProto/Session.php +++ b/src/danog/MadelineProto/Session.php @@ -245,7 +245,8 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB throw new Exception('Handshake: wrong nonce'); } foreach ($ResPQ['server_public_key_fingerprints'] as $curfp) { - if ($curfp === $this->key->fp_float) { + $curfp_biginteger = new \phpseclib\Math\BigInteger($curfp); + if ($this->key->fp->equals($curfp_biginteger)) { $public_key_fingerprint = $curfp; break; } @@ -284,7 +285,6 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB // req_DH_params $this->log->log('Starting Diffie Hellman key exchange'); - $server_dh_params = $this->method_call('req_DH_params', [ 'nonce' => $nonce, diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index afc870ca..3025c505 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -98,7 +98,6 @@ class TL if (!is_numeric($value)) { throw new Exception("serialize_param: given value isn't numeric"); } - return \danog\PHP\Struct::pack(' 0) { + fread($bytes_io, $resto); + } } else { $x = fread($bytes_io, $l); - fread($bytes_io, \danog\MadelineProto\Tools::posmod(-($l + 1), 4)); + $resto = \danog\MadelineProto\Tools::posmod(-($l + 1), 4); + if ($resto > 0) { + fread($bytes_io, $resto); + } } if (!is_string($x)) { throw new Exception("deserialize: generated value isn't a string");