[Fencommits] fenserve: argh, fix a bug with SHA1.hs (I tested with a couple of test vectors now so it should probably be correct now)
Benja Fallenstein
benja.fallenstein at gmail.com
Sun Apr 1 21:06:36 EEST 2007
Sun Apr 1 21:05:55 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* argh, fix a bug with SHA1.hs (I tested with a couple of test vectors now so it should probably be correct now)
diff -rN -u old-fenserve/SHA1.hs new-fenserve/SHA1.hs
--- old-fenserve/SHA1.hs 2007-04-01 21:06:35.000000000 +0300
+++ new-fenserve/SHA1.hs 2007-04-01 21:06:35.000000000 +0300
@@ -128,12 +128,12 @@
sha1_ws :: Int -> ByteString -> Int -> Arr s -> ST s ByteString
sha1_ws 16 s offs arr = return s
sha1_ws n s offs arr = do
- let b1 = fromIntegral $ B.index s (n+offs)
- b2 = fromIntegral $ B.index s (n+offs+1)
- b3 = fromIntegral $ B.index s (n+offs+2)
- b4 = fromIntegral $ B.index s (n+offs+3)
+ let b1 = fromIntegral $ B.index s (offs)
+ b2 = fromIntegral $ B.index s (offs+1)
+ b3 = fromIntegral $ B.index s (offs+2)
+ b4 = fromIntegral $ B.index s (offs+3)
w = shiftL b1 24 + shiftL b2 16 + shiftL b3 8 + b4
- writeArray arr n w; sha1_ws (n+1) s offs arr
+ writeArray arr n w; sha1_ws (n+1) s (offs+4) arr
sha1_add_ws :: Int -> Arr s -> ST s ()
sha1_add_ws 80 arr = return ()
More information about the Fencommits
mailing list