summaryrefslogtreecommitdiff
path: root/lib/PacketTranscoder.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PacketTranscoder.hs')
-rw-r--r--lib/PacketTranscoder.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/PacketTranscoder.hs b/lib/PacketTranscoder.hs
index 759d83f..71a2202 100644
--- a/lib/PacketTranscoder.hs
+++ b/lib/PacketTranscoder.hs
@@ -3,8 +3,6 @@
3{-# LANGUAGE PatternGuards #-} 3{-# LANGUAGE PatternGuards #-}
4module PacketTranscoder where 4module PacketTranscoder where
5 5
6import Debug.Trace
7import GHC.Stack
8import Control.Monad 6import Control.Monad
9import Data.IORef 7import Data.IORef
10import Data.List 8import Data.List
@@ -16,12 +14,10 @@ import qualified Data.ByteString as S
16import qualified Data.ByteString.Char8 as S8 14import qualified Data.ByteString.Char8 as S8
17import Data.Map as Map (Map) 15import Data.Map as Map (Map)
18import qualified Data.Map as Map 16import qualified Data.Map as Map
19import qualified Data.Traversable as Traversable
20import System.IO ( stderr) 17import System.IO ( stderr)
21import System.Posix.IO ( fdToHandle ) 18import System.Posix.IO ( fdToHandle )
22import Text.Show.Pretty as PP ( ppShow ) 19import Text.Show.Pretty as PP ( ppShow )
23import KeyRing.Types 20import KeyRing.Types
24import ControlMaybe (handleIO_)
25 21
26-- | Merge two representations of the same key, prefering secret version 22-- | Merge two representations of the same key, prefering secret version
27-- because they have more information. 23-- because they have more information.
@@ -113,7 +109,7 @@ interpretPassSpec ctx _ PassphraseSpec { passSpecPassFile = fd
113 cachedContents (Just "Enter possibly multi-line passphrase (Press CTRL-D when finished):\n") 109 cachedContents (Just "Enter possibly multi-line passphrase (Press CTRL-D when finished):\n")
114 ctx 110 ctx
115 fd 111 fd
116 let matchkey fp mp = matchpr fp (packet mp) == fp 112 let matchkey fp mp = matchKeySpec fp (packet mp)
117 matchfile file mp = Map.member file (locations mp) 113 matchfile file mp = Map.member file (locations mp)
118 specializers = [ fmap matchkey keyspec, fmap matchfile inputfile] 114 specializers = [ fmap matchkey keyspec, fmap matchfile inputfile]
119 specialize alg mp = 115 specialize alg mp =
@@ -142,6 +138,11 @@ interpretPassSpec ctx keys PassphraseAgent = do
142 138
143 return $ KikiSuccess (cacheSearch, quit agent) 139 return $ KikiSuccess (cacheSearch, quit agent)
144 140
141interpretPassSpec ctx keys (PassphraseMemoizer _) =
142 -- INVALID ARGUMENT: PassphraseMemoizer
143 return BadPassphrase
144
145
145sendQuery :: GnuPGAgent -> (QueryMode,PassphraseResponse) -> OriginMapped Query -> IO PassphraseResponse 146sendQuery :: GnuPGAgent -> (QueryMode,PassphraseResponse) -> OriginMapped Query -> IO PassphraseResponse
146sendQuery agent (ask,failure) qry = do 147sendQuery agent (ask,failure) qry = do
147 mbpw <- getPassphrase agent ask (packet qry) 148 mbpw <- getPassphrase agent ask (packet qry)
@@ -291,8 +292,8 @@ keyQueries grip ringPackets = (mwk, fmap makeQuery keys)
291 mwk = listToMaybe $ do 292 mwk = listToMaybe $ do
292 fp <- maybeToList grip 293 fp <- maybeToList grip
293 let matchfp mp 294 let matchfp mp
294 | not (is_subkey p) && matchpr fp p == fp = Just mp 295 | not (is_subkey p) && matchpr 0 fp p == fp = Just mp
295 | otherwise = Nothing 296 | otherwise = Nothing
296 where p = packet mp 297 where p = packet mp
297 Map.elems $ Map.mapMaybe matchfp $ fmap (\(_,p,_) -> p) $ keys 298 Map.elems $ Map.mapMaybe matchfp $ fmap (\(_,p,_) -> p) $ keys
298 299