From a7ebe7d39de120451ebe3ddbadf3a5268a24a70e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 5 Oct 2017 05:36:36 -0500 Subject: [PATCH 1/2] BigInteger: fix bitwise_not for 0 --- phpseclib/Math/BigInteger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 54bff85c..6f9d5915 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -2945,7 +2945,7 @@ class Math_BigInteger // (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0) $temp = $this->toBytes(); if ($temp == '') { - return ''; + return $this->_normalize(new Math_BigInteger()); } $pre_msb = decbin(ord($temp[0])); $temp = ~$temp; From 6d51f2bf850c06fa0457bbaa223f6b58a7f00e20 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 5 Oct 2017 05:39:00 -0500 Subject: [PATCH 2/2] BigInteger: update bitwise_not fix for 2.0 --- phpseclib/Math/BigInteger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 32320b43..ad456fcb 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -2908,7 +2908,7 @@ class BigInteger // (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0) $temp = $this->toBytes(); if ($temp == '') { - return $this->_normalize(new Math_BigInteger()); + return $this->_normalize(new static()); } $pre_msb = decbin(ord($temp[0])); $temp = ~$temp;