generator384()->createPrivateKey(); } $this->serverPrivateKey = self::$SERVER_PRIVATE_KEY; $this->clientPub = $clientPub; $this->storeLocal(self::TLS_KEY_ON_COMPLETION, $onCompletion); $this->onCompletion = $onCompletion; } public function onRun() : void{ $serverPriv = $this->serverPrivateKey; $sharedSecret = EncryptionUtils::generateSharedSecret($serverPriv, $this->clientPub); $salt = random_bytes(16); $this->aesKey = EncryptionUtils::generateKey($sharedSecret, $salt); $this->handshakeJwt = EncryptionUtils::generateServerHandshakeJwt($serverPriv, $salt); } public function onCompletion() : void{ /** * @var \Closure $callback * @phpstan-var \Closure(string $encryptionKey, string $handshakeJwt) : void $callback */ $callback = $this->fetchLocal(self::TLS_KEY_ON_COMPLETION); $callback($this->aesKey, $this->handshakeJwt); } }