asmcrypto / asmcrypto.js

JavaScript Cryptographic Library with performance in mind.
MIT License
660 stars 182 forks source link

SHA-256 hash of over 4GB file is incorrect (doesn't match openssl) #81

Closed ktarplee closed 9 years ago

ktarplee commented 9 years ago

I think a 32 bit integer is overflowing. If I had to guess I would say it is the variable called TOTAL. I will try to get a standalone test for this posted to this ticket when I get time.

SHA-256 is supposed to be able to handle messages of almost 2^64 bits.

vibornoff commented 9 years ago

It's definitely overflow of the TOTAL variable. Thanks, I'll fix it ASAP.

vibornoff commented 9 years ago

Hey! Could you please verify the bug is fixed now?

ktarplee commented 9 years ago

I tried 1GB, 5GB, and 10GB random files and they all have correct hashes now. Good job! Can you make a release of this so I can bower install this guy?