-- |
-- Module      : Crypto.Hash.Blake2b
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : unknown
--
-- Module containing the binding functions to work with the
-- Blake2b cryptographic hash.
--
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
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.Word (Word8, Word32)


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

instance HashAlgorithm Blake2b_160 where
    type HashBlockSize           Blake2b_160 = 128
    type HashDigestSize          Blake2b_160 = 20
    type HashInternalContextSize Blake2b_160 = 248
    hashBlockSize :: Blake2b_160 -> Int
hashBlockSize  Blake2b_160
_          = Int
128
    hashDigestSize :: Blake2b_160 -> Int
hashDigestSize Blake2b_160
_          = Int
20
    hashInternalContextSize :: Blake2b_160 -> Int
hashInternalContextSize Blake2b_160
_ = Int
248
    hashInternalInit :: Ptr (Context Blake2b_160) -> IO ()
hashInternalInit Ptr (Context Blake2b_160)
p        = forall a. Ptr (Context a) -> Word32 -> IO ()
c_blake2b_init Ptr (Context Blake2b_160)
p Word32
160
    hashInternalUpdate :: Ptr (Context Blake2b_160) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_blake2b_update
    hashInternalFinalize :: Ptr (Context Blake2b_160) -> Ptr (Digest Blake2b_160) -> IO ()
hashInternalFinalize Ptr (Context Blake2b_160)
p    = forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_blake2b_finalize Ptr (Context Blake2b_160)
p Word32
160

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

instance HashAlgorithm Blake2b_224 where
    type HashBlockSize           Blake2b_224 = 128
    type HashDigestSize          Blake2b_224 = 28
    type HashInternalContextSize Blake2b_224 = 248
    hashBlockSize :: Blake2b_224 -> Int
hashBlockSize  Blake2b_224
_          = Int
128
    hashDigestSize :: Blake2b_224 -> Int
hashDigestSize Blake2b_224
_          = Int
28
    hashInternalContextSize :: Blake2b_224 -> Int
hashInternalContextSize Blake2b_224
_ = Int
248
    hashInternalInit :: Ptr (Context Blake2b_224) -> IO ()
hashInternalInit Ptr (Context Blake2b_224)
p        = forall a. Ptr (Context a) -> Word32 -> IO ()
c_blake2b_init Ptr (Context Blake2b_224)
p Word32
224
    hashInternalUpdate :: Ptr (Context Blake2b_224) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_blake2b_update
    hashInternalFinalize :: Ptr (Context Blake2b_224) -> Ptr (Digest Blake2b_224) -> IO ()
hashInternalFinalize Ptr (Context Blake2b_224)
p    = forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_blake2b_finalize Ptr (Context Blake2b_224)
p Word32
224

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

instance HashAlgorithm Blake2b_256 where
    type HashBlockSize           Blake2b_256 = 128
    type HashDigestSize          Blake2b_256 = 32
    type HashInternalContextSize Blake2b_256 = 248
    hashBlockSize :: Blake2b_256 -> Int
hashBlockSize  Blake2b_256
_          = Int
128
    hashDigestSize :: Blake2b_256 -> Int
hashDigestSize Blake2b_256
_          = Int
32
    hashInternalContextSize :: Blake2b_256 -> Int
hashInternalContextSize Blake2b_256
_ = Int
248
    hashInternalInit :: Ptr (Context Blake2b_256) -> IO ()
hashInternalInit Ptr (Context Blake2b_256)
p        = forall a. Ptr (Context a) -> Word32 -> IO ()
c_blake2b_init Ptr (Context Blake2b_256)
p Word32
256
    hashInternalUpdate :: Ptr (Context Blake2b_256) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_blake2b_update
    hashInternalFinalize :: Ptr (Context Blake2b_256) -> Ptr (Digest Blake2b_256) -> IO ()
hashInternalFinalize Ptr (Context Blake2b_256)
p    = forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_blake2b_finalize Ptr (Context Blake2b_256)
p Word32
256

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

instance HashAlgorithm Blake2b_384 where
    type HashBlockSize           Blake2b_384 = 128
    type HashDigestSize          Blake2b_384 = 48
    type HashInternalContextSize Blake2b_384 = 248
    hashBlockSize :: Blake2b_384 -> Int
hashBlockSize  Blake2b_384
_          = Int
128
    hashDigestSize :: Blake2b_384 -> Int
hashDigestSize Blake2b_384
_          = Int
48
    hashInternalContextSize :: Blake2b_384 -> Int
hashInternalContextSize Blake2b_384
_ = Int
248
    hashInternalInit :: Ptr (Context Blake2b_384) -> IO ()
hashInternalInit Ptr (Context Blake2b_384)
p        = forall a. Ptr (Context a) -> Word32 -> IO ()
c_blake2b_init Ptr (Context Blake2b_384)
p Word32
384
    hashInternalUpdate :: Ptr (Context Blake2b_384) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_blake2b_update
    hashInternalFinalize :: Ptr (Context Blake2b_384) -> Ptr (Digest Blake2b_384) -> IO ()
hashInternalFinalize Ptr (Context Blake2b_384)
p    = forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_blake2b_finalize Ptr (Context Blake2b_384)
p Word32
384

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

instance HashAlgorithm Blake2b_512 where
    type HashBlockSize           Blake2b_512 = 128
    type HashDigestSize          Blake2b_512 = 64
    type HashInternalContextSize Blake2b_512 = 248
    hashBlockSize :: Blake2b_512 -> Int
hashBlockSize  Blake2b_512
_          = Int
128
    hashDigestSize :: Blake2b_512 -> Int
hashDigestSize Blake2b_512
_          = Int
64
    hashInternalContextSize :: Blake2b_512 -> Int
hashInternalContextSize Blake2b_512
_ = Int
248
    hashInternalInit :: Ptr (Context Blake2b_512) -> IO ()
hashInternalInit Ptr (Context Blake2b_512)
p        = forall a. Ptr (Context a) -> Word32 -> IO ()
c_blake2b_init Ptr (Context Blake2b_512)
p Word32
512
    hashInternalUpdate :: Ptr (Context Blake2b_512) -> Ptr Word8 -> Word32 -> IO ()
hashInternalUpdate        = forall a. Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
c_blake2b_update
    hashInternalFinalize :: Ptr (Context Blake2b_512) -> Ptr (Digest Blake2b_512) -> IO ()
hashInternalFinalize Ptr (Context Blake2b_512)
p    = forall a. Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
c_blake2b_finalize Ptr (Context Blake2b_512)
p Word32
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 ()