Merge pull request #195 from haskell-crypto/blake2-update-context-size
Blake2 update context size
This commit is contained in:
commit
b3f6786d08
@ -65,10 +65,10 @@ instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost b
|
||||
where
|
||||
type HashBlockSize (Blake2s bitlen) = 64
|
||||
type HashDigestSize (Blake2s bitlen) = Div8 bitlen
|
||||
type HashInternalContextSize (Blake2s bitlen) = 185
|
||||
type HashInternalContextSize (Blake2s bitlen) = 136
|
||||
hashBlockSize _ = 64
|
||||
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
|
||||
hashInternalContextSize _ = 185
|
||||
hashInternalContextSize _ = 136
|
||||
hashInternalInit p = c_blake2s_init p (integralNatVal (Proxy :: Proxy bitlen))
|
||||
hashInternalUpdate = c_blake2s_update
|
||||
hashInternalFinalize p = c_blake2s_finalize p (integralNatVal (Proxy :: Proxy bitlen))
|
||||
@ -100,10 +100,10 @@ instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost b
|
||||
where
|
||||
type HashBlockSize (Blake2b bitlen) = 128
|
||||
type HashDigestSize (Blake2b bitlen) = Div8 bitlen
|
||||
type HashInternalContextSize (Blake2b bitlen) = 361
|
||||
type HashInternalContextSize (Blake2b bitlen) = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p (integralNatVal (Proxy :: Proxy bitlen))
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p (integralNatVal (Proxy :: Proxy bitlen))
|
||||
|
||||
@ -30,10 +30,10 @@ data Blake2b_160 = Blake2b_160
|
||||
instance HashAlgorithm Blake2b_160 where
|
||||
type HashBlockSize Blake2b_160 = 128
|
||||
type HashDigestSize Blake2b_160 = 20
|
||||
type HashInternalContextSize Blake2b_160 = 361
|
||||
type HashInternalContextSize Blake2b_160 = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = 20
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p 160
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p 160
|
||||
@ -45,10 +45,10 @@ data Blake2b_224 = Blake2b_224
|
||||
instance HashAlgorithm Blake2b_224 where
|
||||
type HashBlockSize Blake2b_224 = 128
|
||||
type HashDigestSize Blake2b_224 = 28
|
||||
type HashInternalContextSize Blake2b_224 = 361
|
||||
type HashInternalContextSize Blake2b_224 = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = 28
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p 224
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p 224
|
||||
@ -60,10 +60,10 @@ data Blake2b_256 = Blake2b_256
|
||||
instance HashAlgorithm Blake2b_256 where
|
||||
type HashBlockSize Blake2b_256 = 128
|
||||
type HashDigestSize Blake2b_256 = 32
|
||||
type HashInternalContextSize Blake2b_256 = 361
|
||||
type HashInternalContextSize Blake2b_256 = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = 32
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p 256
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p 256
|
||||
@ -75,10 +75,10 @@ data Blake2b_384 = Blake2b_384
|
||||
instance HashAlgorithm Blake2b_384 where
|
||||
type HashBlockSize Blake2b_384 = 128
|
||||
type HashDigestSize Blake2b_384 = 48
|
||||
type HashInternalContextSize Blake2b_384 = 361
|
||||
type HashInternalContextSize Blake2b_384 = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = 48
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p 384
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p 384
|
||||
@ -90,10 +90,10 @@ data Blake2b_512 = Blake2b_512
|
||||
instance HashAlgorithm Blake2b_512 where
|
||||
type HashBlockSize Blake2b_512 = 128
|
||||
type HashDigestSize Blake2b_512 = 64
|
||||
type HashInternalContextSize Blake2b_512 = 361
|
||||
type HashInternalContextSize Blake2b_512 = 248
|
||||
hashBlockSize _ = 128
|
||||
hashDigestSize _ = 64
|
||||
hashInternalContextSize _ = 361
|
||||
hashInternalContextSize _ = 248
|
||||
hashInternalInit p = c_blake2b_init p 512
|
||||
hashInternalUpdate = c_blake2b_update
|
||||
hashInternalFinalize p = c_blake2b_finalize p 512
|
||||
|
||||
@ -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 ()
|
||||
|
||||
@ -30,10 +30,10 @@ data Blake2s_160 = Blake2s_160
|
||||
instance HashAlgorithm Blake2s_160 where
|
||||
type HashBlockSize Blake2s_160 = 64
|
||||
type HashDigestSize Blake2s_160 = 20
|
||||
type HashInternalContextSize Blake2s_160 = 185
|
||||
type HashInternalContextSize Blake2s_160 = 136
|
||||
hashBlockSize _ = 64
|
||||
hashDigestSize _ = 20
|
||||
hashInternalContextSize _ = 185
|
||||
hashInternalContextSize _ = 136
|
||||
hashInternalInit p = c_blake2s_init p 160
|
||||
hashInternalUpdate = c_blake2s_update
|
||||
hashInternalFinalize p = c_blake2s_finalize p 160
|
||||
@ -45,10 +45,10 @@ data Blake2s_224 = Blake2s_224
|
||||
instance HashAlgorithm Blake2s_224 where
|
||||
type HashBlockSize Blake2s_224 = 64
|
||||
type HashDigestSize Blake2s_224 = 28
|
||||
type HashInternalContextSize Blake2s_224 = 185
|
||||
type HashInternalContextSize Blake2s_224 = 136
|
||||
hashBlockSize _ = 64
|
||||
hashDigestSize _ = 28
|
||||
hashInternalContextSize _ = 185
|
||||
hashInternalContextSize _ = 136
|
||||
hashInternalInit p = c_blake2s_init p 224
|
||||
hashInternalUpdate = c_blake2s_update
|
||||
hashInternalFinalize p = c_blake2s_finalize p 224
|
||||
@ -60,10 +60,10 @@ data Blake2s_256 = Blake2s_256
|
||||
instance HashAlgorithm Blake2s_256 where
|
||||
type HashBlockSize Blake2s_256 = 64
|
||||
type HashDigestSize Blake2s_256 = 32
|
||||
type HashInternalContextSize Blake2s_256 = 185
|
||||
type HashInternalContextSize Blake2s_256 = 136
|
||||
hashBlockSize _ = 64
|
||||
hashDigestSize _ = 32
|
||||
hashInternalContextSize _ = 185
|
||||
hashInternalContextSize _ = 136
|
||||
hashInternalInit p = c_blake2s_init p 256
|
||||
hashInternalUpdate = c_blake2s_update
|
||||
hashInternalFinalize p = c_blake2s_finalize p 256
|
||||
|
||||
@ -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
|
||||
|
||||
@ -58,10 +58,10 @@ data HashCustom =
|
||||
|
||||
hashModules =
|
||||
-- module header hash ctx dg blk
|
||||
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 185 (HashMulti [] [(160, 64), (224,64), (256,64)])
|
||||
, GenHashModule "Blake2sp" "blake2.h" "blake2sp" 2185 (HashMulti [] [(224,64), (256,64)])
|
||||
, GenHashModule "Blake2b" "blake2.h" "blake2b" 361 (HashMulti [] [(160, 128), (224, 128), (256, 128), (384, 128), (512,128)])
|
||||
, GenHashModule "Blake2bp" "blake2.h" "blake2sp" 2325 (HashMulti [] [(512,128)])
|
||||
[ GenHashModule "Blake2s" "blake2.h" "blake2s" 136 (HashMulti [] [(160, 64), (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" "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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user