From 67f87dd1e276ef4a82842a54f9a3a47edc01c915 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 11 Aug 2024 10:47:47 -0500 Subject: [PATCH 1/2] Tests/BigInteger: update bitwise_OR test --- tests/Unit/Math/BigInteger/TestCase.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index c19320fe..287d6c87 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -221,6 +221,12 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($z->toHex(), $x->bitwise_OR($y)->toHex()); + $x = $this->getInstance('AFAFAFAFAFAFAFAFAFAFAFAF', 16); + $y = $this->getInstance('133713371337133713371337', 16); + $z = $this->getInstance('BFBFBFBFBFBFBFBFBFBFBFBF', 16); + + $this->assertSame($z->toHex(), $x->bitwise_OR($y)->toHex()); + $x = -0xFFFF; $y = 2; $z = $x ^ $y; From 36d2092a81f9ab91593bc4ccb16ba496465577ac Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 11 Aug 2024 11:02:56 -0500 Subject: [PATCH 2/2] BigInteger/BCMath engine's bitwise_or() was doing XOR --- phpseclib/Math/BigInteger/Engines/BCMath.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger/Engines/BCMath.php b/phpseclib/Math/BigInteger/Engines/BCMath.php index 7c5ca9fb..e3a49906 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -336,7 +336,7 @@ class BCMath extends Engine */ public function bitwise_or(BCMath $x) { - return $this->bitwiseXorHelper($x); + return $this->bitwiseOrHelper($x); } /**