Skip to content

Commit 8fbeba2

Browse files
committed
require alg
1 parent 26aebeb commit 8fbeba2

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/JWK.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,11 @@ public static function parseKey(array $jwk, string $defaultAlg = null): ?Key
102102
throw new UnexpectedValueException('JWK must contain a "kty" parameter');
103103
}
104104

105-
$ktyNotRequiringAlg = [
106-
// In Octet Key Pair (OKP) keys, the signing algorithm (alg) will not be read from the
107-
// JWK, as it can be inferred directly from the curve type (crv).
108-
// @see https://datatracker.ietf.org/doc/html/rfc8037#section-3.1
109-
'OKP',
110-
];
111-
if (!isset($jwk['alg']) && !\in_array($jwk['kty'], $ktyNotRequiringAlg, true)) {
105+
if (!isset($jwk['alg'])) {
112106
if (\is_null($defaultAlg)) {
113107
// The "alg" parameter is optional in a KTY, but an algorithm is required
114-
// for parsing certain key types in this library. Use the $defaultAlg parameter
115-
// when parsing the key set in order to prevent this error.
108+
// for parsing in this library. Use the $defaultAlg parameter when parsing the
109+
// key set in order to prevent this error.
116110
// @see https://datatracker.ietf.org/doc/html/rfc7517#section-4.4
117111
throw new UnexpectedValueException('JWK must contain an "alg" parameter');
118112
}

0 commit comments

Comments
 (0)