Re: Bug #6159 [Fbk->Opn]: Different results
| From: | Philippe Jausions | Date: | Fri, 05 May 2006 17:50:33 +0000 |
| Subject: | Re: Bug #6159 [Fbk->Opn]: Different results | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-3745@lists.php.net to get a copy of this message | ||
Hi,
Could both of you try the latest CVS version of the package for
Crypt_Blowfish? I'd really appreciate it, since I don't have access to
the same machines as you do.
Let me know how it works out for you.
Thanks,
-Philippe
vichheann at yahoo dot fr wrote:
>Edit report at %ÈÅ„Ô<ðݸÄ<Û>
>http://pear.php.net/bugs/bug.php?id=6159&edit=1
>
> ID: 6159
> User updated by: vichheann at yahoo dot fr
> Reported By: vichheann at yahoo dot fr
>-Status: Feedback
>+Status: Open
> Id: 6159
> Type: Bug
> Package: Crypt_Blowfish
> Operating System: Fedora
> PHP Version: 5.0.3
> New Comment:
>
>I checked out the last sources on CVS and use them to update my local
>pear install. I launched then the tests with 'pear run-tests' but they
>failed on windows and linux. I also tried to use this new version with
>my code but it failed too. So I'm sorry to say that but it seems that
>the last commit has not been tested (it should work on windows at
>least). Or maybe I miss something?
>
>
>
>I trust you when you say the solution with binxor() is a performance
>killer. But in my case, it's not so important (well, for now ...).
>
>
>Previous Comments:
>------------------------------------------------------------------------
>
>[2006-04-26 13:30:16] jausions at php dot net
>
>Thank you for taking the time to report a problem with the package.
>This problem may have been already fixed by a previous change that
>is in the CVS of the package. Please log into CVS with:
>
>cvs -d :pserver:cvsread@cvs.php.net:/repository login
>
>and check out the CVS repository of this package and upgrade
>
>cvs -d :pserver:cvsread@cvs.php.net:/repository co pear/Crypt_Blowfish
>pear upgrade pear/Crypt_Blowfish/package2.xml
>
>or
>
>pear upgrade pear/Crypt_Blowfish/package.xml
>
>If you are able to reproduce the bug with the latest CVS,
>please change the status back to "Open".
>Again, thank you for your continued support of PEAR.
>
>Ok, let's see if the CVS version works for you. I don't have access to
>a machine which would have the problem with this bug, so please bear
>with us while we're trying to find a reasonable solution to this.
>
>
>
>The binxor() proposed seems to work from your comment, but it is a
>major performance killer, 6 times as slow as ^ alone...
>
>
>
>Let me know, Thanks
>
>
>
> -Philippe
>
>------------------------------------------------------------------------
>
>[2006-04-06 18:13:42] vichheann at yahoo dot fr
>
>Hi,
>
>Philippe, I did what you said and run the tests on windows and linux
>but they failed:
>
>Notice: Undefined offset: 2 in
>D:\dev\tools\php-5.0.4\PEAR\Crypt\Blowfish.php on line 215
>
>It's where i've replaced unpack by your _unpackN2
>
>
>
>I don't have 64-bit machine so no tests.
>
>------------------------------------------------------------------------
>
>[2006-04-06 15:49:07] jausions at php dot net
>
>Ok, I think this is not the whole picture. First the bindec/decbin is a
>huge performance killer. Second, it may have to do with the unpack("N2")
>and big unsigned 32-bit ending as signed integers.
>
>
>
>I don't have a access to a 64-bit machine, so I can't really do
>tests...
>
>
>
>Can any of you do some tests using:
>
>
>
> function _unpackN2($input)
>
> {
>
> list(, $Xl, $Xr) = unpack('N2', $input);
>
> return array(
>
> ($Xl < 0) ? ($Xl ^ 4294967296) : $Xl,
>
> ($Xr < 0) ? ($Xr ^ 4294967296) : $Xr);
>
> }
>
>
>
>and replacing the calls to unpack("N2"...) with $this->_unpackN2(...)?
>
>------------------------------------------------------------------------
>
>[2006-04-06 14:17:36] jausions at php dot net
>
>For performance reasons: this function should have a switch for 64-bit
>platforms only.
>
>
>
> function _binxor($a, $b) {
>
> return (PHP_INT_SIZE > 4)
>
> ? bindec(decbin((float)$a ^ (float)$b))
>
> : ($a ^ $b);
>
> }
>
>------------------------------------------------------------------------
>
>[2006-03-13 04:39:27] vichheann at yahoo dot fr
>
>I've just tried what you said and it works! Thanks Alexander!
>
>I ran 'pear run-tests' on windows and fedora and all tests passed.
>
>This is a diff of what i've made:
>
>128c128,137
>
><
>
>---
>
>
>
>
>
>
>> /**
>>
>>
>
>
>
>> *
>>
>>
>
>
>
>> *
>>
>>
>http://www.php.net/manual/en/language.operators.bitwise.php#56382
>
>
>
>> */
>>
>>
>
>
>
>> function binxor($a, $b)
>>
>>
>
>
>
>> {
>>
>>
>
>
>
>> return bindec(decbin((float)$a ^ (float)$b));
>>
>>
>
>
>
>> }
>>
>>
>
>
>
>
>151,153c160,162
>
>< $temp = $Xl ^ $this->_P[$i];
>
>< $Xl = ((($this->_S[0][($temp>>24) & 255] +
>
>< $this->_S[1][($temp>>16) & 255]) ^
>
>---
>
>
>
>> $temp =$this-> binxor($Xl, $this->_P[$i]);
>>
>>
>
>
>
>> $Xl =
>>
>>
>$this->binxor($this->binxor($this->_S[0][($temp>>24) & 255] +
>
>
>
>> $this->_S[1][($temp>>16) & 255],
>>
>>
>
>155c164
>
>< $this->_S[3][$temp & 255]) ^ $Xr;
>
>---
>
>
>
>> $this->_S[3][$temp & 255], $Xr);
>>
>>
>
>158,159c167,168
>
>< $Xr = $Xl ^ $this->_P[16];
>
>< $Xl = $temp ^ $this->_P[17];
>
>---
>
>
>
>> $Xr = $this->binxor($Xl, $this->_P[16]);
>>
>>
>
>
>
>> $Xl = $this->binxor($temp, $this->_P[17]);
>>
>>
>
>173,175c182,184
>
>< $temp = $Xl ^ $this->_P[$i];
>
>< $Xl = ((($this->_S[0][($temp>>24) & 255] +
>
>< $this->_S[1][($temp>>16) & 255]) ^
>
>---
>
>
>
>> $temp = $this->binxor($Xl, $this->_P[$i]);
>>
>>
>
>
>
>> $Xl =
>>
>>
>$this->binxor($this->binxor($this->_S[0][($temp>>24) & 255] +
>
>
>
>> $this->_S[1][($temp>>16) & 255],
>>
>>
>
>177c186
>
>< $this->_S[3][$temp & 255]) ^ $Xr;
>
>---
>
>
>
>> $this->_S[3][$temp & 255], $Xr);
>>
>>
>
>180,181c189,190
>
>< $Xr = $Xl ^ $this->_P[1];
>
>< $Xl = $temp ^ $this->_P[0];
>
>---
>
>
>
>> $Xr = $this->binxor($Xl, $this->_P[1]);
>>
>>
>
>
>
>> $Xl = $this->binxor($temp, $this->_P[0]);
>>
>>
>
>
>
>Matthew, would it be possible to fix it for a new release please?
>
>------------------------------------------------------------------------
>
>The remainder of the comments for this report are too long. To view
>the rest of the comments, please view the bug report online at
> http://pear.php.net/bugs/bug.php?id=6159
>
>
>