{-# LINE 1 "src/Crypto/Hash/BLAKE2/BLAKE2b.hsc" #-}
module Crypto.Hash.BLAKE2.BLAKE2b
(
BLAKE2bState,
initialize,
initialize',
update,
finalize,
hash
) where
import Data.ByteString (ByteString)
import Foreign.C.Types (CInt(..), CSize(..))
import Foreign.ForeignPtr (ForeignPtr)
import Foreign.Storable (Storable(..))
import Crypto.Hash.BLAKE2.Internal
data BLAKE2bStruct
instance Storable BLAKE2bStruct where
sizeOf :: BLAKE2bStruct -> Int
sizeOf BLAKE2bStruct
_ = (Int
248)
{-# LINE 32 "src/Crypto/Hash/BLAKE2/BLAKE2b.hsc" #-}
alignment _ = 8
{-# LINE 33 "src/Crypto/Hash/BLAKE2/BLAKE2b.hsc" #-}
peek = error "peek not implemented"
poke :: Ptr BLAKE2bStruct -> BLAKE2bStruct -> IO ()
poke = forall a. HasCallStack => [Char] -> a
error [Char]
"poke not implemented"
type BLAKE2bState = ForeignPtr BLAKE2bStruct
initialize :: Int
-> BLAKE2bState
initialize :: Int -> BLAKE2bState
initialize = forall a. Storable a => InitFunc a -> Int -> ForeignPtr a
initializer InitFunc BLAKE2bStruct
c_blake2b_init
{-# INLINE initialize #-}
initialize' :: Int
-> ByteString
-> BLAKE2bState
initialize' :: Int -> ByteString -> BLAKE2bState
initialize' = forall a.
Storable a =>
InitKeyFunc a -> Int -> ByteString -> ForeignPtr a
initializer' InitKeyFunc BLAKE2bStruct
c_blake2b_init_key
{-# INLINE initialize' #-}
update :: ByteString
-> BLAKE2bState
-> BLAKE2bState
update :: ByteString -> BLAKE2bState -> BLAKE2bState
update = forall a.
Storable a =>
UpdateFunc a -> ByteString -> ForeignPtr a -> ForeignPtr a
updater UpdateFunc BLAKE2bStruct
c_blake2b_update
{-# INLINE update #-}
finalize :: Int
-> BLAKE2bState
-> ByteString
finalize :: Int -> BLAKE2bState -> ByteString
finalize = forall a.
Storable a =>
FinalFunc a -> Int -> ForeignPtr a -> ByteString
finalizer UpdateFunc BLAKE2bStruct
c_blake2b_final
{-# INLINE finalize #-}
hash :: Int
-> ByteString
-> ByteString
-> ByteString
hash :: Int -> ByteString -> ByteString -> ByteString
hash = HashFunc -> Int -> ByteString -> ByteString -> ByteString
hasher HashFunc
c_blake2b
{-# INLINE hash #-}
foreign import ccall unsafe "blake2.h blake2b"
c_blake2b :: HashFunc
foreign import ccall unsafe "blake2.h blake2b_init"
c_blake2b_init :: InitFunc BLAKE2bStruct
foreign import ccall unsafe "blake2.h blake2b_init_key"
c_blake2b_init_key :: InitKeyFunc BLAKE2bStruct
foreign import ccall unsafe "blake2.h blake2b_update"
c_blake2b_update :: UpdateFunc BLAKE2bStruct
foreign import ccall unsafe "blake2.h blake2b_final"
c_blake2b_final :: FinalFunc BLAKE2bStruct