From 9e321981a2460567d565f1d3df4b97214812d5fd Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Tue, 22 Feb 2022 19:33:16 -0600 Subject: [PATCH] Psalm coverage for phpseclib3\Math\ Revert accidental change --- build/psalm.xml | 16 +- build/psalm_baseline.xml | 319 +++++++++++++++++++ phpseclib/Math/BigInteger/Engines/Engine.php | 2 +- 3 files changed, 321 insertions(+), 16 deletions(-) create mode 100644 build/psalm_baseline.xml diff --git a/build/psalm.xml b/build/psalm.xml index 0a3f8db6..b521dbfe 100644 --- a/build/psalm.xml +++ b/build/psalm.xml @@ -7,6 +7,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedPsalmSuppress="true" sealAllMethods="true" + errorBaseline="psalm_baseline.xml" > @@ -26,20 +27,5 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/psalm_baseline.xml b/build/psalm_baseline.xml new file mode 100644 index 00000000..19a5bd62 --- /dev/null +++ b/build/psalm_baseline.xml @@ -0,0 +1,319 @@ + + + + + $this->value + + + $class::max(...$nums) + $class::min(...$nums) + $class::randomRange($min->value, $max->value) + $class::randomRangePrime($min->value, $max->value) + $class::scan1divide($r->value) + + + + + $current + $current + $current + $n->value + $r_value + $result->bitmask->value + $result->value + $temp + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $u + $v + $v + $v + $x->value + $y->value + $y->value + $y->value + $y->value + $y->value + $y->value[0] == '-' ? substr($y->value, 1) : $y->value + + + $class::powModHelper($this, $e, $n, static::class) + $current + $r_value + $temp->value + $this->value + $this->value + $this->value + $this->value + $y->value + + + + + static::reduce($x, $n) + static::reduce(bcmul($x, $x), $n) + static::reduce(bcmul($x, $y), $n) + + + + + $e->value + $n->value + $x->value + + + + + $x[0] + $x[0] + $x[0] + + + static::$zero + static::$zero + + + static::ENGINE_DIR + static::ENGINE_DIR + static::FAST_BITWISE + static::FAST_BITWISE + + + abs + abs + abs + abs + add + add + add + add + bitwise_leftShift + bitwise_leftShift + bitwise_rightShift + compare + compare + compare + compare + compare + compare + compare + compare + compare + compare + compare + compare + divide + divide + equals + equals + equals + extendedGCD + initialize + initialize + initialize + make_odd + make_odd + make_odd + modInverse + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + normalize + powModInner + static::randomRange($min, $max) + static::randomRange($min, $max) + static::randomRange(static::$two[static::class], $n_2) + static::randomRangePrime($min, $max) + static::scan1divide($r) + subtract + subtract + subtract + subtract + subtract + subtract + subtract + subtract + testSmallPrimes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toString + + + + + $class::powModHelper($this, $e, $n) + + + + + toBytes + + + + + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::MAX10 + static::MAX10 + static::MAX10LEN + static::MAX10LEN + static::MAX10LEN + static::MAX10LEN + static::MAX10LEN + static::MAX_DIGIT + static::MAX_DIGIT + static::MAX_DIGIT + static::MAX_DIGIT + static::MAX_DIGIT2 + static::MAX_DIGIT2 + static::MAX_DIGIT2 + static::MSB + + + $class::powModHelper($this, $e, $n, static::class) + $r_value + $result->bitmask->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $val + $val + $val + $val + $val + $val + $val + $value + $x + $y->value + $y->value + $y_value + $y_value + compare + compare + static::isValidEngine() + subtract + subtract + + + + + divide + static::reduce($class::square($x), $n, $class) + static::reduce($temp[self::VALUE], $n, $class) + static::reduce($x, $n, $class) + + + + + $n->value + modInverse + rshift + + + + + divide + divide + + + + + $m + $m->value + + + + + $m + + + + + $val + + + + + static::$zero + static::$zero + static::$zero + static::$zero + static::$zero + static::$zero + + + diff --git a/phpseclib/Math/BigInteger/Engines/Engine.php b/phpseclib/Math/BigInteger/Engines/Engine.php index b4769696..455cebd0 100644 --- a/phpseclib/Math/BigInteger/Engines/Engine.php +++ b/phpseclib/Math/BigInteger/Engines/Engine.php @@ -900,7 +900,7 @@ abstract class Engine // see HAC 4.49 "Note (controlling the error probability)" // @codingStandardsIgnoreStart - if ($length >= 163) $t = 2; // floor(1300 / 8) + if ($length >= 163) { $t = 2; } // floor(1300 / 8) else if ($length >= 106) { $t = 3; } // floor( 850 / 8) else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8)