DonaldChanShining / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

Progressive hashing of SHA512 yields different results on same data (Chrome only) #72

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

// tested with:
// count = 32768
// salt = "86846685d7a70051111b959"
// salt2 = "l9qAaa7Q"
// a_Password = "tester"

var preHash = CryptoJS.SHA512(salt + a_Password).toString();
var hash = CryptoJS.SHA512(salt2 + preHash);
var roundHash = CryptoJS.algo.SHA512.create();

 do {
    roundHash.update( hash );
    roundHash.update( preHash );
    hash = roundHash.finalize();
    roundHash.reset();
} while (--count);

alert( hash.toString() );

What is the expected output? What do you see instead?

The value showed in the alert window differs every time this codeblock is 
re-run.
It does *not* differ when a breakpoint is hit at least once inside the loop 
(browser bug?).

This happens with Chrome, not on Firefox.
The php based version showed the result produced with a breakpoint is correct:

$preHash = hash('sha512', $salt.$a_Password);
$hash = hash('sha512', $salt2.$preHash, true);

do {
    $hash = hash('sha512', $hash.$preHash, true);
} while (--$count);

echo bin2hex($hash);

What version of the product are you using? On what operating system?

CryptoJS 3.1.2
Tested NOT WORKING with Chrome 25.0.1364.58
Tested WORKING with Firefox 15.0.1

Original issue reported on code.google.com by arne.cl...@gmail.com on 3 Feb 2013 at 12:28

GoogleCodeExporter commented 8 years ago
Note that this happend on a beta version of Chrome.
Chrome 24 (latest release version) does not show the problem.

So this might become a non-issue once Chrome 25 is coming out of beta.

Original comment by arne.cl...@gmail.com on 3 Feb 2013 at 12:40

GoogleCodeExporter commented 8 years ago
Since this issue does not occur in any other browser, including the current 
stable build of Chrome, this seems to be a browser bug in a beta build. If this 
issue eventually occurs in the stable build, then I'll look into a workaround. 
Otherwise, this issue is more appropriately reported to Chrome.

Original comment by Jeff.Mott.OR on 3 Feb 2013 at 1:15

GoogleCodeExporter commented 8 years ago
I opened a chrome bug for this one 
http://code.google.com/p/chromium/issues/detail?id=173907

Original comment by arne.cl...@gmail.com on 3 Feb 2013 at 4:14

GoogleCodeExporter commented 8 years ago
Confirmed and fixed by the Chrome Team.

Original comment by arne.cl...@gmail.com on 7 Feb 2013 at 8:48

GoogleCodeExporter commented 8 years ago
Fantastic! Thanks for following through. :)

Original comment by Jeff.Mott.OR on 7 Feb 2013 at 11:08