From 31c10f39e5a67094b853f69a35f3b084ef61d91e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 9 Apr 2019 20:42:18 -0500 Subject: [PATCH] BigInteger/GMP: negative base-256 numbers didn't load correctly --- phpseclib/Math/BigInteger/Engines/GMP.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index 148492de..72ec98ad 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -136,8 +136,10 @@ class GMP extends Engine { switch (abs($base)) { case 256: - $sign = $this->is_negative ? '-' : ''; $this->value = gmp_import($this->value); + if ($this->is_negative) { + $this->value = -$this->value; + } break; case 16: $temp = $this->is_negative ? '-0x' . $this->value : '0x' . $this->value;