@@ -301,20 +301,20 @@ private static function verify(
301
301
'OpenSSL error: ' . \openssl_error_string ()
302
302
);
303
303
case 'sodium_crypto ' :
304
- if (!\function_exists ('sodium_crypto_sign_verify_detached ' )) {
305
- throw new DomainException ('libsodium is not available ' );
306
- }
307
- if (!\is_string ($ keyMaterial )) {
308
- throw new InvalidArgumentException ('key must be a string when using EdDSA ' );
309
- }
310
- try {
311
- // The last non-empty line is used as the key.
312
- $ lines = array_filter (explode ("\n" , $ keyMaterial ));
313
- $ key = base64_decode ((string ) end ($ lines ));
314
- return sodium_crypto_sign_verify_detached ($ signature , $ msg , $ key );
315
- } catch (Exception $ e ) {
316
- throw new DomainException ($ e ->getMessage (), 0 , $ e );
317
- }
304
+ if (!\function_exists ('sodium_crypto_sign_verify_detached ' )) {
305
+ throw new DomainException ('libsodium is not available ' );
306
+ }
307
+ if (!\is_string ($ keyMaterial )) {
308
+ throw new InvalidArgumentException ('key must be a string when using EdDSA ' );
309
+ }
310
+ try {
311
+ // The last non-empty line is used as the key.
312
+ $ lines = array_filter (explode ("\n" , $ keyMaterial ));
313
+ $ key = base64_decode ((string ) end ($ lines ));
314
+ return sodium_crypto_sign_verify_detached ($ signature , $ msg , $ key );
315
+ } catch (Exception $ e ) {
316
+ throw new DomainException ($ e ->getMessage (), 0 , $ e );
317
+ }
318
318
case 'hash_hmac ' :
319
319
default :
320
320
if (!\is_string ($ keyMaterial )) {
@@ -510,7 +510,7 @@ private static function signatureToDER(string $sig): string
510
510
{
511
511
// Separate the signature into r-value and s-value
512
512
$ length = max (1 , (int ) (\strlen ($ sig ) / 2 ));
513
- list ($ r , $ s ) = \str_split ($ sig , $ length > 0 ? $ length : 1 );
513
+ list ($ r , $ s ) = \str_split ($ sig , $ length );
514
514
515
515
// Trim leading zeros
516
516
$ r = \ltrim ($ r , "\x00" );
0 commit comments