@@ -53,9 +53,10 @@ class JWT
53
53
* @var array<string, string[]>
54
54
*/
55
55
public static $ supported_algs = [
56
- 'ES384 ' => ['openssl ' , 'SHA384 ' ],
57
56
'ES256 ' => ['openssl ' , 'SHA256 ' ],
58
57
'ES256K ' => ['openssl ' , 'SHA256 ' ],
58
+ 'ES384 ' => ['openssl ' , 'SHA384 ' ],
59
+ 'ES512 ' => ['openssl ' , 'SHA512 ' ],
59
60
'HS256 ' => ['hash_hmac ' , 'SHA256 ' ],
60
61
'HS384 ' => ['hash_hmac ' , 'SHA384 ' ],
61
62
'HS512 ' => ['hash_hmac ' , 'SHA512 ' ],
@@ -75,7 +76,7 @@ class JWT
75
76
* the public key.
76
77
* Each Key object contains an algorithm and
77
78
* matching key.
78
- * Supported algorithms are 'ES384','ES256 ',
79
+ * Supported algorithms are 'ES256', 'ES256K', ' ES384', 'ES512 ',
79
80
* 'HS256', 'HS384', 'HS512', 'RS256', 'RS384'
80
81
* and 'RS512'.
81
82
* @param stdClass $headers Optional. Populates stdClass with headers.
@@ -142,8 +143,8 @@ public static function decode(
142
143
// See issue #351
143
144
throw new UnexpectedValueException ('Incorrect key for this algorithm ' );
144
145
}
145
- if (\in_array ($ header ->alg , ['ES256 ' , 'ES256K ' , 'ES384 ' ], true )) {
146
- // OpenSSL expects an ASN.1 DER sequence for ES256/ES256K/ES384 signatures
146
+ if (\in_array ($ header ->alg , ['ES256 ' , 'ES256K ' , 'ES384 ' , ' ES512 ' ], true )) {
147
+ // OpenSSL expects an ASN.1 DER sequence for ES256/ES256K/ES384/ES512 signatures
147
148
$ sig = self ::signatureToDER ($ sig );
148
149
}
149
150
if (!self ::verify ("{$ headb64 }. {$ bodyb64 }" , $ sig , $ key ->getKeyMaterial (), $ header ->alg )) {
@@ -186,8 +187,8 @@ public static function decode(
186
187
*
187
188
* @param array<mixed> $payload PHP array
188
189
* @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $key The secret key.
189
- * @param string $alg Supported algorithms are 'ES384','ES256 ', 'ES256K ', 'HS256 ',
190
- * 'HS384', 'HS512', 'RS256', 'RS384', and 'RS512'
190
+ * @param string $alg Supported algorithms are 'ES256', 'ES256K ', 'ES384 ', 'ES512 ',
191
+ * 'HS256', ' HS384', 'HS512', 'RS256', 'RS384', and 'RS512'
191
192
* @param string $keyId
192
193
* @param array<string, string> $head An array with header elements to attach
193
194
*
@@ -227,8 +228,8 @@ public static function encode(
227
228
*
228
229
* @param string $msg The message to sign
229
230
* @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $key The secret key.
230
- * @param string $alg Supported algorithms are 'EdDSA', 'ES384 ', 'ES256 ', 'ES256K ', 'HS256 ',
231
- * 'HS384', 'HS512', 'RS256', 'RS384', and 'RS512'
231
+ * @param string $alg Supported algorithms are 'EdDSA', 'ES256 ', 'ES256K ', 'ES384 ', 'ES512 ',
232
+ * 'HS256', ' HS384', 'HS512', 'RS256', 'RS384', and 'RS512'
232
233
*
233
234
* @return string An encrypted message
234
235
*
@@ -262,6 +263,8 @@ public static function sign(
262
263
$ signature = self ::signatureFromDER ($ signature , 256 );
263
264
} elseif ($ alg === 'ES384 ' ) {
264
265
$ signature = self ::signatureFromDER ($ signature , 384 );
266
+ } elseif ($ alg === 'ES512 ' ) {
267
+ $ signature = self ::signatureFromDER ($ signature , 512 );
265
268
}
266
269
return $ signature ;
267
270
case 'sodium_crypto ' :
0 commit comments