diff --git a/phpseclib/Math/BigInteger/Engines/BCMath.php b/phpseclib/Math/BigInteger/Engines/BCMath.php index b9739243..08273490 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -514,8 +514,6 @@ class BCMath extends Engine */ protected function normalize(BCMath $result) { - unset($result->reduce); - $result->precision = $this->precision; $result->bitmask = $this->bitmask; diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php index 27530ec7..35a3f313 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php @@ -59,11 +59,6 @@ abstract class EvalBarrett extends Base */ protected static function generateCustomReduction(BCMath $m, $class) { - if (isset($n->reduce)) { - self::$custom_reduction = $n->reduce; - return $n->reduce; - } - $m_length = strlen($m); if ($m_length < 5) { diff --git a/phpseclib/Math/BigInteger/Engines/Engine.php b/phpseclib/Math/BigInteger/Engines/Engine.php index 17b1996c..fd9eb828 100644 --- a/phpseclib/Math/BigInteger/Engines/Engine.php +++ b/phpseclib/Math/BigInteger/Engines/Engine.php @@ -1081,20 +1081,18 @@ abstract class Engine static::$modexpEngine; if (method_exists($fqengine, 'generateCustomReduction')) { $func = $fqengine::generateCustomReduction($this, static::class); - $this->reduce = eval('return function(' . static::class . ' $x) use ($func, $class) { + return eval('return function(' . static::class . ' $x) use ($func, $class) { $r = new $class(); $r->value = $func($x->value); return $r; };'); - return clone $this->reduce; } $n = $this->value; - $this->reduce = eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) { + return eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) { $r = new $class(); $r->value = $fqengine::reduce($x->value, $n, $class); return $r; };'); - return clone $this->reduce; } /** diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index 2cbc9cbe..74272da8 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -512,8 +512,6 @@ class GMP extends Engine */ protected function normalize(GMP $result) { - unset($result->reduce); - $result->precision = $this->precision; $result->bitmask = $this->bitmask; @@ -683,10 +681,9 @@ class GMP extends Engine public function createRecurringModuloFunction() { $temp = $this->value; - $this->reduce = function(GMP $x) use ($temp) { + return function(GMP $x) use ($temp) { return new GMP($x->value % $temp); }; - return $this->reduce; } /** diff --git a/phpseclib/Math/BigInteger/Engines/PHP.php b/phpseclib/Math/BigInteger/Engines/PHP.php index 5f94e68b..63705f9f 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP.php +++ b/phpseclib/Math/BigInteger/Engines/PHP.php @@ -731,8 +731,6 @@ abstract class PHP extends Engine */ protected function normalize(PHP $result) { - unset($result->reduce); - $result->precision = $this->precision; $result->bitmask = $this->bitmask; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php index 7c81071d..c9f82c70 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php @@ -60,11 +60,6 @@ abstract class EvalBarrett extends Base */ protected static function generateCustomReduction(PHP $m, $class) { - if (isset($n->reduce)) { - self::$custom_reduction = $n->reduce; - return $n->reduce; - } - $m_length = count($m->value); if ($m_length < 5) {