module Crypto.Hash.Blake2b
( Blake2b_160 (..), Blake2b_224 (..), Blake2b_256 (..), Blake2b_384 (..), Blake2b_512 (..)
) where
import Crypto.Hash.Types
import Foreign.Ptr (Ptr)
import Data.Data
import Data.Typeable
import Data.Word (Word8, Word32)
data Blake2b_160 = Blake2b_160
deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_160 where
hashBlockSize _ = 128
hashDigestSize _ = 20
hashInternalContextSize _ = 361
hashInternalInit p = c_blake2b_init p 160
hashInternalUpdate = c_blake2b_update
hashInternalFinalize p = c_blake2b_finalize p 160
data Blake2b_224 = Blake2b_224
deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_224 where
hashBlockSize _ = 128
hashDigestSize _ = 28
hashInternalContextSize _ = 361
hashInternalInit p = c_blake2b_init p 224
hashInternalUpdate = c_blake2b_update
hashInternalFinalize p = c_blake2b_finalize p 224
data Blake2b_256 = Blake2b_256
deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_256 where
hashBlockSize _ = 128
hashDigestSize _ = 32
hashInternalContextSize _ = 361
hashInternalInit p = c_blake2b_init p 256
hashInternalUpdate = c_blake2b_update
hashInternalFinalize p = c_blake2b_finalize p 256
data Blake2b_384 = Blake2b_384
deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_384 where
hashBlockSize _ = 128
hashDigestSize _ = 48
hashInternalContextSize _ = 361
hashInternalInit p = c_blake2b_init p 384
hashInternalUpdate = c_blake2b_update
hashInternalFinalize p = c_blake2b_finalize p 384
data Blake2b_512 = Blake2b_512
deriving (Show,Data,Typeable)
instance HashAlgorithm Blake2b_512 where
hashBlockSize _ = 128
hashDigestSize _ = 64
hashInternalContextSize _ = 361
hashInternalInit p = c_blake2b_init p 512
hashInternalUpdate = c_blake2b_update
hashInternalFinalize p = c_blake2b_finalize p 512
foreign import ccall unsafe "cryptonite_blake2b_init"
c_blake2b_init :: Ptr (Context a) -> Word32 -> IO ()
foreign import ccall "cryptonite_blake2b_update"
c_blake2b_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
foreign import ccall unsafe "cryptonite_blake2b_finalize"
c_blake2b_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()