mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 09:58:59 +01:00
Finally fixed req_DH_params method
This commit is contained in:
parent
127a698265
commit
e284fb8ef6
10
composer.lock
generated
10
composer.lock
generated
@ -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",
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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('<q', $value);
|
||||
break;
|
||||
case 'int128':
|
||||
@ -167,10 +166,16 @@ class TL
|
||||
if ($l == 254) {
|
||||
$long_len = \danog\PHP\Struct::unpack('<I', fread($bytes_io, 3).\danog\MadelineProto\Tools::string2bin('\x00')) [0];
|
||||
$x = fread($bytes_io, $long_len);
|
||||
fread($bytes_io, \danog\MadelineProto\Tools::posmod(-$long_len, 4));
|
||||
$resto = \danog\MadelineProto\Tools::posmod(-$long_len, 4);
|
||||
if ($resto > 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");
|
||||
|
Loading…
Reference in New Issue
Block a user