cryptohash 0.7.3 → 0.7.4
raw patch · 2 files changed
+29/−1 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Crypto.MAC.HMAC: hmac :: (ByteString -> ByteString) -> Int -> ByteString -> ByteString -> ByteString
Files
- Crypto/MAC/HMAC.hs +27/−0
- cryptohash.cabal +2/−1
+ Crypto/MAC/HMAC.hs view
@@ -0,0 +1,27 @@+-- |+-- Module : Crypto.MAC.HMAC+-- License : BSD-style+-- Maintainer : Vincent Hanquez <vincent@snarc.org>+-- Stability : experimental+-- Portability : unknown+--+-- provide the HMAC (Hash based Message Authentification Code) base algorithm.+-- http://en.wikipedia.org/wiki/HMAC+--+module Crypto.MAC.HMAC+ ( hmac+ ) where++import Data.ByteString (ByteString)+import qualified Data.ByteString as B+import Data.Bits (xor)++-- | compute a MAC using the supplied hashing function+hmac :: (ByteString -> ByteString) -> Int -> ByteString -> ByteString -> ByteString+hmac f blockSize secret msg = f $ B.append opad (f $ B.append ipad msg) where+ opad = B.map (xor 0x5c) k'+ ipad = B.map (xor 0x36) k'++ k' = B.append kt pad+ kt = if B.length secret > fromIntegral blockSize then f secret else secret+ pad = B.replicate (fromIntegral blockSize - B.length kt) 0
cryptohash.cabal view
@@ -1,5 +1,5 @@ Name: cryptohash-Version: 0.7.3+Version: 0.7.4 Description: A collection of crypto hashes, with a practical incremental and one-pass, pure APIs, with performance close to the fastest implementations available in others languages.@@ -51,6 +51,7 @@ Crypto.Hash.Skein256 Crypto.Hash.Skein512 Crypto.Hash.Tiger+ Crypto.MAC.HMAC ghc-options: -Wall -O2 -optc-O3 -fno-cse C-sources: cbits/sha1.c cbits/sha256.c