srijs / rusha

High-performance pure-javascript SHA1 implementation suitable for large binary data, reaching up to half the native speed.
https://npmjs.org/rusha
MIT License
277 stars 32 forks source link

Fix padlen (i.e. fix Rusha for length%64 == 55) #4

Closed edwintorok closed 11 years ago

edwintorok commented 11 years ago

Rusha is giving wrong results when length is 55. For example a buffer full of zeroes of length 55:

Rusha    hash mismatch on size 55: cc8562dd082fad5ad46646b2737be76d6eefd836 expected: 8e8832c642a6a38c74c17fc92ccedc266c108e6c

I have confirmed that 8e8832c642a6a38c74c17fc92ccedc266c108e6c is the good expected hash:

$ dd if=/dev/zero bs=55 count=1 2>/dev/null|sha1sum -
8e8832c642a6a38c74c17fc92ccedc266c108e6c  -

The 2 commits in this pull request:

srijs commented 11 years ago

Good spot! Thank you. While this looks good so far, I will verify the functionality tomorrow and then subsequently merge...

srijs commented 11 years ago

Merged with gratitude.

srijs commented 11 years ago

On a side-note, Tim Caswell's Cifre seems to have the same problem. I just opened an issue over there (https://github.com/openpeer/cifre/issues/2).