Add support for blake2s(p) 224 bits
This commit is contained in:
parent
08edce4ec7
commit
50631d3150
@ -11,6 +11,8 @@
|
|||||||
module Crypto.Hash.Algorithms
|
module Crypto.Hash.Algorithms
|
||||||
( HashAlgorithm
|
( HashAlgorithm
|
||||||
-- * hash algorithms
|
-- * hash algorithms
|
||||||
|
, Blake2s_224(..)
|
||||||
|
, Blake2sp_224(..)
|
||||||
, Blake2s_256(..)
|
, Blake2s_256(..)
|
||||||
, Blake2sp_256(..)
|
, Blake2sp_256(..)
|
||||||
, Blake2b_512(..)
|
, Blake2b_512(..)
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
--
|
--
|
||||||
{-# LANGUAGE ForeignFunctionInterface #-}
|
{-# LANGUAGE ForeignFunctionInterface #-}
|
||||||
module Crypto.Hash.Blake2s
|
module Crypto.Hash.Blake2s
|
||||||
( Blake2s_256 (..)
|
( Blake2s_224 (..), Blake2s_256 (..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Crypto.Hash.Types
|
import Crypto.Hash.Types
|
||||||
@ -18,6 +18,18 @@ import Foreign.Ptr (Ptr)
|
|||||||
import Data.Word (Word8, Word32)
|
import Data.Word (Word8, Word32)
|
||||||
|
|
||||||
|
|
||||||
|
-- | Blake2s (224 bits) cryptographic hash algorithm
|
||||||
|
data Blake2s_224 = Blake2s_224
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
instance HashAlgorithm Blake2s_224 where
|
||||||
|
hashBlockSize _ = 64
|
||||||
|
hashDigestSize _ = 28
|
||||||
|
hashInternalContextSize _ = 185
|
||||||
|
hashInternalInit p = c_blake2s_init p 224
|
||||||
|
hashInternalUpdate = c_blake2s_update
|
||||||
|
hashInternalFinalize p = c_blake2s_finalize p 224
|
||||||
|
|
||||||
-- | Blake2s (256 bits) cryptographic hash algorithm
|
-- | Blake2s (256 bits) cryptographic hash algorithm
|
||||||
data Blake2s_256 = Blake2s_256
|
data Blake2s_256 = Blake2s_256
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
--
|
--
|
||||||
{-# LANGUAGE ForeignFunctionInterface #-}
|
{-# LANGUAGE ForeignFunctionInterface #-}
|
||||||
module Crypto.Hash.Blake2sp
|
module Crypto.Hash.Blake2sp
|
||||||
( Blake2sp_256 (..)
|
( Blake2sp_224 (..), Blake2sp_256 (..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Crypto.Hash.Types
|
import Crypto.Hash.Types
|
||||||
@ -18,6 +18,18 @@ import Foreign.Ptr (Ptr)
|
|||||||
import Data.Word (Word8, Word32)
|
import Data.Word (Word8, Word32)
|
||||||
|
|
||||||
|
|
||||||
|
-- | Blake2sp (224 bits) cryptographic hash algorithm
|
||||||
|
data Blake2sp_224 = Blake2sp_224
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
instance HashAlgorithm Blake2sp_224 where
|
||||||
|
hashBlockSize _ = 64
|
||||||
|
hashDigestSize _ = 28
|
||||||
|
hashInternalContextSize _ = 2185
|
||||||
|
hashInternalInit p = c_blake2sp_init p 224
|
||||||
|
hashInternalUpdate = c_blake2sp_update
|
||||||
|
hashInternalFinalize p = c_blake2sp_finalize p 224
|
||||||
|
|
||||||
-- | Blake2sp (256 bits) cryptographic hash algorithm
|
-- | Blake2sp (256 bits) cryptographic hash algorithm
|
||||||
data Blake2sp_256 = Blake2sp_256
|
data Blake2sp_256 = Blake2sp_256
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|||||||
@ -53,8 +53,8 @@ data HashCustom =
|
|||||||
|
|
||||||
hashModules =
|
hashModules =
|
||||||
-- module header hash ctx dg blk
|
-- module header hash ctx dg blk
|
||||||
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 185 (HashMulti [(256,64)])
|
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 185 (HashMulti [(224,64), (256,64)])
|
||||||
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [(256,64)])
|
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [(224,64), (256,64)])
|
||||||
, GenHashModule "Blake2b" "blake2.h" "blake2b" 361 (HashMulti [(512,128)])
|
, GenHashModule "Blake2b" "blake2.h" "blake2b" 361 (HashMulti [(512,128)])
|
||||||
, GenHashModule "Blake2bp" "blake2.h" "blake2sp" 2325 (HashMulti [(512,128)])
|
, GenHashModule "Blake2bp" "blake2.h" "blake2sp" 2325 (HashMulti [(512,128)])
|
||||||
, GenHashModule "MD2" "md2.h" "md2" 96 (HashSimple 128 16)
|
, GenHashModule "MD2" "md2.h" "md2" 96 (HashSimple 128 16)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user