Applied fixes from StyleCI
This commit is contained in:
parent
1ae804dfce
commit
edd5f81fec
12
mtproto.php
12
mtproto.php
@ -247,7 +247,7 @@ class Session
|
|||||||
$key = new \phpseclib\Crypt\RSA();
|
$key = new \phpseclib\Crypt\RSA();
|
||||||
$key->load($f);
|
$key->load($f);
|
||||||
$new_nonce = \phpseclib\Crypt\Random::string(32);
|
$new_nonce = \phpseclib\Crypt\Random::string(32);
|
||||||
$data = $this->tl->serialize_obj("p_q_inner_data", ['pq' => $pq_bytes, 'p' => $p_bytes, 'q' => $q_bytes, 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'new_nonce' => $new_nonce]);
|
$data = $this->tl->serialize_obj('p_q_inner_data', ['pq' => $pq_bytes, 'p' => $p_bytes, 'q' => $q_bytes, 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'new_nonce' => $new_nonce]);
|
||||||
$sha_digest = sha1($data, true);
|
$sha_digest = sha1($data, true);
|
||||||
$random_bytes = \phpseclib\Crypt\Random::string(((255 - strlen($data)) - strlen($sha_digest)));
|
$random_bytes = \phpseclib\Crypt\Random::string(((255 - strlen($data)) - strlen($sha_digest)));
|
||||||
$to_encrypt = $sha_digest.$data.$random_bytes;
|
$to_encrypt = $sha_digest.$data.$random_bytes;
|
||||||
@ -271,14 +271,14 @@ class Session
|
|||||||
$server_time = $server_DH_inner_data['server_time'];
|
$server_time = $server_DH_inner_data['server_time'];
|
||||||
$this->timedelta = ($server_time - time());
|
$this->timedelta = ($server_time - time());
|
||||||
pyjslib_printnl(sprintf('Server-client time delta = %.1f s', $this->timedelta));
|
pyjslib_printnl(sprintf('Server-client time delta = %.1f s', $this->timedelta));
|
||||||
$dh_prime = $this->struct->unpack(">Q", $dh_prime_str);
|
$dh_prime = $this->struct->unpack('>Q', $dh_prime_str);
|
||||||
$g_a = $this->struct->unpack(">Q", $g_a_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;
|
$retry_id = 0;
|
||||||
$b_str = \phpseclib\Crypt\Random::string(256);
|
$b_str = \phpseclib\Crypt\Random::string(256);
|
||||||
$b = $this->struct->unpack(">Q", $b_str);
|
$b = $this->struct->unpack('>Q', $b_str);
|
||||||
$g_b = pow($g, $b, $dh_prime);
|
$g_b = pow($g, $b, $dh_prime);
|
||||||
$g_b_str = $this->struct->pack(">Q", $g_b);
|
$g_b_str = $this->struct->pack('>Q', $g_b);
|
||||||
$data = serialize_obj(['client_DH_inner_data'], ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'retry_id' => $retry_id, 'g_b' => $g_b_str]);
|
$data = serialize_obj(['client_DH_inner_data'], ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'retry_id' => $retry_id, 'g_b' => $g_b_str]);
|
||||||
$data_with_sha = sha1($data, true).$data;
|
$data_with_sha = sha1($data, true).$data;
|
||||||
$data_with_sha_padded = $data_with_sha.\phpseclib\Crypt\Random::string(posmod(-strlen($data_with_sha), 16));
|
$data_with_sha_padded = $data_with_sha.\phpseclib\Crypt\Random::string(posmod(-strlen($data_with_sha), 16));
|
||||||
@ -286,7 +286,7 @@ class Session
|
|||||||
foreach (pyjslib_range(1, $this->AUTH_MAX_RETRY) as $i) {
|
foreach (pyjslib_range(1, $this->AUTH_MAX_RETRY) as $i) {
|
||||||
$Set_client_DH_params_answer = $this->method_call('set_client_DH_params', ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'encrypted_data' => $encrypted_data]);
|
$Set_client_DH_params_answer = $this->method_call('set_client_DH_params', ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'encrypted_data' => $encrypted_data]);
|
||||||
$auth_key = pow($g_a, $b, $dh_prime);
|
$auth_key = pow($g_a, $b, $dh_prime);
|
||||||
$auth_key_str = $this->struct->pack(">Q", $auth_key);
|
$auth_key_str = $this->struct->pack('>Q', $auth_key);
|
||||||
$auth_key_sha = sha1($auth_key_str, true);
|
$auth_key_sha = sha1($auth_key_str, true);
|
||||||
$auth_key_aux_hash = substr($auth_key_sha, 0, 8);
|
$auth_key_aux_hash = substr($auth_key_sha, 0, 8);
|
||||||
$new_nonce_hash1 = substr(sha1($new_nonce.''.$auth_key_aux_hash, true), -16);
|
$new_nonce_hash1 = substr(sha1($new_nonce.''.$auth_key_aux_hash, true), -16);
|
||||||
|
Loading…
Reference in New Issue
Block a user