diff --git a/phpseclib/Common/Functions/Strings.php b/phpseclib/Common/Functions/Strings.php index c1165f38..30d77418 100644 --- a/phpseclib/Common/Functions/Strings.php +++ b/phpseclib/Common/Functions/Strings.php @@ -435,7 +435,7 @@ abstract class Strings // return str_replace(['+', '/'], ['-', '_'], self::base64_encode($data)); return function_exists('sodium_bin2base64') ? - sodium_bin2base64($data, SODIUM_BASE64_VARIANT_URLSAFE) : + sodium_bin2base64($data, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING) : Base64UrlSafe::encode($data); } diff --git a/phpseclib/Crypt/EC/Formats/Signature/IEEE.php b/phpseclib/Crypt/EC/Formats/Signature/IEEE.php index e300b6c1..ae1c648a 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/IEEE.php +++ b/phpseclib/Crypt/EC/Formats/Signature/IEEE.php @@ -58,7 +58,7 @@ abstract class IEEE { $r = $r->toBytes(); $s = $s->toBytes(); - $length >>= 3; + $length = (int) ceil($length / 8); return str_pad($r, $length, "\0", STR_PAD_LEFT) . str_pad($s, $length, "\0", STR_PAD_LEFT); } }