@@ -301,20 +301,20 @@ private static function verify(
301301 'OpenSSL error: ' . \openssl_error_string ()
302302 );
303303 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+ }
318318 case 'hash_hmac ' :
319319 default :
320320 if (!\is_string ($ keyMaterial )) {
@@ -510,7 +510,7 @@ private static function signatureToDER(string $sig): string
510510 {
511511 // Separate the signature into r-value and s-value
512512 $ 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 );
514514
515515 // Trim leading zeros
516516 $ r = \ltrim ($ r , "\x00" );
0 commit comments