use more Internal.Compat to get UnsafeDoIO
This commit is contained in:
parent
f43d340fd2
commit
57aa7ce098
@ -59,7 +59,7 @@ 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"
|
||||
| otherwise = unsafePerformIO $ do
|
||||
| otherwise = unsafeDoIO $ do
|
||||
stPtr <- createSecureMem 64 $ \stPtr ->
|
||||
withBytePtr nonce $ \noncePtr ->
|
||||
withBytePtr key $ \keyPtr ->
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{-# LANGUAGE ForeignFunctionInterface, CPP #-}
|
||||
{-# LANGUAGE ForeignFunctionInterface #-}
|
||||
-- |
|
||||
-- Module : Crypto.Cipher.RC4
|
||||
-- License : BSD-style
|
||||
@ -25,18 +25,12 @@ import Data.Byteable
|
||||
import Data.SecureMem
|
||||
import Foreign.Ptr
|
||||
import Foreign.ForeignPtr
|
||||
import System.IO.Unsafe
|
||||
import Data.ByteString (ByteString)
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Internal as B
|
||||
|
||||
----------------------------------------------------------------------
|
||||
unsafeDoIO :: IO a -> a
|
||||
#if __GLASGOW_HASKELL__ > 704
|
||||
unsafeDoIO = unsafeDupablePerformIO
|
||||
#else
|
||||
unsafeDoIO = unsafePerformIO
|
||||
#endif
|
||||
import Crypto.Internal.Compat
|
||||
|
||||
-- | The encryption state for RC4
|
||||
newtype State = State SecureMem
|
||||
|
||||
@ -18,6 +18,7 @@ import Data.SecureMem
|
||||
import Data.ByteString (ByteString)
|
||||
import qualified Data.ByteString.Internal as B
|
||||
import qualified Data.ByteString as B
|
||||
import Crypto.Internal.Compat
|
||||
import Data.Byteable
|
||||
import Data.Word
|
||||
import Data.Bits (xor)
|
||||
@ -50,7 +51,7 @@ 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"
|
||||
| otherwise = unsafePerformIO $ do
|
||||
| otherwise = unsafeDoIO $ do
|
||||
stPtr <- createSecureMem 64 $ \stPtr ->
|
||||
withBytePtr nonce $ \noncePtr ->
|
||||
withBytePtr key $ \keyPtr ->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user