Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from snoyberg/master

Upgrade dependency to conduit 0.2.
  • Loading branch information...
commit 83fa50b6a425aa4ac6304fe91ec8a615236d94cb 2 parents 314de70 + 773ca38
@meteficha meteficha authored
Showing with 15 additions and 15 deletions.
  1. +3 −3 crypto-conduit.cabal
  2. +12 −12 src/Crypto/Conduit.hs
View
6 crypto-conduit.cabal
@@ -1,6 +1,6 @@
Cabal-version: >= 1.8
Name: crypto-conduit
-Version: 0.1.1.2
+Version: 0.1.2
Synopsis: Conduit interface for cryptographic operations (from crypto-api).
Homepage: https://github.com/meteficha/crypto-conduit
License: BSD3
@@ -32,7 +32,7 @@ Library
bytestring >= 0.9 && < 0.10,
cereal >= 0.3 && < 0.4,
crypto-api >= 0.8 && < 0.9,
- conduit >= 0.0 && < 0.2,
+ conduit >= 0.2 && < 0.3,
transformers == 0.2.*
GHC-options: -Wall
@@ -43,7 +43,7 @@ Test-suite runtests
bytestring >= 0.9 && < 0.10,
cereal >= 0.3 && < 0.4,
crypto-api >= 0.8 && < 0.9,
- conduit >= 0.0 && < 0.2,
+ conduit >= 0.2 && < 0.3,
transformers == 0.2.*,
cryptocipher == 0.3.*,
View
24 src/Crypto/Conduit.hs
@@ -86,10 +86,10 @@ sinkHash = blocked AnyMultiple blockSize =$ sink
push ctx (Full bs) =
let !ctx' = C.updateCtx ctx bs
- in return (ctx', Processing)
+ in return (StateProcessing ctx')
push ctx (LastOne bs) =
let !ret = C.finalize ctx bs
- in return (error "sinkHash", Done Nothing ret)
+ in return (StateDone Nothing ret)
blockSize = (C.blockLength .::. getType sink) `div` 8
@@ -131,11 +131,11 @@ sinkHmac (C.MacKey key) = blocked AnyMultiple blockSize =$ sink
push ctx (Full bs) =
let !ctx' = C.updateCtx ctx bs
- in return (ctx', Processing)
+ in return (StateProcessing ctx')
push ctx (LastOne bs) =
let !inner = C.finalize ctx bs `asTypeOf` d
!outer = C.hash $ L.fromChunks [ko, S.encode inner]
- in return (error "sinkHmac", Done Nothing outer)
+ in return (StateDone Nothing outer)
d = getType sink
blockSize = (C.blockLength .::. d) `div` 8
@@ -316,7 +316,7 @@ sourceCtr k iv = sourceState iv pull
pull iv' =
let !iv'' = C.incIV iv'
block = C.encryptBlock k $ S.encode iv'
- in return (iv'', Open block)
+ in return (StateOpen iv'' block)
----------------------------------------------------------------------
@@ -337,9 +337,9 @@ sinkCbcMac k = blocked StrictBlockSize blockSize =$ sink
push iv (Full input) =
let !iv' = C.encryptBlock k (iv `zwp` input)
- in return (iv', Processing)
+ in return (StateProcessing iv')
push iv (LastOne input)
- | B.null input = return (error "sinkCbcMac", Done Nothing iv)
+ | B.null input = return (StateDone Nothing iv)
| otherwise = fail "sinkCbcMac: input has an incomplete final block."
close _ = fail "sinkCbcMac"
@@ -383,7 +383,7 @@ blocked mode blockSize = conduitState B.empty push close
push acc = return . mk . block . append acc
where
- mk (blks, rest) = (rest, Producing blks)
+ mk (blks, rest) = (StateProducing rest blks)
close = return . (:[]) . LastOne
@@ -415,11 +415,11 @@ blockCipherConduit key mode initialState apply final = blocked mode blockSize =$
push state (Full input) =
let (!state', !output) = apply state input
- in return (state', Producing [output])
+ in return (StateProducing state' [output])
push _ (LastOne input) | B.null input =
- return (error "blockCipherConduit", Finished Nothing [])
+ return (StateFinished Nothing [])
push state (LastOne input) = mk <$> final state input
- where mk output = (error "blockCipherConduit", Finished Nothing [output])
+ where mk output = StateFinished Nothing [output]
close _ = fail "blockCipherConduit"
@@ -433,4 +433,4 @@ blockCipherConduit key mode initialState apply final = blocked mode blockSize =$
-- Taken from crypto-api.
zwp :: B.ByteString -> B.ByteString -> B.ByteString
zwp a = B.pack . B.zipWith xor a
-{-# INLINEABLE zwp #-}
+{-# INLINEABLE zwp #-}
Please sign in to comment.
Something went wrong with that request. Please try again.