From f9a71c7d34e3f8b595912829dc26f17818a743f6 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 20 Apr 2014 02:01:59 -0400 Subject: decrypt the working key --- KeyRing.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'KeyRing.hs') diff --git a/KeyRing.hs b/KeyRing.hs index 8d4f82d..5e55565 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -687,7 +687,8 @@ importPEMKey doDecrypt db' tup = do buildKeyDB :: (MappedPacket -> IO (KikiCondition Packet)) -> FilePath -> FilePath -> Maybe String -> KeyRingOperation - -> IO (KikiCondition ((KeyDB,Maybe String,Maybe Packet),[(FilePath,KikiReportAction)])) + -> IO (KikiCondition ((KeyDB,Maybe String,Maybe MappedPacket) + ,[(FilePath,KikiReportAction)])) buildKeyDB doDecrypt secring pubring grip0 keyring = do let @@ -712,7 +713,7 @@ buildKeyDB doDecrypt secring pubring grip0 keyring = do return $ KikiSuccess (db'', report0 ++ report) -- KeyRings (todo: KikiCondition reporting?) - (db_rings,wk,grip) <- do + (db_rings,mwk,grip) <- do ms <- mapM readp (files isring) let grip = grip0 `mplus` (fingerprint <$> fstkey) where @@ -726,9 +727,11 @@ buildKeyDB doDecrypt secring pubring grip0 keyring = do fp <- maybeToList grip elm <- Map.toList db_rings guard $ matchSpec (KeyGrip fp) elm - return $ keyPacket (snd elm) + return $ keyMappedPacket (snd elm) return (db_rings,wk,grip) + let wk = fmap packet mwk + -- Wallets wms <- mapM (readw wk) (files iswallet) let wallet_keys = do @@ -753,7 +756,7 @@ buildKeyDB doDecrypt secring pubring grip0 keyring = do db <- foldM (importPEMKey doDecrypt) (KikiSuccess (db,[])) imports try db $ \(db,reportPEMs) -> do - return $ KikiSuccess ( (db, grip, wk), reportWallets ++ reportPEMs ) + return $ KikiSuccess ( (db, grip, mwk), reportWallets ++ reportPEMs ) torhash key = maybe "" id $ derToBase32 <$> derRSA key @@ -1251,6 +1254,8 @@ runKeyRing operation = do try' bresult $ \((db,grip,wk),report_imports) -> do + let wkun = fmap (doDecrypt unkeysRef pws) wk + nonexistents <- filterM (fmap not . doesFileExist . fst) $ do (f,t) <- Map.toList (kFiles operation) @@ -1314,7 +1319,7 @@ runKeyRing operation = do { rtPubring = pubring , rtSecring = secring , rtGrip = grip - , rtWorkingKey = wk + , rtWorkingKey = fmap packet wk , rtKeyDB = db } @@ -1358,7 +1363,7 @@ makeInducerSig topk wkun uid extras db' <- Traversable.mapM doManips db -} - r <- writeWalletKeys operation db wk + r <- writeWalletKeys operation db (fmap packet wk) try' r $ \report_wallets -> do r <- writeRingKeys operation rt -- db wk secring pubring -- cgit v1.2.3