[ChaCha] only need ByteArrayAccess for initialization
This commit is contained in:
parent
cb293eb6db
commit
f559c7bd9d
@ -54,11 +54,13 @@ initialize nbRounds key nonce
|
|||||||
nonceLen = B.length nonce
|
nonceLen = B.length nonce
|
||||||
|
|
||||||
-- | Initialize simple ChaCha State
|
-- | Initialize simple ChaCha State
|
||||||
initializeSimple :: ByteArray seed
|
--
|
||||||
|
-- The seed need to be at least 40 bytes long
|
||||||
|
initializeSimple :: ByteArrayAccess seed
|
||||||
=> seed -- ^ a 40 bytes long seed
|
=> seed -- ^ a 40 bytes long seed
|
||||||
-> StateSimple
|
-> StateSimple
|
||||||
initializeSimple seed
|
initializeSimple seed
|
||||||
| sLen /= 40 = error "ChaCha Random: seed length should be 40 bytes"
|
| sLen < 40 = error "ChaCha Random: seed length should be 40 bytes"
|
||||||
| otherwise = unsafeDoIO $ do
|
| otherwise = unsafeDoIO $ do
|
||||||
stPtr <- B.alloc 64 $ \stPtr ->
|
stPtr <- B.alloc 64 $ \stPtr ->
|
||||||
B.withByteArray seed $ \seedPtr ->
|
B.withByteArray seed $ \seedPtr ->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user