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

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


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

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

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

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

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

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

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

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


foreign import ccall unsafe "crypton_sha3_init"
    c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()

foreign import ccall "crypton_sha3_update"
    c_sha3_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()

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