From 1b88769aef48415a2a55b61d3500965cbf2ed8e5 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 12 May 2019 13:51:16 +0200 Subject: [PATCH] Async RSA (hehe) --- src/danog/MadelineProto/MTProto.php | 2 +- src/danog/MadelineProto/RSA.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index ec8b9ad0..41bf843a 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -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; } /* diff --git a/src/danog/MadelineProto/RSA.php b/src/danog/MadelineProto/RSA.php index 6eeb6ccb..36d088f1 100644 --- a/src/danog/MadelineProto/RSA.php +++ b/src/danog/MadelineProto/RSA.php @@ -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()