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

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


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

instance HashAlgorithm Keccak_224 where
    type HashBlockSize           Keccak_224 = 144
    type HashDigestSize          Keccak_224 = 28
    type HashInternalContextSize Keccak_224 = 352
    hashBlockSize :: Keccak_224 -> Int
hashBlockSize  Keccak_224
_          = Int
144
    hashDigestSize :: Keccak_224 -> Int
hashDigestSize Keccak_224
_          = Int
28
    hashInternalContextSize :: Keccak_224 -> Int
hashInternalContextSize Keccak_224
_ = Int
352
    hashInternalInit :: Ptr (Context Keccak_224) -> IO ()
hashInternalInit Ptr (Context Keccak_224)
p        = Ptr (Context Keccak_224) -> Word32 -> IO ()
forall a. Ptr (Context a) -> Word32 -> IO ()
c_keccak_init Ptr (Context Keccak_224)
p Word32
224
    hashInternalUpdate :: Ptr (Context Keccak_224) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = Ptr (Context Keccak_224) -> Ptr Word8 -> Word32 -> IO ()
forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_keccak_update
    hashInternalFinalize :: Ptr (Context Keccak_224) -> Ptr (Digest Keccak_224) -> IO ()
hashInternalFinalize Ptr (Context Keccak_224)
p    = Ptr (Context Keccak_224)
-> Word32 -> Ptr (Digest Keccak_224) -> IO ()
forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_keccak_finalize Ptr (Context Keccak_224)
p Word32
224

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

instance HashAlgorithm Keccak_256 where
    type HashBlockSize           Keccak_256 = 136
    type HashDigestSize          Keccak_256 = 32
    type HashInternalContextSize Keccak_256 = 344
    hashBlockSize :: Keccak_256 -> Int
hashBlockSize  Keccak_256
_          = Int
136
    hashDigestSize :: Keccak_256 -> Int
hashDigestSize Keccak_256
_          = Int
32
    hashInternalContextSize :: Keccak_256 -> Int
hashInternalContextSize Keccak_256
_ = Int
344
    hashInternalInit :: Ptr (Context Keccak_256) -> IO ()
hashInternalInit Ptr (Context Keccak_256)
p        = Ptr (Context Keccak_256) -> Word32 -> IO ()
forall a. Ptr (Context a) -> Word32 -> IO ()
c_keccak_init Ptr (Context Keccak_256)
p Word32
256
    hashInternalUpdate :: Ptr (Context Keccak_256) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = Ptr (Context Keccak_256) -> Ptr Word8 -> Word32 -> IO ()
forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_keccak_update
    hashInternalFinalize :: Ptr (Context Keccak_256) -> Ptr (Digest Keccak_256) -> IO ()
hashInternalFinalize Ptr (Context Keccak_256)
p    = Ptr (Context Keccak_256)
-> Word32 -> Ptr (Digest Keccak_256) -> IO ()
forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_keccak_finalize Ptr (Context Keccak_256)
p Word32
256

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

instance HashAlgorithm Keccak_384 where
    type HashBlockSize           Keccak_384 = 104
    type HashDigestSize          Keccak_384 = 48
    type HashInternalContextSize Keccak_384 = 312
    hashBlockSize :: Keccak_384 -> Int
hashBlockSize  Keccak_384
_          = Int
104
    hashDigestSize :: Keccak_384 -> Int
hashDigestSize Keccak_384
_          = Int
48
    hashInternalContextSize :: Keccak_384 -> Int
hashInternalContextSize Keccak_384
_ = Int
312
    hashInternalInit :: Ptr (Context Keccak_384) -> IO ()
hashInternalInit Ptr (Context Keccak_384)
p        = Ptr (Context Keccak_384) -> Word32 -> IO ()
forall a. Ptr (Context a) -> Word32 -> IO ()
c_keccak_init Ptr (Context Keccak_384)
p Word32
384
    hashInternalUpdate :: Ptr (Context Keccak_384) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = Ptr (Context Keccak_384) -> Ptr Word8 -> Word32 -> IO ()
forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_keccak_update
    hashInternalFinalize :: Ptr (Context Keccak_384) -> Ptr (Digest Keccak_384) -> IO ()
hashInternalFinalize Ptr (Context Keccak_384)
p    = Ptr (Context Keccak_384)
-> Word32 -> Ptr (Digest Keccak_384) -> IO ()
forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_keccak_finalize Ptr (Context Keccak_384)
p Word32
384

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

instance HashAlgorithm Keccak_512 where
    type HashBlockSize           Keccak_512 = 72
    type HashDigestSize          Keccak_512 = 64
    type HashInternalContextSize Keccak_512 = 280
    hashBlockSize :: Keccak_512 -> Int
hashBlockSize  Keccak_512
_          = Int
72
    hashDigestSize :: Keccak_512 -> Int
hashDigestSize Keccak_512
_          = Int
64
    hashInternalContextSize :: Keccak_512 -> Int
hashInternalContextSize Keccak_512
_ = Int
280
    hashInternalInit :: Ptr (Context Keccak_512) -> IO ()
hashInternalInit Ptr (Context Keccak_512)
p        = Ptr (Context Keccak_512) -> Word32 -> IO ()
forall a. Ptr (Context a) -> Word32 -> IO ()
c_keccak_init Ptr (Context Keccak_512)
p Word32
512
    hashInternalUpdate :: Ptr (Context Keccak_512) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = Ptr (Context Keccak_512) -> Ptr Word8 -> Word32 -> IO ()
forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_keccak_update
    hashInternalFinalize :: Ptr (Context Keccak_512) -> Ptr (Digest Keccak_512) -> IO ()
hashInternalFinalize Ptr (Context Keccak_512)
p    = Ptr (Context Keccak_512)
-> Word32 -> Ptr (Digest Keccak_512) -> IO ()
forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_keccak_finalize Ptr (Context Keccak_512)
p Word32
512


foreign import ccall unsafe "crypton_keccak_init"
    c_keccak_init :: Ptr (Context a) -> Word32 -> IO ()

foreign import ccall "crypton_keccak_update"
    c_keccak_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()

foreign import ccall unsafe "crypton_keccak_finalize"
    c_keccak_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()