-- |
-- 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
showList :: [SHA3_224] -> ShowS
$cshowList :: [SHA3_224] -> ShowS
show :: SHA3_224 -> String
$cshow :: SHA3_224 -> String
showsPrec :: Int -> SHA3_224 -> ShowS
$cshowsPrec :: Int -> SHA3_224 -> ShowS
Show,Typeable SHA3_224
DataType
Constr
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 -> DataType
SHA3_224 -> Constr
(forall b. Data b => b -> b) -> SHA3_224 -> SHA3_224
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_224 -> c SHA3_224
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSHA3_224 :: Constr
$tSHA3_224 :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> SHA3_224 -> m SHA3_224
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SHA3_224 -> m SHA3_224
gmapQi :: Int -> (forall d. Data d => d -> u) -> SHA3_224 -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA3_224 -> u
gmapQ :: (forall d. Data d => d -> u) -> SHA3_224 -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA3_224 -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_224 -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_224 -> r
gmapT :: (forall b. Data b => b -> b) -> SHA3_224 -> SHA3_224
$cgmapT :: (forall b. Data b => b -> b) -> SHA3_224 -> SHA3_224
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> 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)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SHA3_224)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA3_224)
dataTypeOf :: SHA3_224 -> DataType
$cdataTypeOf :: SHA3_224 -> DataType
toConstr :: SHA3_224 -> Constr
$ctoConstr :: SHA3_224 -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_224 -> 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
$cp1Data :: Typeable 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
showList :: [SHA3_256] -> ShowS
$cshowList :: [SHA3_256] -> ShowS
show :: SHA3_256 -> String
$cshow :: SHA3_256 -> String
showsPrec :: Int -> SHA3_256 -> ShowS
$cshowsPrec :: Int -> SHA3_256 -> ShowS
Show,Typeable SHA3_256
DataType
Constr
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 -> DataType
SHA3_256 -> Constr
(forall b. Data b => b -> b) -> SHA3_256 -> SHA3_256
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_256 -> c SHA3_256
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSHA3_256 :: Constr
$tSHA3_256 :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> SHA3_256 -> m SHA3_256
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SHA3_256 -> m SHA3_256
gmapQi :: Int -> (forall d. Data d => d -> u) -> SHA3_256 -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA3_256 -> u
gmapQ :: (forall d. Data d => d -> u) -> SHA3_256 -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA3_256 -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_256 -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_256 -> r
gmapT :: (forall b. Data b => b -> b) -> SHA3_256 -> SHA3_256
$cgmapT :: (forall b. Data b => b -> b) -> SHA3_256 -> SHA3_256
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> 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)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SHA3_256)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA3_256)
dataTypeOf :: SHA3_256 -> DataType
$cdataTypeOf :: SHA3_256 -> DataType
toConstr :: SHA3_256 -> Constr
$ctoConstr :: SHA3_256 -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_256 -> 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
$cp1Data :: Typeable 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
showList :: [SHA3_384] -> ShowS
$cshowList :: [SHA3_384] -> ShowS
show :: SHA3_384 -> String
$cshow :: SHA3_384 -> String
showsPrec :: Int -> SHA3_384 -> ShowS
$cshowsPrec :: Int -> SHA3_384 -> ShowS
Show,Typeable SHA3_384
DataType
Constr
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 -> DataType
SHA3_384 -> Constr
(forall b. Data b => b -> b) -> SHA3_384 -> SHA3_384
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_384 -> c SHA3_384
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSHA3_384 :: Constr
$tSHA3_384 :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> SHA3_384 -> m SHA3_384
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SHA3_384 -> m SHA3_384
gmapQi :: Int -> (forall d. Data d => d -> u) -> SHA3_384 -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA3_384 -> u
gmapQ :: (forall d. Data d => d -> u) -> SHA3_384 -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA3_384 -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_384 -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_384 -> r
gmapT :: (forall b. Data b => b -> b) -> SHA3_384 -> SHA3_384
$cgmapT :: (forall b. Data b => b -> b) -> SHA3_384 -> SHA3_384
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> 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)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SHA3_384)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA3_384)
dataTypeOf :: SHA3_384 -> DataType
$cdataTypeOf :: SHA3_384 -> DataType
toConstr :: SHA3_384 -> Constr
$ctoConstr :: SHA3_384 -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_384 -> 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
$cp1Data :: Typeable 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
showList :: [SHA3_512] -> ShowS
$cshowList :: [SHA3_512] -> ShowS
show :: SHA3_512 -> String
$cshow :: SHA3_512 -> String
showsPrec :: Int -> SHA3_512 -> ShowS
$cshowsPrec :: Int -> SHA3_512 -> ShowS
Show,Typeable SHA3_512
DataType
Constr
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 -> DataType
SHA3_512 -> Constr
(forall b. Data b => b -> b) -> SHA3_512 -> SHA3_512
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_512 -> c SHA3_512
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSHA3_512 :: Constr
$tSHA3_512 :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> SHA3_512 -> m SHA3_512
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SHA3_512 -> m SHA3_512
gmapQi :: Int -> (forall d. Data d => d -> u) -> SHA3_512 -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA3_512 -> u
gmapQ :: (forall d. Data d => d -> u) -> SHA3_512 -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA3_512 -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_512 -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SHA3_512 -> r
gmapT :: (forall b. Data b => b -> b) -> SHA3_512 -> SHA3_512
$cgmapT :: (forall b. Data b => b -> b) -> SHA3_512 -> SHA3_512
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> 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)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SHA3_512)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA3_512)
dataTypeOf :: SHA3_512 -> DataType
$cdataTypeOf :: SHA3_512 -> DataType
toConstr :: SHA3_512 -> Constr
$ctoConstr :: SHA3_512 -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA3_512 -> 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
$cp1Data :: Typeable 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 "cryptonite_sha3_init"
    c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()

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

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