From f559c7bd9dcc250899b62ce0cbab1b072033e76e Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Fri, 7 Jul 2017 17:31:30 +0100 Subject: [PATCH] [ChaCha] only need ByteArrayAccess for initialization --- Crypto/Cipher/ChaCha.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Crypto/Cipher/ChaCha.hs b/Crypto/Cipher/ChaCha.hs index 3a0f0b6..5e85b7b 100644 --- a/Crypto/Cipher/ChaCha.hs +++ b/Crypto/Cipher/ChaCha.hs @@ -54,11 +54,13 @@ initialize nbRounds key nonce nonceLen = B.length nonce -- | 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 -> StateSimple 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 stPtr <- B.alloc 64 $ \stPtr -> B.withByteArray seed $ \seedPtr ->