summaryrefslogtreecommitdiff
path: root/KeyRing.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-30 22:51:25 -0400
committerjoe <joe@jerkface.net>2014-04-30 22:51:25 -0400
commit69acbc5156a69393ab97e444f51945706365da4b (patch)
tree7d5cf40e1430729679f46d95530b68b67005a07d /KeyRing.hs
parent298d4805cc7e3c16a71550f3a3bd0f4945c67772 (diff)
partial support for kPassphrases
Diffstat (limited to 'KeyRing.hs')
-rw-r--r--KeyRing.hs22
1 files 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
242 , rtSecring :: FilePath 242 , rtSecring :: FilePath
243 , rtGrip :: Maybe String 243 , rtGrip :: Maybe String
244 , rtWorkingKey :: Maybe Packet 244 , rtWorkingKey :: Maybe Packet
245 , rtUnspilled :: Map.Map InputFile KeyDB
246 -- ^ TODO: this is currently unused
245 , rtKeyDB :: KeyDB 247 , rtKeyDB :: KeyDB
246 , rtRingAccess :: Map.Map FilePath Access 248 , rtRingAccess :: Map.Map FilePath Access
247 } 249 }
@@ -254,16 +256,18 @@ data PacketUpdate = InducerSignature String [SignatureSubpacket]
254noManip :: KeyRingRuntime -> KeyData -> [PacketUpdate] 256noManip :: KeyRingRuntime -> KeyData -> [PacketUpdate]
255noManip _ _ = [] 257noManip _ _ = []
256 258
257data PassphraseSpec = PassphraseSpec (Maybe FilePath) (Maybe String) InputFile 259data PassphraseSpec = PassphraseSpec
260 { passSpecRingFile :: Maybe FilePath
261 , passSpecKeySpec :: Maybe String
262 -- ^ non-Nothing value reserved for future use (TODO).
263 , passSpecPassFile :: InputFile
264 }
258 265
259data Transform = Autosign 266data Transform = Autosign
260 267
261data KeyRingOperation = KeyRingOperation 268data KeyRingOperation = KeyRingOperation
262 { kFiles :: Map.Map InputFile StreamInfo 269 { kFiles :: Map.Map InputFile StreamInfo
263 , kPassphrases :: [PassphraseSpec] 270 , kPassphrases :: [PassphraseSpec]
264 -- ^ TODO: this is currently ignored
265 , kUnspilled :: Map.Map InputFile KeyDB
266 -- ^ TODO: this is currently ignored
267 , kTransform :: [Transform] 271 , kTransform :: [Transform]
268 -- ^ TODO: this is currently ignored 272 -- ^ TODO: this is currently ignored
269 , kManip :: KeyRingRuntime -> KeyData -> [PacketUpdate]--[KeyRingAddress PacketUpdate] 273 , kManip :: KeyRingRuntime -> KeyData -> [PacketUpdate]--[KeyRingAddress PacketUpdate]
@@ -1645,12 +1649,20 @@ makeMemoizingDecrypter operation ctx = do
1645 -- and the pws map keys must match the MappedPacket locations. 1649 -- and the pws map keys must match the MappedPacket locations.
1646 -- TODO: Perhaps these should both be of type InputFile rather than 1650 -- TODO: Perhaps these should both be of type InputFile rather than
1647 -- FilePath? 1651 -- FilePath?
1652 -- pws :: Map.Map FilePath (IO S.ByteString)
1648 pws <- 1653 pws <-
1649 Traversable.mapM (cachedContents ctx . fromJust . pwfile . typ) 1654 Traversable.mapM (cachedContents ctx . fromJust . pwfile . typ)
1650 (Map.mapKeys (resolveForReport Nothing) -- see note (*) note above 1655 (Map.mapKeys (resolveForReport Nothing) -- see note (*) note above
1651 $ Map.filter (isJust . pwfile . typ) $ kFiles operation) 1656 $ Map.filter (isJust . pwfile . typ) $ kFiles operation)
1657 pws2 <-
1658 Traversable.mapM (cachedContents ctx)
1659 $ Map.fromList $ mapMaybe
1660 (\spec -> (,passSpecPassFile spec) `fmap` do
1661 guard $ isNothing $ passSpecKeySpec spec
1662 passSpecRingFile spec)
1663 (kPassphrases operation)
1652 unkeysRef <- newIORef Map.empty 1664 unkeysRef <- newIORef Map.empty
1653 return $ doDecrypt unkeysRef pws 1665 return $ doDecrypt unkeysRef (pws `Map.union` pws2)
1654 where 1666 where
1655 doDecrypt :: IORef (Map.Map KeyKey Packet) 1667 doDecrypt :: IORef (Map.Map KeyKey Packet)
1656 -> Map.Map FilePath (IO S.ByteString) 1668 -> Map.Map FilePath (IO S.ByteString)