packages feed

cipher-rc4 0.1.1 → 0.1.2

raw patch · 2 files changed

+14/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Crypto/Cipher/RC4.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE ForeignFunctionInterface, CPP #-} -- | -- Module      : Crypto.Cipher.RC4 -- License     : BSD-style@@ -6,6 +6,9 @@ -- Stability   : stable -- Portability : Good --+-- Simple implementation of the RC4 stream cipher.+-- http://en.wikipedia.org/wiki/RC4+-- -- Initial FFI implementation by Peter White <peter@janrain.com> -- -- Reorganized and simplified to have an opaque context.@@ -22,13 +25,19 @@ import Data.Word import Foreign.Ptr import Foreign.ForeignPtr-import System.IO.Unsafe (unsafeDupablePerformIO)+import System.IO.Unsafe import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Internal as B import Control.Applicative ((<$>))  ----------------------------------------------------------------------+unsafeDoIO :: IO a -> a+#if __GLASGOW_HASKELL__ > 704+unsafeDoIO = unsafeDupablePerformIO+#else+unsafeDoIO = unsafePerformIO+#endif  -- | The encryption context for RC4 newtype Ctx = Ctx B.ByteString@@ -60,7 +69,7 @@ -- adequate otherwise security takes a hit. initCtx :: B.ByteString -- ^ The key         -> Ctx          -- ^ The RC4 context with the key mixed in-initCtx key = unsafeDupablePerformIO $+initCtx key = unsafeDoIO $     Ctx <$> (B.create 264 $ \ctx -> B.useAsCStringLen key $ \(keyPtr,keyLen) -> c_rc4_init (castPtr keyPtr) (fromIntegral keyLen) (castPtr ctx))  -- | generate the next len bytes of the rc4 stream without combining@@ -72,7 +81,7 @@ combine :: Ctx                 -- ^ rc4 context         -> B.ByteString        -- ^ input         -> (Ctx, B.ByteString) -- ^ new rc4 context, and the output-combine (Ctx cctx) clearText = unsafeDupablePerformIO $+combine (Ctx cctx) clearText = unsafeDoIO $     B.mallocByteString 264 >>= \dctx ->     B.mallocByteString len >>= \outfptr ->     withByteStringPtr clearText $ \clearPtr ->
cipher-rc4.cabal view
@@ -1,5 +1,5 @@ Name:                cipher-rc4-Version:             0.1.1+Version:             0.1.2 Description:         Fast RC4 cipher implementation License:             BSD3 License-file:        LICENSE