diff options
author | joe <joe@jerkface.net> | 2014-04-30 22:51:25 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-30 22:51:25 -0400 |
commit | 69acbc5156a69393ab97e444f51945706365da4b (patch) | |
tree | 7d5cf40e1430729679f46d95530b68b67005a07d | |
parent | 298d4805cc7e3c16a71550f3a3bd0f4945c67772 (diff) |
partial support for kPassphrases
-rw-r--r-- | KeyRing.hs | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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] | |||
254 | noManip :: KeyRingRuntime -> KeyData -> [PacketUpdate] | 256 | noManip :: KeyRingRuntime -> KeyData -> [PacketUpdate] |
255 | noManip _ _ = [] | 257 | noManip _ _ = [] |
256 | 258 | ||
257 | data PassphraseSpec = PassphraseSpec (Maybe FilePath) (Maybe String) InputFile | 259 | data 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 | ||
259 | data Transform = Autosign | 266 | data Transform = Autosign |
260 | 267 | ||
261 | data KeyRingOperation = KeyRingOperation | 268 | data 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) |