Add support for blake2s(p) 224 bits

This commit is contained in:
Vincent Hanquez 2016-01-09 10:09:35 +00:00
parent 08edce4ec7
commit 50631d3150
4 changed files with 30 additions and 4 deletions

View File

@ -11,6 +11,8 @@
module Crypto.Hash.Algorithms
( HashAlgorithm
-- * hash algorithms
, Blake2s_224(..)
, Blake2sp_224(..)
, Blake2s_256(..)
, Blake2sp_256(..)
, Blake2b_512(..)

View File

@ -10,7 +10,7 @@
--
{-# LANGUAGE ForeignFunctionInterface #-}
module Crypto.Hash.Blake2s
( Blake2s_256 (..)
( Blake2s_224 (..), Blake2s_256 (..)
) where
import Crypto.Hash.Types
@ -18,6 +18,18 @@ import Foreign.Ptr (Ptr)
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
data Blake2s_256 = Blake2s_256
deriving (Show)

View File

@ -10,7 +10,7 @@
--
{-# LANGUAGE ForeignFunctionInterface #-}
module Crypto.Hash.Blake2sp
( Blake2sp_256 (..)
( Blake2sp_224 (..), Blake2sp_256 (..)
) where
import Crypto.Hash.Types
@ -18,6 +18,18 @@ import Foreign.Ptr (Ptr)
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
data Blake2sp_256 = Blake2sp_256
deriving (Show)

View File

@ -53,8 +53,8 @@ data HashCustom =
hashModules =
-- module header hash ctx dg blk
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 185 (HashMulti [(256,64)])
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [(256,64)])
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 185 (HashMulti [(224,64), (256,64)])
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [(224,64), (256,64)])
, GenHashModule "Blake2b" "blake2.h" "blake2b" 361 (HashMulti [(512,128)])
, GenHashModule "Blake2bp" "blake2.h" "blake2sp" 2325 (HashMulti [(512,128)])
, GenHashModule "MD2" "md2.h" "md2" 96 (HashSimple 128 16)