summaryrefslogtreecommitdiff
path: root/Crypto.hs
diff options
context:
space:
mode:
authorGravatar guilhem <guilhem@fripost.org>2013-03-11 02:33:13 +0100
committerGravatar Joey Hess <joey@kitenet.net>2013-03-11 09:48:38 -0400
commit7fa1e498de9cbb84b23f90b17c66d755292ae716 (patch)
treedc1f5127473d3450b138b4aedfe43a5248d42939 /Crypto.hs
parentf2292dc3b494dbed517a48ab2876594f5ace0179 (diff)
GnuPG options for symmetric encryption.
Diffstat (limited to 'Crypto.hs')
-rw-r--r--Crypto.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Crypto.hs b/Crypto.hs
index ed489cdbc..21a35ad0b 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -23,6 +23,8 @@ module Crypto (
readBytes,
encrypt,
decrypt,
+ GpgOpts(..),
+ getGpgOpts,
prop_hmacWithCipher_sane
) where
@@ -34,6 +36,7 @@ import Control.Applicative
import Common.Annex
import qualified Utility.Gpg as Gpg
+import Utility.Gpg.Types
import Types.Key
import Types.Crypto
@@ -131,10 +134,12 @@ feedBytes = flip L.hPut
readBytes :: (L.ByteString -> IO a) -> Reader a
readBytes a h = L.hGetContents h >>= a
-{- Runs a Feeder action, that generates content that is encrypted with the
- - Cipher, and read by the Reader action. -}
-encrypt :: Cipher -> Feeder -> Reader a -> IO a
-encrypt = Gpg.feedRead [Params "--symmetric --force-mdc"] . cipherPassphrase
+{- Runs a Feeder action, that generates content that is symmetrically encrypted
+ - with the Cipher using the given GnuPG options, and then read by the Reader
+ - action. -}
+encrypt :: GpgOpts -> Cipher -> Feeder -> Reader a -> IO a
+encrypt opts = Gpg.feedRead ( Params "--symmetric --force-mdc" : toParams opts )
+ . cipherPassphrase
{- Runs a Feeder action, that generates content that is decrypted with the
- Cipher, and read by the Reader action. -}