mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Use OpenSSL for ECDH during client login, drop mdanter/ecc (#4328)
This brings a significant performance improvement to login sequence handling, reducing CPU cost of `PrepareEncryptionTask` by over 90% and `ProcessLoginTask` by over 60%. It also allows us to shed a dependency.
This commit is contained in:
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use Mdanter\Ecc\Crypto\Key\PublicKeyInterface;
|
||||
use pocketmine\entity\InvalidSkinException;
|
||||
use pocketmine\event\player\PlayerPreLoginEvent;
|
||||
use pocketmine\lang\KnownTranslationKeys;
|
||||
@ -63,13 +62,13 @@ class LoginPacketHandler extends PacketHandler{
|
||||
private $playerInfoConsumer;
|
||||
/**
|
||||
* @var \Closure
|
||||
* @phpstan-var \Closure(bool, bool, ?string, ?PublicKeyInterface) : void
|
||||
* @phpstan-var \Closure(bool, bool, ?string, ?string) : void
|
||||
*/
|
||||
private $authCallback;
|
||||
|
||||
/**
|
||||
* @phpstan-param \Closure(PlayerInfo) : void $playerInfoConsumer
|
||||
* @phpstan-param \Closure(bool $isAuthenticated, bool $authRequired, ?string $error, ?PublicKeyInterface $clientPubKey) : void $authCallback
|
||||
* @phpstan-param \Closure(bool $isAuthenticated, bool $authRequired, ?string $error, ?string $clientPubKey) : void $authCallback
|
||||
*/
|
||||
public function __construct(Server $server, NetworkSession $session, \Closure $playerInfoConsumer, \Closure $authCallback){
|
||||
$this->session = $session;
|
||||
@ -78,10 +77,6 @@ class LoginPacketHandler extends PacketHandler{
|
||||
$this->authCallback = $authCallback;
|
||||
}
|
||||
|
||||
private static function dummy() : void{
|
||||
echo PublicKeyInterface::class; //this prevents the import getting removed by tools that don't understand phpstan
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
if(!$this->isCompatibleProtocol($packet->protocol)){
|
||||
$this->session->sendDataPacket(PlayStatusPacket::create($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL ? PlayStatusPacket::LOGIN_FAILED_CLIENT : PlayStatusPacket::LOGIN_FAILED_SERVER), true);
|
||||
|
Reference in New Issue
Block a user