public function bigBrother_handleAuthentication(BigBrother $plugin, $username, $onlineMode) { if ($this->bigBrother_status === 0) { $this->bigBrother_username = $username; if ($onlineMode === true) { $pk = new EncryptionRequestPacket(); $pk->serverID = ""; $pk->publicKey = $plugin->getASN1PublicKey(); $pk->verifyToken = $this->bigBrother_checkToken = Utils::getRandomBytes(4, false, true, $pk->publicKey); $this->putRawPacket($pk); } else { $task = new OnlineProfile($this->clientID, $this->bigBrother_username); $this->server->getScheduler()->scheduleAsyncTask($task); } } }
public function bigBrother_processAuthentication(BigBrother $plugin, EncryptionResponsePacket $packet) { $this->bigBrother_secret = $plugin->decryptBinary($packet->sharedSecret); $token = $plugin->decryptBinary($packet->verifyToken); $this->interface->enableEncryption($this, $this->bigBrother_secret); if ($token !== $this->bigBrother_checkToken) { $this->close("", "Invalid check token"); } else { $this->getAuthenticateOnline($this->bigBrother_username, Binary::sha1("" . $this->bigBrother_secret . $plugin->getASN1PublicKey())); } }