packages feed

crypto-conduit 0.1.3.1 → 0.2.0

raw patch · 3 files changed

+25/−25 lines, 3 filesdep ~conduitnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: conduit

API changes (from Hackage documentation)

- Crypto.Conduit: blocked :: Resource m => BlockMode -> ByteLength -> Conduit ByteString m Block
+ Crypto.Conduit: blocked :: Monad m => BlockMode -> ByteLength -> Conduit ByteString m Block
- Crypto.Conduit: conduitDecryptCbc :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitDecryptCbc :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitDecryptCfb :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitDecryptCfb :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitDecryptCtr :: (Resource m, BlockCipher k) => k -> IV k -> (IV k -> IV k) -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitDecryptCtr :: (Monad m, BlockCipher k) => k -> IV k -> (IV k -> IV k) -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitDecryptEcb :: (Resource m, BlockCipher k) => k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitDecryptEcb :: (Monad m, BlockCipher k) => k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitDecryptOfb :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitDecryptOfb :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitEncryptCbc :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitEncryptCbc :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitEncryptCfb :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitEncryptCfb :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitEncryptCtr :: (Resource m, BlockCipher k) => k -> IV k -> (IV k -> IV k) -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitEncryptCtr :: (Monad m, BlockCipher k) => k -> IV k -> (IV k -> IV k) -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitEncryptEcb :: (Resource m, BlockCipher k) => k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitEncryptEcb :: (Monad m, BlockCipher k) => k -> Conduit ByteString m ByteString
- Crypto.Conduit: conduitEncryptOfb :: (Resource m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
+ Crypto.Conduit: conduitEncryptOfb :: (Monad m, BlockCipher k) => k -> IV k -> Conduit ByteString m ByteString
- Crypto.Conduit: sinkCbcMac :: (Resource m, BlockCipher k) => k -> Sink ByteString m ByteString
+ Crypto.Conduit: sinkCbcMac :: (Monad m, BlockCipher k) => k -> Sink ByteString m ByteString
- Crypto.Conduit: sinkHash :: (Resource m, Hash ctx d) => Sink ByteString m d
+ Crypto.Conduit: sinkHash :: (Monad m, Hash ctx d) => Sink ByteString m d
- Crypto.Conduit: sinkHmac :: (Resource m, Hash ctx d) => MacKey ctx d -> Sink ByteString m d
+ Crypto.Conduit: sinkHmac :: (Monad m, Hash ctx d) => MacKey ctx d -> Sink ByteString m d
- Crypto.Conduit: sourceCtr :: (Resource m, BlockCipher k) => k -> IV k -> Source m ByteString
+ Crypto.Conduit: sourceCtr :: (Monad m, BlockCipher k) => k -> IV k -> Source m ByteString

Files

crypto-conduit.cabal view
@@ -1,6 +1,6 @@ Cabal-version:       >= 1.8 Name:                crypto-conduit-Version:             0.1.3.1+Version:             0.2.0 Synopsis:            Conduit interface for cryptographic operations (from crypto-api). Homepage:            https://github.com/meteficha/crypto-conduit License:             BSD3@@ -35,7 +35,7 @@     base         >= 3   && < 5,     bytestring   >= 0.9 && < 0.10,     cereal       >= 0.3 && < 0.4,-    conduit      >= 0.2 && < 0.3,+    conduit      >= 0.3 && < 0.4,     transformers == 0.2.*   if flag(old-crypto-api)     Build-depends: crypto-api >= 0.8 && < 0.9
src/Crypto/Conduit.hs view
@@ -39,7 +39,7 @@     ) where  -- from base-import Control.Applicative ((<$>))+import Control.Monad (liftM) import Control.Arrow (first) import Data.Bits (xor) @@ -77,7 +77,7 @@  -- | A 'Sink' that hashes a stream of 'B.ByteString'@s@ and -- creates a digest @d@.-sinkHash :: (Resource m, C.Hash ctx d) => Sink B.ByteString m d+sinkHash :: (Monad m, C.Hash ctx d) => Sink B.ByteString m d sinkHash = blocked AnyMultiple blockSize =$ sink     where       sink = sinkState C.initialCtx@@ -110,7 +110,7 @@  -- | A 'Sink' that computes the HMAC of a stream of -- 'B.ByteString'@s@ and creates a digest @d@.-sinkHmac :: (Resource m, C.Hash ctx d) =>+sinkHmac :: (Monad m, C.Hash ctx d) => #if OLD_CRYPTO_API             C.MacKey #else@@ -156,7 +156,7 @@ -- the block size of the cipher and fails otherwise.  (Note that -- ECB has many undesirable cryptographic properties, please -- avoid it if you don't know what you're doing.)-conduitEncryptEcb :: (Resource m, C.BlockCipher k) =>+conduitEncryptEcb :: (Monad m, C.BlockCipher k) =>                      k -- ^ Cipher key.                   -> Conduit B.ByteString m B.ByteString conduitEncryptEcb k =@@ -170,7 +170,7 @@ -- | A 'Conduit' that decrypts a stream of 'B.ByteString'@s@ -- using ECB mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitDecryptEcb :: (Resource m, C.BlockCipher k) =>+conduitDecryptEcb :: (Monad m, C.BlockCipher k) =>                      k -- ^ Cipher key.                   -> Conduit B.ByteString m B.ByteString conduitDecryptEcb k =@@ -187,7 +187,7 @@ -- | A 'Conduit' that encrypts a stream of 'B.ByteString'@s@ -- using CBC mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitEncryptCbc :: (Resource m, C.BlockCipher k) =>+conduitEncryptCbc :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -203,7 +203,7 @@ -- | A 'Conduit' that decrypts a stream of 'B.ByteString'@s@ -- using CBC mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitDecryptCbc :: (Resource m, C.BlockCipher k) =>+conduitDecryptCbc :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -222,7 +222,7 @@ -- | A 'Conduit' that encrypts a stream of 'B.ByteString'@s@ -- using CFB mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitEncryptCfb :: (Resource m, C.BlockCipher k) =>+conduitEncryptCfb :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -238,7 +238,7 @@ -- | A 'Conduit' that decrypts a stream of 'B.ByteString'@s@ -- using CFB mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitDecryptCfb :: (Resource m, C.BlockCipher k) =>+conduitDecryptCfb :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -257,7 +257,7 @@ -- | A 'Conduit' that encrypts a stream of 'B.ByteString'@s@ -- using OFB mode.  Expects the input length to be a multiple of -- the block size of the cipher and fails otherwise.-conduitEncryptOfb :: (Resource m, C.BlockCipher k) =>+conduitEncryptOfb :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -272,7 +272,7 @@  -- | Synonym for 'conduitEncryptOfb', since for OFB mode both -- encryption and decryption are the same.-conduitDecryptOfb :: (Resource m, C.BlockCipher k) =>+conduitDecryptOfb :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> Conduit B.ByteString m B.ByteString@@ -285,7 +285,7 @@ -- | A 'Conduit' that encrypts a stream of 'B.ByteString'@s@ -- using CTR mode.  The input may have any length, even -- non-multiples of the block size.-conduitEncryptCtr :: (Resource m, C.BlockCipher k) =>+conduitEncryptCtr :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> (C.IV k -> C.IV k) -- ^ Increment counter ('C.incIV' is recommended)@@ -303,7 +303,7 @@  -- | Synonym for 'conduitEncryptCtr', since for CTR mode both -- encryption and decryption are the same.-conduitDecryptCtr :: (Resource m, C.BlockCipher k) =>+conduitDecryptCtr :: (Monad m, C.BlockCipher k) =>                      k      -- ^ Cipher key.                   -> C.IV k -- ^ Initialization vector.                   -> (C.IV k -> C.IV k) -- ^ Increment counter ('C.incIV' is recommended)@@ -313,7 +313,7 @@  -- | An infinite stream of bytes generated by a block cipher on -- CTR mode.-sourceCtr :: (Resource m, C.BlockCipher k) =>+sourceCtr :: (Monad m, C.BlockCipher k) =>              k      -- ^ Cipher key.           -> C.IV k -- ^ Initialization vector.           -> Source m B.ByteString@@ -334,7 +334,7 @@ -- the input length to be a multiple of the block size of the -- cipher and fails otherwise.  (Note that CBC-MAC is not secure -- for variable-length messages.)-sinkCbcMac :: (Resource m, C.BlockCipher k) =>+sinkCbcMac :: (Monad m, C.BlockCipher k) =>               k -- ^ Cipher key.            -> Sink B.ByteString m B.ByteString sinkCbcMac k = blocked StrictBlockSize blockSize =$ sink@@ -363,7 +363,7 @@ -- the 'BlockMode').  All 'Block'@s@ beside the last one will be -- 'Full'.  The last block will always be 'LastOne' with less -- bytes than the block size, possibly zero.-blocked :: Resource m =>+blocked :: Monad m =>            BlockMode         -> C.ByteLength -- ^ Block size         -> Conduit B.ByteString m Block@@ -406,12 +406,12 @@   -- | Constructs a 'Conduit' for a 'BlockCipher'.-blockCipherConduit :: (Resource m, C.BlockCipher k) =>+blockCipherConduit :: (Monad m, C.BlockCipher k) =>                       k -- ^ Cipher key (not used, just for getting block size).                    -> BlockMode                    -> s -- ^ Initial state.                    -> (s -> B.ByteString -> (s, B.ByteString))        -- ^ Encrypt block.-                   -> (s -> B.ByteString -> ResourceT m B.ByteString) -- ^ Final encryption.+                   -> (s -> B.ByteString -> m B.ByteString) -- ^ Final encryption.                    -> Conduit B.ByteString m B.ByteString blockCipherConduit key mode initialState apply final = blocked mode blockSize =$= conduit     where@@ -424,7 +424,7 @@           in return (StateProducing state' [output])       push _ (LastOne input) | B.null input =           return (StateFinished Nothing [])-      push state (LastOne input) = mk <$> final state input+      push state (LastOne input) = mk `liftM` final state input           where mk output = StateFinished Nothing [output]        close _ = fail "blockCipherConduit"
tests/runtests.hs view
@@ -191,7 +191,7 @@  testBlockCipherConduit ::        Maybe C.ByteLength -- ^ Fix input length to be a multiple of the block size?-    -> (forall m. Resource m => Conduit B.ByteString m B.ByteString)+    -> (forall m. Monad m => Conduit B.ByteString m B.ByteString)     -> (L.ByteString -> L.ByteString)     -> [Word8]     -> Bool@@ -205,10 +205,10 @@ ----------------------------------------------------------------------  -runPureResource :: (forall m. Resource m => ResourceT m a) -> a-runPureResource r = runST (runResourceT r)+runPureResource :: (forall m. Monad m => m a) -> a+runPureResource r = runST r -consumeAsLazy :: Resource m => Sink B.ByteString m L.ByteString+consumeAsLazy :: Monad m => Sink B.ByteString m L.ByteString consumeAsLazy = L.fromChunks <$> consume  fixBlockedSize :: C.ByteLength -> L.ByteString -> L.ByteString