File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,10 @@ class JWK
31
31
// 'P-521' => '1.3.132.0.35', // Len: 132 (not supported)
32
32
];
33
33
34
- // 'crv' identifier => JWT 'alg'
35
- private const OKP_CURVES = [
36
- 'Ed25519 ' => 'EdDSA ' ,
34
+ // For keys with "kty" equal to "OKP" (Octet Key Pair), the "crv" parameter must contain the key subtype.
35
+ // This library supports the following subtypes:
36
+ private const OKP_SUBTYPES = [
37
+ 'Ed25519 ' => true , // RFC 8037
37
38
];
38
39
39
40
/**
@@ -160,17 +161,17 @@ public static function parseKey(array $jwk, string $defaultAlg = null): ?Key
160
161
throw new UnexpectedValueException ('crv not set ' );
161
162
}
162
163
163
- if (! isset (self ::OKP_CURVES [$ jwk ['crv ' ]])) {
164
- throw new DomainException ('Unrecognised or unsupported OKP curve ' );
164
+ if (empty (self ::OKP_SUBTYPES [$ jwk ['crv ' ]])) {
165
+ throw new DomainException ('Unrecognised or unsupported OKP key subtype ' );
165
166
}
166
167
167
168
if (empty ($ jwk ['x ' ])) {
168
169
throw new UnexpectedValueException ('x not set ' );
169
170
}
170
171
172
+ // This library works internally with EdDSA keys (Ed25519) encoded in standard base64.
171
173
$ publicKey = JWT ::convertBase64urlToBase64 ($ jwk ['x ' ]);
172
- $ alg = self ::OKP_CURVES [$ jwk ['crv ' ]];
173
- return new Key ($ publicKey , $ alg );
174
+ return new Key ($ publicKey , $ jwk ['alg ' ]);
174
175
default :
175
176
break ;
176
177
}
You can’t perform that action at this time.
0 commit comments