sign($key, $input), $signature); } public function sign(JWK $key, string $input): string { $this->checkKey($key); return \hash_hmac($this->getHashAlgorithm(), $input, Base64Url::decode($key->get('k')), true); } protected function checkKey(JWK $key) { if (!\in_array($key->get('kty'), $this->allowedKeyTypes(), true)) { throw new \InvalidArgumentException('Wrong key type.'); } if (!$key->has('k')) { throw new \InvalidArgumentException('The key parameter "k" is missing.'); } } abstract protected function getHashAlgorithm(): string; }