packages feed

SHA2 0.1.1 → 0.2.0

raw patch · 3 files changed

+14/−15 lines, 3 filesdep ~AESPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: AES

API changes (from Hackage documentation)

- Codec.Digest.SHA: hash' :: Length -> ByteString -> ByteString
+ Codec.Digest.SHA.Misc: showHex :: Word8 -> String -> String
- Codec.Digest.SHA: hash :: Length -> ByteString -> ByteString
+ Codec.Digest.SHA: hash :: (Hashable a) => Length -> a -> ByteString

Files

Codec/Digest/SHA.hs view
@@ -1,22 +1,17 @@--- | A pure interface to SHA+-- | A pure interface to SHA2 module Codec.Digest.SHA(-  Length(..), hash, hash', hmac,+  Length(..), hash, hmac,   showBSasHex ) where  import Codec.Digest.SHA.Monad import qualified Data.ByteString as B-import qualified Data.ByteString.Lazy as BL import Data.Bits(xor) --- | Hashing lazy bytestrings-hash :: Length -> BL.ByteString -> B.ByteString+-- | Plain SHA2+hash :: Hashable a => Length -> a -> B.ByteString hash len bs = snd $ runSHA len (update bs) --- | Hashing strict bytestrings-hash' :: Length -> B.ByteString -> B.ByteString-hash' len bs = snd $ runSHA len (update bs)- lenBytes :: Num a => Length -> a lenBytes SHA256 = 32 lenBytes SHA384 = 48@@ -27,7 +22,7 @@                             then B.take len k                             else B.concat [k,(B.replicate (len - B.length k) 0)] --- | SHA-based HMAC, see http://en.wikipedia.org/wiki/HMAC+-- | SHA2-based HMAC, see http://en.wikipedia.org/wiki/HMAC -- -- If you're doing encryption and want to prevent attackers from -- changing your messages, you probably want this.@@ -36,7 +31,7 @@        -> B.ByteString -- ^ The shared secret key to use        -> a -- ^ Message to hash        -> B.ByteString-hmac len key' msg = hash' len $ B.concat [opad,ihash]+hmac len key' msg = hash len $ B.concat [opad,ihash]   where     ihash = snd $ runSHA len $ update ipad >> update msg     opad = B.map (xor 0x5c) key
Codec/Digest/SHA/Misc.hs view
@@ -1,9 +1,14 @@ module Codec.Digest.SHA.Misc where  import qualified Data.ByteString as B-import Numeric(showHex)+import qualified Numeric(showHex)+import Data.Word(Word8)  -- | Converts a ByteString to hexadeximal string format showBSasHex :: B.ByteString -> String showBSasHex bs | B.null bs = "" showBSasHex bs = showHex (B.index bs 0) $ showBSasHex (B.drop 1 bs)++showHex :: Word8 -> String -> String+showHex n rest | n < 0x10 = Numeric.showHex n ('0' : rest)+showHEx n rest = Numeric.showHex n rest
SHA2.cabal view
@@ -1,7 +1,7 @@ Name: SHA2 Synopsis: Fast, incremental SHA hashing for bytestrings Description: A zero-copy binding to Aaron Gifford's SHA implementation, including a copy of that implementation-Version: 0.1.1+Version: 0.2.0 License: BSD3 License-file: COPYING Copyright: Copyright (c) 2009 University of Tromsø@@ -17,7 +17,7 @@ Library   Build-Depends:         base >= 4 && < 5 , bytestring, monads-tf >= 0.0.0.1 && < 0.1,-        transformers >= 0.1.4.0 && < 0.2, AES >= 0.2 && < 0.3+        transformers >= 0.1.4.0 && < 0.2, AES >= 0.2   Extensions:         ForeignFunctionInterface,         ViewPatterns,@@ -37,4 +37,3 @@    C-sources: cbits/sha2.c   Include-Dirs: cbits-