From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- .../web-token/jwt-signature-algorithm-rsa/RSA.php | 124 ++++++++++----------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'vendor/web-token/jwt-signature-algorithm-rsa/RSA.php') diff --git a/vendor/web-token/jwt-signature-algorithm-rsa/RSA.php b/vendor/web-token/jwt-signature-algorithm-rsa/RSA.php index 12a4445..337522d 100644 --- a/vendor/web-token/jwt-signature-algorithm-rsa/RSA.php +++ b/vendor/web-token/jwt-signature-algorithm-rsa/RSA.php @@ -1,62 +1,62 @@ -checkKey($key); - $pub = RSAKey::createFromJWK($key->toPublic()); - - return JoseRSA::verify($pub, $input, $signature, $this->getAlgorithm(), $this->getSignatureMethod()); - } - - public function sign(JWK $key, string $input): string - { - $this->checkKey($key); - if (!$key->has('d')) { - throw new \InvalidArgumentException('The key is not a private key.'); - } - - $priv = RSAKey::createFromJWK($key); - - return JoseRSA::sign($priv, $input, $this->getAlgorithm(), $this->getSignatureMethod()); - } - - private function checkKey(JWK $key) - { - if (!\in_array($key->get('kty'), $this->allowedKeyTypes(), true)) { - throw new \InvalidArgumentException('Wrong key type.'); - } - foreach (['n', 'e'] as $k) { - if (!$key->has($k)) { - throw new \InvalidArgumentException(\sprintf('The key parameter "%s" is missing.', $k)); - } - } - } -} +checkKey($key); + $pub = RSAKey::createFromJWK($key->toPublic()); + + return JoseRSA::verify($pub, $input, $signature, $this->getAlgorithm(), $this->getSignatureMethod()); + } + + public function sign(JWK $key, string $input): string + { + $this->checkKey($key); + if (!$key->has('d')) { + throw new \InvalidArgumentException('The key is not a private key.'); + } + + $priv = RSAKey::createFromJWK($key); + + return JoseRSA::sign($priv, $input, $this->getAlgorithm(), $this->getSignatureMethod()); + } + + private function checkKey(JWK $key) + { + if (!\in_array($key->get('kty'), $this->allowedKeyTypes(), true)) { + throw new \InvalidArgumentException('Wrong key type.'); + } + foreach (['n', 'e'] as $k) { + if (!$key->has($k)) { + throw new \InvalidArgumentException(\sprintf('The key parameter "%s" is missing.', $k)); + } + } + } +} -- cgit v1.2.3