diff --git a/Crypto/Hash/Algorithms.hs b/Crypto/Hash/Algorithms.hs index 36a4e23..d34fd34 100644 --- a/Crypto/Hash/Algorithms.hs +++ b/Crypto/Hash/Algorithms.hs @@ -11,6 +11,8 @@ module Crypto.Hash.Algorithms ( HashAlgorithm -- * hash algorithms + , Blake2s_224(..) + , Blake2sp_224(..) , Blake2s_256(..) , Blake2sp_256(..) , Blake2b_512(..) diff --git a/Crypto/Hash/Blake2s.hs b/Crypto/Hash/Blake2s.hs index 21e97e2..d5c45f7 100644 --- a/Crypto/Hash/Blake2s.hs +++ b/Crypto/Hash/Blake2s.hs @@ -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) diff --git a/Crypto/Hash/Blake2sp.hs b/Crypto/Hash/Blake2sp.hs index 4dd04d6..a7f54c8 100644 --- a/Crypto/Hash/Blake2sp.hs +++ b/Crypto/Hash/Blake2sp.hs @@ -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) diff --git a/gen/Gen.hs b/gen/Gen.hs index c5d681d..1d8a8b2 100644 --- a/gen/Gen.hs +++ b/gen/Gen.hs @@ -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)