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

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

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

instance HashAlgorithm SHA384 where
    type HashBlockSize           SHA384 = 128
    type HashDigestSize          SHA384 = 48
    type HashInternalContextSize SHA384 = 256
    hashBlockSize :: SHA384 -> Int
hashBlockSize  SHA384
_          = Int
128
    hashDigestSize :: SHA384 -> Int
hashDigestSize SHA384
_          = Int
48
    hashInternalContextSize :: SHA384 -> Int
hashInternalContextSize SHA384
_ = Int
256
    hashInternalInit :: Ptr (Context SHA384) -> IO ()
hashInternalInit          = forall a. Ptr (Context a) -> IO ()
c_sha384_init
    hashInternalUpdate :: Ptr (Context SHA384) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_sha384_update
    hashInternalFinalize :: Ptr (Context SHA384) -> Ptr (Digest SHA384) -> IO ()
hashInternalFinalize      = forall a. Ptr (Context a) -> Ptr (Digest a) -> IO ()
c_sha384_finalize

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

foreign import ccall unsafe "cryptonite_sha384_init"
    c_sha384_init :: Ptr (Context a)-> IO ()

foreign import ccall "cryptonite_sha384_update"
    c_sha384_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()

foreign import ccall unsafe "cryptonite_sha384_finalize"
    c_sha384_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()

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