vincenthz / hs-cryptohash

efficient and practical cryptohashing in haskell. DEPRECATED in favor of cryptonite
Other
30 stars 24 forks source link

Wrong hashes with Skein512_256 #21

Closed redneb closed 10 years ago

redneb commented 10 years ago

The implementation of Skein512_256 returns different results depending on how the input is broken into chunks and fed to hashUpdate. For example, the program:

import Crypto.Hash
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L

s1, s2 :: B.ByteString
s1 = B.replicate  1 0
s2 = B.replicate 63 0

hs, hl :: Digest Skein512_256
hs = hash (B.concat [s1,s2])
hl = hashlazy (L.fromChunks [s1,s2])

main :: IO ()
main = print hs >> print hl

produces the following output:

24e8a5a2bdbf2f5540a2a181b8caa52559da938a6d8006b26a70f8e3f3d741f6
075cefbbf6eb63919fcfdc87752511114f459f6a566dad285725cb82c543c6b5
vincenthz commented 10 years ago

ouch. that's really bad. I'll have a look ASAP

vincenthz commented 10 years ago

Thanks for finding the bug and issuing a good test case.