diff options
Diffstat (limited to 'lib/PacketTranscoder.hs')
-rw-r--r-- | lib/PacketTranscoder.hs | 15 |
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 #-} |
4 | module PacketTranscoder where | 4 | module PacketTranscoder where |
5 | 5 | ||
6 | import Debug.Trace | ||
7 | import GHC.Stack | ||
8 | import Control.Monad | 6 | import Control.Monad |
9 | import Data.IORef | 7 | import Data.IORef |
10 | import Data.List | 8 | import Data.List |
@@ -16,12 +14,10 @@ import qualified Data.ByteString as S | |||
16 | import qualified Data.ByteString.Char8 as S8 | 14 | import qualified Data.ByteString.Char8 as S8 |
17 | import Data.Map as Map (Map) | 15 | import Data.Map as Map (Map) |
18 | import qualified Data.Map as Map | 16 | import qualified Data.Map as Map |
19 | import qualified Data.Traversable as Traversable | ||
20 | import System.IO ( stderr) | 17 | import System.IO ( stderr) |
21 | import System.Posix.IO ( fdToHandle ) | 18 | import System.Posix.IO ( fdToHandle ) |
22 | import Text.Show.Pretty as PP ( ppShow ) | 19 | import Text.Show.Pretty as PP ( ppShow ) |
23 | import KeyRing.Types | 20 | import KeyRing.Types |
24 | import 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 | ||
141 | interpretPassSpec ctx keys (PassphraseMemoizer _) = | ||
142 | -- INVALID ARGUMENT: PassphraseMemoizer | ||
143 | return BadPassphrase | ||
144 | |||
145 | |||
145 | sendQuery :: GnuPGAgent -> (QueryMode,PassphraseResponse) -> OriginMapped Query -> IO PassphraseResponse | 146 | sendQuery :: GnuPGAgent -> (QueryMode,PassphraseResponse) -> OriginMapped Query -> IO PassphraseResponse |
146 | sendQuery agent (ask,failure) qry = do | 147 | sendQuery 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 | ||