{-# LANGUAGE PackageImports #-}
module Crypto.Hash.SHA224
( Ctx(..)
, init
, update
, updates
, finalize
, hash
, hashlazy
) where
import Prelude hiding (init)
import qualified Data.ByteString.Lazy as L
import Data.ByteString (ByteString)
import Crypto.Hash.Internal (digestToByteString, digestToByteStringWitness)
import qualified "cryptonite" Crypto.Hash as H
newtype Ctx = Ctx (H.Context H.SHA224)
init :: Ctx
init :: Ctx
init = Context SHA224 -> Ctx
Ctx Context SHA224
forall a. HashAlgorithm a => Context a
H.hashInit
update :: Ctx -> ByteString -> Ctx
update :: Ctx -> ByteString -> Ctx
update (Ctx ctx :: Context SHA224
ctx) d :: ByteString
d = Context SHA224 -> Ctx
Ctx (Context SHA224 -> Ctx) -> Context SHA224 -> Ctx
forall a b. (a -> b) -> a -> b
$ Context SHA224 -> ByteString -> Context SHA224
forall ba a.
(ByteArrayAccess ba, HashAlgorithm a) =>
Context a -> ba -> Context a
H.hashUpdate Context SHA224
ctx ByteString
d
updates :: Ctx -> [ByteString] -> Ctx
updates :: Ctx -> [ByteString] -> Ctx
updates (Ctx ctx :: Context SHA224
ctx) d :: [ByteString]
d =
Context SHA224 -> Ctx
Ctx (Context SHA224 -> Ctx) -> Context SHA224 -> Ctx
forall a b. (a -> b) -> a -> b
$ Context SHA224 -> [ByteString] -> Context SHA224
forall a ba.
(HashAlgorithm a, ByteArrayAccess ba) =>
Context a -> [ba] -> Context a
H.hashUpdates Context SHA224
ctx [ByteString]
d
finalize :: Ctx -> ByteString
finalize :: Ctx -> ByteString
finalize (Ctx ctx :: Context SHA224
ctx) = Digest SHA224 -> ByteString
forall h. HashAlgorithm h => Digest h -> ByteString
digestToByteString (Digest SHA224 -> ByteString) -> Digest SHA224 -> ByteString
forall a b. (a -> b) -> a -> b
$ Context SHA224 -> Digest SHA224
forall a. HashAlgorithm a => Context a -> Digest a
H.hashFinalize Context SHA224
ctx
hash :: ByteString -> ByteString
hash :: ByteString -> ByteString
hash d :: ByteString
d = SHA224 -> Digest SHA224 -> ByteString
forall h. HashAlgorithm h => h -> Digest h -> ByteString
digestToByteStringWitness SHA224
H.SHA224 (Digest SHA224 -> ByteString) -> Digest SHA224 -> ByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> Digest SHA224
forall ba a.
(ByteArrayAccess ba, HashAlgorithm a) =>
ba -> Digest a
H.hash ByteString
d
hashlazy :: L.ByteString -> ByteString
hashlazy :: ByteString -> ByteString
hashlazy l :: ByteString
l = SHA224 -> Digest SHA224 -> ByteString
forall h. HashAlgorithm h => h -> Digest h -> ByteString
digestToByteStringWitness SHA224
H.SHA224 (Digest SHA224 -> ByteString) -> Digest SHA224 -> ByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> Digest SHA224
forall a. HashAlgorithm a => ByteString -> Digest a
H.hashlazy ByteString
l