From 775855994cb5d0b5fcaa1dd04500f98f054c1ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Ch=C3=A9ron?= Date: Sun, 15 Mar 2020 15:44:35 +0100 Subject: [PATCH] Use notElem --- Crypto/Cipher/ChaCha.hs | 6 +++--- Crypto/Cipher/Salsa.hs | 6 +++--- Crypto/Cipher/XSalsa.hs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Crypto/Cipher/ChaCha.hs b/Crypto/Cipher/ChaCha.hs index 4dd70ad..8d9c638 100644 --- a/Crypto/Cipher/ChaCha.hs +++ b/Crypto/Cipher/ChaCha.hs @@ -41,9 +41,9 @@ initialize :: (ByteArrayAccess key, ByteArrayAccess nonce) -> nonce -- ^ the nonce (64 or 96 bits) -> State -- ^ the initial ChaCha state initialize nbRounds key nonce - | not (kLen `elem` [16,32]) = error "ChaCha: key length should be 128 or 256 bits" - | not (nonceLen `elem` [8,12]) = error "ChaCha: nonce length should be 64 or 96 bits" - | not (nbRounds `elem` [8,12,20]) = error "ChaCha: rounds should be 8, 12 or 20" + | kLen `notElem` [16,32] = error "ChaCha: key length should be 128 or 256 bits" + | nonceLen `notElem` [8,12] = error "ChaCha: nonce length should be 64 or 96 bits" + | nbRounds `notElem` [8,12,20] = error "ChaCha: rounds should be 8, 12 or 20" | otherwise = unsafeDoIO $ do stPtr <- B.alloc 132 $ \stPtr -> B.withByteArray nonce $ \noncePtr -> diff --git a/Crypto/Cipher/Salsa.hs b/Crypto/Cipher/Salsa.hs index 7d05e6c..34cd7b7 100644 --- a/Crypto/Cipher/Salsa.hs +++ b/Crypto/Cipher/Salsa.hs @@ -33,9 +33,9 @@ initialize :: (ByteArrayAccess key, ByteArrayAccess nonce) -> nonce -- ^ the nonce (64 or 96 bits) -> State -- ^ the initial Salsa state initialize nbRounds key nonce - | not (kLen `elem` [16,32]) = error "Salsa: key length should be 128 or 256 bits" - | not (nonceLen `elem` [8,12]) = error "Salsa: nonce length should be 64 or 96 bits" - | not (nbRounds `elem` [8,12,20]) = error "Salsa: rounds should be 8, 12 or 20" + | kLen `notElem` [16,32] = error "Salsa: key length should be 128 or 256 bits" + | nonceLen `notElem` [8,12] = error "Salsa: nonce length should be 64 or 96 bits" + | nbRounds `notElem` [8,12,20] = error "Salsa: rounds should be 8, 12 or 20" | otherwise = unsafeDoIO $ do stPtr <- B.alloc 132 $ \stPtr -> B.withByteArray nonce $ \noncePtr -> diff --git a/Crypto/Cipher/XSalsa.hs b/Crypto/Cipher/XSalsa.hs index 1510597..0353aa2 100644 --- a/Crypto/Cipher/XSalsa.hs +++ b/Crypto/Cipher/XSalsa.hs @@ -35,7 +35,7 @@ initialize :: (ByteArrayAccess key, ByteArrayAccess nonce) initialize nbRounds key nonce | kLen /= 32 = error "XSalsa: key length should be 256 bits" | nonceLen /= 24 = error "XSalsa: nonce length should be 192 bits" - | not (nbRounds `elem` [8,12,20]) = error "XSalsa: rounds should be 8, 12 or 20" + | nbRounds `notElem` [8,12,20] = error "XSalsa: rounds should be 8, 12 or 20" | otherwise = unsafeDoIO $ do stPtr <- B.alloc 132 $ \stPtr -> B.withByteArray nonce $ \noncePtr ->