summaryrefslogtreecommitdiff
path: root/Crypto.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-23 17:27:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-23 17:33:32 -0400
commit9a8ff4c743fae057520caebb59a760caf29001b4 (patch)
tree6fb8bde572a73366a6749c07ecf711fe550a1bd5 /Crypto.hs
parent063d84ddd33f1aa0624cf5f363f2c58397b98562 (diff)
plumb RemoteGitConfig through to decryptCipher
Diffstat (limited to 'Crypto.hs')
-rw-r--r--Crypto.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/Crypto.hs b/Crypto.hs
index 91efd71c6..d5b0ed94d 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -99,14 +99,14 @@ genSharedPubKeyCipher cmd keyid highQuality = do
{- Updates an existing Cipher, making changes to its keyids.
-
- When the Cipher is encrypted, re-encrypts it. -}
-updateCipherKeyIds :: Gpg.GpgCmd -> [(Bool, Gpg.KeyId)] -> StorableCipher -> IO StorableCipher
-updateCipherKeyIds _ _ SharedCipher{} = error "Cannot update shared cipher"
-updateCipherKeyIds _ [] c = return c
-updateCipherKeyIds cmd changes encipher@(EncryptedCipher _ variant ks) = do
+updateCipherKeyIds :: LensGpgEncParams encparams => Gpg.GpgCmd -> encparams -> [(Bool, Gpg.KeyId)] -> StorableCipher -> IO StorableCipher
+updateCipherKeyIds _ _ _ SharedCipher{} = error "Cannot update shared cipher"
+updateCipherKeyIds _ _ [] c = return c
+updateCipherKeyIds cmd encparams changes encipher@(EncryptedCipher _ variant ks) = do
ks' <- updateCipherKeyIds' cmd changes ks
- cipher <- decryptCipher cmd encipher
+ cipher <- decryptCipher cmd encparams encipher
encryptCipher cmd cipher variant ks'
-updateCipherKeyIds cmd changes (SharedPubKeyCipher cipher ks) =
+updateCipherKeyIds cmd _ changes (SharedPubKeyCipher cipher ks) =
SharedPubKeyCipher cipher <$> updateCipherKeyIds' cmd changes ks
updateCipherKeyIds' :: Gpg.GpgCmd -> [(Bool, Gpg.KeyId)] -> KeyIds -> IO KeyIds
@@ -136,15 +136,16 @@ encryptCipher cmd c variant (KeyIds ks) = do
MacOnlyCipher x -> x
{- Decrypting an EncryptedCipher is expensive; the Cipher should be cached. -}
-decryptCipher :: Gpg.GpgCmd -> StorableCipher -> IO Cipher
-decryptCipher _ (SharedCipher t) = return $ Cipher t
-decryptCipher _ (SharedPubKeyCipher t _) = return $ MacOnlyCipher t
-decryptCipher cmd (EncryptedCipher t variant _) =
- mkCipher <$> Gpg.pipeStrict cmd [ Param "--decrypt" ] t
+decryptCipher :: LensGpgEncParams c => Gpg.GpgCmd -> c -> StorableCipher -> IO Cipher
+decryptCipher _ _ (SharedCipher t) = return $ Cipher t
+decryptCipher _ _ (SharedPubKeyCipher t _) = return $ MacOnlyCipher t
+decryptCipher cmd c (EncryptedCipher t variant _) =
+ mkCipher <$> Gpg.pipeStrict cmd params t
where
mkCipher = case variant of
Hybrid -> Cipher
PubKey -> MacOnlyCipher
+ params = Param "--decrypt" : getGpgDecParams c
type EncKey = Key -> Key