Async RSA (hehe)

This commit is contained in:
Daniil Gentili 2019-05-12 13:51:16 +02:00
parent 5ec4195173
commit 1b88769aef
2 changed files with 4 additions and 4 deletions

View File

@ -190,7 +190,7 @@ class MTProto implements TLCallback
// Load rsa keys
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['load_rsa'], Logger::ULTRA_VERBOSE);
foreach ($this->settings['authorization']['rsa_keys'] as $key) {
$key = new RSA($key);
$key = yield (new RSA())->load($key);
$this->rsa_keys[$key->fp] = $key;
}
/*

View File

@ -27,7 +27,7 @@ class RSA
public $n;
public $fp;
public function __magic_construct_async($rsa_key)
public function load($rsa_key)
{
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['rsa_init'], Logger::ULTRA_VERBOSE);
$key = new \phpseclib\Crypt\RSA();
@ -36,9 +36,9 @@ class RSA
$this->n = \phpseclib\Common\Functions\Objects::getVar($key, 'modulus');
$this->e = \phpseclib\Common\Functions\Objects::getVar($key, 'exponent');
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['computing_fingerprint'], Logger::ULTRA_VERBOSE);
$this->fp = substr(sha1(yield $this->serialize_object_async(['type' => 'bytes'], $this->n->toBytes(), 'key').yield $this->serialize_object_async(['type' => 'bytes'], $this->e->toBytes(), 'key'), true), -8);
$this->fp = substr(sha1((yield $this->serialize_object_async(['type' => 'bytes'], $this->n->toBytes(), 'key')).(yield $this->serialize_object_async(['type' => 'bytes'], $this->e->toBytes(), 'key')), true), -8);
return true;
return $this;
}
public function __sleep()