From 2dcde34387fd04354fbef647c6741f98a9cffb7e Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Wed, 12 Mar 2008 22:03:08 +0000 Subject: [PATCH] - fixed php.net bug 13324 - Method BigInteger::bitwise_or produces wrong result git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@10 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Math/BigInteger.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 22b2387c..693f7f4d 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -69,7 +69,7 @@ * @author Jim Wigginton * @copyright MMVI Jim Wigginton * @license http://www.gnu.org/licenses/lgpl.txt - * @version $Id: BigInteger.php,v 1.2 2007-07-23 05:21:39 terrafrost Exp $ + * @version $Id: BigInteger.php,v 1.3 2008-03-12 22:03:08 terrafrost Exp $ * @link http://pear.php.net/package/Math_BigInteger */ @@ -1414,7 +1414,7 @@ class Math_BigInteger { * * As for why we do all the bitmasking... strange things can happen when converting from flots to ints. For * instance, on some computers, var_dump((int) -4294967297) yields int(-1) and on others, it yields - * int(-2147483648). To avoid problems stemming from this, we use bitmasks to guarntee that ints aren't + * int(-2147483648). To avoid problems stemming from this, we use bitmasks to guarantee that ints aren't * auto-converted to floats. The outermost bitmask is present because without it, there's no guarantee that * the "residue" returned would be the so-called "common residue". We use fmod, in the last step, because the * maximum possible $x is 26 bits and the maximum $result is 16 bits. Thus, we have to be able to handle up to @@ -1736,11 +1736,11 @@ class Math_BigInteger { return new Math_BigInteger($this->toBytes() | $x->toBytes(), 256); } - $result = new Math_BigInteger(); + $result = $this->_copy(); $x_length = count($x->value); for ($i = 0; $i < $x_length; $i++) { - $result->value[] = $this->value[$i] | $x->value[$i]; + $result->value[$i] = $this->value[$i] | $x->value[$i]; } return $result->_normalize(); @@ -1766,11 +1766,11 @@ class Math_BigInteger { return new Math_BigInteger($this->toBytes() ^ $x->toBytes(), 256); } - $result = new Math_BigInteger(); + $result = $this->_copy(); $x_length = count($x->value); for ($i = 0; $i < $x_length; $i++) { - $result->value[] = $this->value[$i] ^ $x->value[$i]; + $result->value[$i] = $this->value[$i] ^ $x->value[$i]; } return $result->_normalize();