-- |
-- 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
(Int -> SHA384 -> ShowS)
-> (SHA384 -> String) -> ([SHA384] -> ShowS) -> Show SHA384
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SHA384 -> ShowS
showsPrec :: Int -> SHA384 -> ShowS
$cshow :: SHA384 -> String
show :: SHA384 -> String
$cshowList :: [SHA384] -> ShowS
showList :: [SHA384] -> ShowS
Show,Typeable SHA384
Typeable SHA384 =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> SHA384 -> c SHA384)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SHA384)
-> (SHA384 -> Constr)
-> (SHA384 -> DataType)
-> (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))
-> ((forall b. Data b => b -> b) -> SHA384 -> SHA384)
-> (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 u. (forall d. Data d => d -> u) -> SHA384 -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SHA384 -> u)
-> (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 (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SHA384 -> m SHA384)
-> Data SHA384
SHA384 -> Constr
SHA384 -> DataType
(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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA384 -> c SHA384
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SHA384 -> c SHA384
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SHA384
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SHA384
$ctoConstr :: SHA384 -> Constr
toConstr :: SHA384 -> Constr
$cdataTypeOf :: SHA384 -> DataType
dataTypeOf :: SHA384 -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA384)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SHA384)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA384)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA384)
$cgmapT :: (forall b. Data b => b -> b) -> SHA384 -> SHA384
gmapT :: (forall b. Data b => b -> b) -> SHA384 -> SHA384
$cgmapQl :: 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
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA384 -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA384 -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SHA384 -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> SHA384 -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA384 -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SHA384 -> u
$cgmapM :: forall (m :: * -> *).
Monad 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
$cgmapMp :: 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
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SHA384 -> m SHA384
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SHA384 -> m 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          = Ptr (Context SHA384) -> IO ()
forall a. Ptr (Context a) -> IO ()
c_sha384_init
    hashInternalUpdate :: Ptr (Context SHA384) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = Ptr (Context SHA384) -> Ptr Word8 -> Word32 -> IO ()
forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_sha384_update
    hashInternalFinalize :: Ptr (Context SHA384) -> Ptr (Digest SHA384) -> IO ()
hashInternalFinalize      = Ptr (Context SHA384) -> Ptr (Digest SHA384) -> IO ()
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 = Ptr (Context SHA384)
-> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest SHA384) -> IO ()
forall a.
Ptr (Context a)
-> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
c_sha384_finalize_prefix

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

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

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

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