From 69acbc5156a69393ab97e444f51945706365da4b Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 30 Apr 2014 22:51:25 -0400 Subject: partial support for kPassphrases --- KeyRing.hs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/KeyRing.hs b/KeyRing.hs index 08bde7a..db9e9c3 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -242,6 +242,8 @@ data KeyRingRuntime = KeyRingRuntime , rtSecring :: FilePath , rtGrip :: Maybe String , rtWorkingKey :: Maybe Packet + , rtUnspilled :: Map.Map InputFile KeyDB + -- ^ TODO: this is currently unused , rtKeyDB :: KeyDB , rtRingAccess :: Map.Map FilePath Access } @@ -254,16 +256,18 @@ data PacketUpdate = InducerSignature String [SignatureSubpacket] noManip :: KeyRingRuntime -> KeyData -> [PacketUpdate] noManip _ _ = [] -data PassphraseSpec = PassphraseSpec (Maybe FilePath) (Maybe String) InputFile +data PassphraseSpec = PassphraseSpec + { passSpecRingFile :: Maybe FilePath + , passSpecKeySpec :: Maybe String + -- ^ non-Nothing value reserved for future use (TODO). + , passSpecPassFile :: InputFile + } data Transform = Autosign data KeyRingOperation = KeyRingOperation { kFiles :: Map.Map InputFile StreamInfo , kPassphrases :: [PassphraseSpec] - -- ^ TODO: this is currently ignored - , kUnspilled :: Map.Map InputFile KeyDB - -- ^ TODO: this is currently ignored , kTransform :: [Transform] -- ^ TODO: this is currently ignored , kManip :: KeyRingRuntime -> KeyData -> [PacketUpdate]--[KeyRingAddress PacketUpdate] @@ -1645,12 +1649,20 @@ makeMemoizingDecrypter operation ctx = do -- and the pws map keys must match the MappedPacket locations. -- TODO: Perhaps these should both be of type InputFile rather than -- FilePath? + -- pws :: Map.Map FilePath (IO S.ByteString) pws <- Traversable.mapM (cachedContents ctx . fromJust . pwfile . typ) (Map.mapKeys (resolveForReport Nothing) -- see note (*) note above $ Map.filter (isJust . pwfile . typ) $ kFiles operation) + pws2 <- + Traversable.mapM (cachedContents ctx) + $ Map.fromList $ mapMaybe + (\spec -> (,passSpecPassFile spec) `fmap` do + guard $ isNothing $ passSpecKeySpec spec + passSpecRingFile spec) + (kPassphrases operation) unkeysRef <- newIORef Map.empty - return $ doDecrypt unkeysRef pws + return $ doDecrypt unkeysRef (pws `Map.union` pws2) where doDecrypt :: IORef (Map.Map KeyKey Packet) -> Map.Map FilePath (IO S.ByteString) -- cgit v1.2.3