Merge cshakeInit with first cshakeUpdate
This commit is contained in:
parent
14093ac298
commit
8b235612be
@ -38,11 +38,12 @@ import Data.Memory.PtrMethods (memSet)
|
|||||||
|
|
||||||
-- cSHAKE
|
-- cSHAKE
|
||||||
|
|
||||||
cshakeInit :: forall a name string . (HashSHAKE a, ByteArrayAccess name, ByteArrayAccess string)
|
cshakeInit :: forall a name string prefix . (HashSHAKE a, ByteArrayAccess name, ByteArrayAccess string, ByteArrayAccess prefix)
|
||||||
=> name -> string -> H.Context a
|
=> name -> string -> prefix -> H.Context a
|
||||||
cshakeInit n s = H.Context $ B.allocAndFreeze c $ \(ptr :: Ptr (H.Context a)) -> do
|
cshakeInit n s p = H.Context $ B.allocAndFreeze c $ \(ptr :: Ptr (H.Context a)) -> do
|
||||||
hashInternalInit ptr
|
hashInternalInit ptr
|
||||||
B.withByteArray b $ \d -> hashInternalUpdate ptr d (fromIntegral $ B.length b)
|
B.withByteArray b $ \d -> hashInternalUpdate ptr d (fromIntegral $ B.length b)
|
||||||
|
B.withByteArray p $ \d -> hashInternalUpdate ptr d (fromIntegral $ B.length p)
|
||||||
where
|
where
|
||||||
c = hashInternalContextSize (undefined :: a)
|
c = hashInternalContextSize (undefined :: a)
|
||||||
w = hashBlockSize (undefined :: a)
|
w = hashBlockSize (undefined :: a)
|
||||||
@ -91,7 +92,7 @@ newtype Context a = Context (H.Context a)
|
|||||||
-- string and key.
|
-- string and key.
|
||||||
initialize :: forall a string key . (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key)
|
initialize :: forall a string key . (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key)
|
||||||
=> string -> key -> Context a
|
=> string -> key -> Context a
|
||||||
initialize str key = Context $ cshakeUpdate (cshakeInit n str) p
|
initialize str key = Context $ cshakeInit n str p
|
||||||
where
|
where
|
||||||
n = B.pack [75,77,65,67] :: B.Bytes -- "KMAC"
|
n = B.pack [75,77,65,67] :: B.Bytes -- "KMAC"
|
||||||
w = hashBlockSize (undefined :: a)
|
w = hashBlockSize (undefined :: a)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user