    -- |
    -- Module      : Crypto.Hash.SHA256
    -- License     : BSD-style
    -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
    -- Stability   : experimental
    -- Portability : unknown
    --
    -- Module containing the binding functions to work with the
    -- SHA256 cryptographic hash.
    --
    {-# LANGUAGE ForeignFunctionInterface #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DataKinds #-}
    {-# LANGUAGE TypeFamilies #-}
    module Crypto.Hash.SHA256 ( SHA256 (..) ) where

    import           Crypto.Hash.Types
    import           Foreign.Ptr (Ptr)
    import           Data.Data
    import           Data.Word (Word8, Word32)

    -- | SHA256 cryptographic hash algorithm
    data SHA256 = SHA256
        deriving (Int -> SHA256 -> ShowS
    [SHA256] -> ShowS
    SHA256 -> String
    (Int -> SHA256 -> ShowS)
    -> (SHA256 -> String) -> ([SHA256] -> ShowS) -> Show SHA256
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> SHA256 -> ShowS
    showsPrec :: Int -> SHA256 -> ShowS
    $cshow :: SHA256 -> String
    show :: SHA256 -> String
    $cshowList :: [SHA256] -> ShowS
    showList :: [SHA256] -> ShowS
    Show,Typeable SHA256
    Typeable SHA256
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> SHA256 -> c SHA256)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SHA256)
    -> (SHA256 -> Constr)
    -> (SHA256 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c SHA256))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA256))
    -> ((forall b. Data b => b -> b) -> SHA256 -> SHA256)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> SHA256 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> SHA256 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> SHA256 -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> SHA256 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> SHA256 -> m SHA256)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SHA256 -> m SHA256)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SHA256 -> m SHA256)
    -> Data SHA256
    SHA256 -> Constr
    SHA256 -> DataType
    (forall b. Data b => b -> b) -> SHA256 -> SHA256
    forall a.
    Typeable a
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> SHA256 -> u
    forall u. (forall d. Data d => d -> u) -> SHA256 -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SHA256
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SHA256 -> c SHA256
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SHA256)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA256)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SHA256 -> c SHA256
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SHA256 -> c SHA256
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SHA256
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SHA256
    $ctoConstr :: SHA256 -> Constr
    toConstr :: SHA256 -> Constr
    $cdataTypeOf :: SHA256 -> DataType
    dataTypeOf :: SHA256 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SHA256)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SHA256)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA256)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA256)
    $cgmapT :: (forall b. Data b => b -> b) -> SHA256 -> SHA256
    gmapT :: (forall b. Data b => b -> b) -> SHA256 -> SHA256
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA256 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> SHA256 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA256 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA256 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA256 -> m SHA256
    Data)

    instance HashAlgorithm SHA256 where
        type HashBlockSize           SHA256 = 64
        type HashDigestSize          SHA256 = 32
        type HashInternalContextSize SHA256 = 192
        hashBlockSize :: SHA256 -> Int
    hashBlockSize  SHA256
    _          = Int
    64
        hashDigestSize :: SHA256 -> Int
    hashDigestSize SHA256
    _          = Int
    32
        hashInternalContextSize :: SHA256 -> Int
    hashInternalContextSize SHA256
    _ = Int
    192
        hashInternalInit :: Ptr (Context SHA256) -> IO ()
    hashInternalInit          = Ptr (Context SHA256) -> IO ()
    forall a. Ptr (Context a) -> IO ()
    c_sha256_init
        hashInternalUpdate :: Ptr (Context SHA256) -> Ptr Word8 -> Word32 -> IO ()
    hashInternalUpdate        = Ptr (Context SHA256) -> Ptr Word8 -> Word32 -> IO ()
    forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
    c_sha256_update
        hashInternalFinalize :: Ptr (Context SHA256) -> Ptr (Digest SHA256) -> IO ()
    hashInternalFinalize      = Ptr (Context SHA256) -> Ptr (Digest SHA256) -> IO ()
    forall a. Ptr (Context a) -> Ptr (Digest a) -> IO ()
    c_sha256_finalize

    instance HashAlgorithmPrefix SHA256 where
        hashInternalFinalizePrefix :: Ptr (Context SHA256)
    -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest SHA256) -> IO ()
    hashInternalFinalizePrefix = Ptr (Context SHA256)
    -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest SHA256) -> IO ()
    forall a.
    Ptr (Context a)
    -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
    c_sha256_finalize_prefix

    foreign import ccall unsafe "crypton_sha256_init"
        c_sha256_init :: Ptr (Context a)-> IO ()

    foreign import ccall "crypton_sha256_update"
        c_sha256_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()

    foreign import ccall unsafe "crypton_sha256_finalize"
        c_sha256_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()

    foreign import ccall "crypton_sha256_finalize_prefix"
        c_sha256_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()