-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Decrypt files encrypted by QNAP's Hybrid Backup Sync
--   
--   Please see the README on Github at
--   <a>https://github.com/alexkazik/qnap-decrypt#readme</a>
@package qnap-decrypt
@version 0.3.4


-- | This module provides a function to decrypt a padded and encrypted
--   stream of <a>ByteString</a>s.
module Data.Conduit.Crypto

-- | Decrypt a PKCS padded and encrypted stream of <a>ByteString</a>s
--   
--   <pre>
--   runConduitRes $
--     sourceFile inName .|
--     decryptPaddedStream (error "Padding Error") defaultChunkSize (unCbc key) iv .|
--     sinkFile outName
--   </pre>
--   
--   <i>Since 0.3.0</i>
decryptPaddedStream :: forall e cipher m. Exception e => BlockCipher cipher => Monad m => e -> Int -> (IV cipher -> ByteString -> (ByteString, IV cipher)) -> IV cipher -> ConduitT ByteString ByteString m ()

-- | The chunk size used for I/O. Currently set to 32k, less the memory
--   management overhead
defaultChunkSize :: Int


-- | This is the heart of the qnap-decrypt package. It provides the
--   function to decrypt the files encryped by QNAP's Hybrid Backup Sync.
module Crypto.QNAP

-- | Decrypt a QNAP encoded file (does not throw an exception)
--   
--   <i>Since 0.3.0</i>
decrypt :: String -> FilePath -> FilePath -> IO (Maybe DecryptError)

-- | Errors the decrypter could run into
--   
--   The Exception instance has a specialized <a>displayException</a>
--   function which renders the error in english text (unlike <a>show</a>
--   which just displays the constructor).
--   
--   <i>Since 0.3.0</i>
data DecryptError

-- | Password is empty
PasswordEmpty :: DecryptError

-- | Invalid encryption key
InvalidKey :: DecryptError

-- | Unknown file type (the file is not encrypted or it's version is not
--   known)
UnknownFileType :: DecryptError

-- | Bad Magic (probably wrong password)
BadMagic :: DecryptError

-- | Error decoding the header: &lt;error&gt;
HeaderDecodeError :: String -> DecryptError

-- | Padding is corrupt (probably damaged file)
PaddingError :: DecryptError

-- | IO Exception: &lt;error&gt;
IOError :: IOException -> DecryptError

-- | Decompression Exception: &lt;error&gt; (probably damaged file)
ZlibError :: ZlibException -> DecryptError

-- | File size is different than excepted (probably damaged file)
FileSizeMismatch :: DecryptError
instance GHC.Show.Show Crypto.QNAP.DecryptError
instance GHC.Exception.Type.Exception Crypto.QNAP.DecryptError
