packages feed

crypto-conduit 0.1 → 0.1.1

raw patch · 2 files changed

+26/−7 lines, 2 filesdep +transformersPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

API changes (from Hackage documentation)

+ Crypto.Conduit: hashFile :: (MonadIO m, Hash ctx d) => FilePath -> m d

Files

crypto-conduit.cabal view
@@ -1,6 +1,6 @@ Cabal-version:       >= 1.8 Name:                crypto-conduit-Version:             0.1+Version:             0.1.1 Synopsis:            Conduit interface for cryptographic operations (from crypto-api). Homepage:            https://github.com/meteficha/crypto-conduit License:             BSD3@@ -32,7 +32,8 @@     bytestring   >= 0.9 && < 0.10,     cereal       >= 0.3 && < 0.4,     crypto-api   >= 0.8 && < 0.9,-    conduit      >= 0.0 && < 0.1+    conduit      >= 0.0 && < 0.1,+    transformers == 0.2.*   GHC-options: -Wall  Test-suite runtests@@ -43,6 +44,7 @@     cereal       >= 0.3 && < 0.4,     crypto-api   >= 0.8 && < 0.9,     conduit      >= 0.0 && < 0.1,+    transformers == 0.2.*,      cryptocipher == 0.3.*,     cryptohash   == 0.7.*,
src/Crypto/Conduit.hs view
@@ -7,6 +7,7 @@ module Crypto.Conduit     ( -- * Cryptographic hash functions       sinkHash+    , hashFile        -- * Hash-based message authentication code (HMAC)     , sinkHmac@@ -31,7 +32,7 @@       -- ** Cipher-block chaining message authentication code (CBC-MAC)     , sinkCbcMac -      -- * Helpers+      -- * Internal helpers     , blocked     , BlockMode(..)     , Block(..)@@ -60,8 +61,12 @@  -- from conduit import Data.Conduit+import Data.Conduit.Binary (sourceFile) +-- from transformers+import Control.Monad.IO.Class (MonadIO, liftIO) + -- | Helper to get our return type. getType :: Monad m => sink input m output -> output getType = undefined@@ -89,6 +94,17 @@       blockSize = (C.blockLength .::. getType sink) `div` 8  +-- | Hashes the whole contents of the given file in constant+-- memory.  This function is just a convenient wrapper around+-- 'sinkHash' defined as:+--+-- @+-- hashFile fp = 'liftIO' $ 'runResourceT' ('sourceFile' fp '$$' 'sinkHash')+-- @+hashFile :: (MonadIO m, C.Hash ctx d) => FilePath -> m d+hashFile fp = liftIO $ runResourceT (sourceFile fp $$ sinkHash)++ ----------------------------------------------------------------------  @@ -307,10 +323,11 @@   -- | A 'Sink' that computes the CBC-MAC of a stream of--- 'B.ByteString'@s@ and creates a digest @d@.  Expects 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.)+-- 'B.ByteString'@s@ and creates a digest (already encoded in a+-- 'B.ByteString', since we're using a block cipher).  Expects+-- 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) =>               k -- ^ Cipher key.            -> Sink B.ByteString m B.ByteString