Update context size for Blake2bp and Blake2sp

Also fix Blake2bp to not use blake2sp functions
This commit is contained in:
Vincent Hanquez 2017-10-02 21:05:30 +01:00
parent 74f1c1872b
commit 84e96d2fa3
3 changed files with 17 additions and 17 deletions

View File

@ -30,20 +30,20 @@ data Blake2bp_512 = Blake2bp_512
instance HashAlgorithm Blake2bp_512 where
type HashBlockSize Blake2bp_512 = 128
type HashDigestSize Blake2bp_512 = 64
type HashInternalContextSize Blake2bp_512 = 2325
type HashInternalContextSize Blake2bp_512 = 1768
hashBlockSize _ = 128
hashDigestSize _ = 64
hashInternalContextSize _ = 2325
hashInternalInit p = c_blake2sp_init p 512
hashInternalUpdate = c_blake2sp_update
hashInternalFinalize p = c_blake2sp_finalize p 512
hashInternalContextSize _ = 1768
hashInternalInit p = c_blake2bp_init p 512
hashInternalUpdate = c_blake2bp_update
hashInternalFinalize p = c_blake2bp_finalize p 512
foreign import ccall unsafe "cryptonite_blake2sp_init"
c_blake2sp_init :: Ptr (Context a) -> Word32 -> IO ()
foreign import ccall unsafe "cryptonite_blake2bp_init"
c_blake2bp_init :: Ptr (Context a) -> Word32 -> IO ()
foreign import ccall "cryptonite_blake2sp_update"
c_blake2sp_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
foreign import ccall "cryptonite_blake2bp_update"
c_blake2bp_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
foreign import ccall unsafe "cryptonite_blake2sp_finalize"
c_blake2sp_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
foreign import ccall unsafe "cryptonite_blake2bp_finalize"
c_blake2bp_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()

View File

@ -30,10 +30,10 @@ data Blake2sp_224 = Blake2sp_224
instance HashAlgorithm Blake2sp_224 where
type HashBlockSize Blake2sp_224 = 64
type HashDigestSize Blake2sp_224 = 28
type HashInternalContextSize Blake2sp_224 = 2185
type HashInternalContextSize Blake2sp_224 = 1752
hashBlockSize _ = 64
hashDigestSize _ = 28
hashInternalContextSize _ = 2185
hashInternalContextSize _ = 1752
hashInternalInit p = c_blake2sp_init p 224
hashInternalUpdate = c_blake2sp_update
hashInternalFinalize p = c_blake2sp_finalize p 224
@ -45,10 +45,10 @@ data Blake2sp_256 = Blake2sp_256
instance HashAlgorithm Blake2sp_256 where
type HashBlockSize Blake2sp_256 = 64
type HashDigestSize Blake2sp_256 = 32
type HashInternalContextSize Blake2sp_256 = 2185
type HashInternalContextSize Blake2sp_256 = 1752
hashBlockSize _ = 64
hashDigestSize _ = 32
hashInternalContextSize _ = 2185
hashInternalContextSize _ = 1752
hashInternalInit p = c_blake2sp_init p 256
hashInternalUpdate = c_blake2sp_update
hashInternalFinalize p = c_blake2sp_finalize p 256

View File

@ -59,9 +59,9 @@ data HashCustom =
hashModules =
-- module header hash ctx dg blk
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 136 (HashMulti [] [(160, 64), (224,64), (256,64)])
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [] [(224,64), (256,64)])
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 1752 (HashMulti [] [(224,64), (256,64)])
, GenHashModule "Blake2b" "blake2.h" "blake2b" 248 (HashMulti [] [(160, 128), (224, 128), (256, 128), (384, 128), (512,128)])
, GenHashModule "Blake2bp" "blake2.h" "blake2sp" 2325 (HashMulti [] [(512,128)])
, GenHashModule "Blake2bp" "blake2.h" "blake2bp" 1768 (HashMulti [] [(512,128)])
, GenHashModule "MD2" "md2.h" "md2" 96 (HashSimple 128 16)
, GenHashModule "MD4" "md4.h" "md4" 96 (HashSimple 128 64)
, GenHashModule "MD5" "md5.h" "md5" 96 (HashSimple 128 64)