summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-30 23:01:07 -0400
committerjoe <joe@jerkface.net>2014-04-30 23:01:07 -0400
commitaa5bf4e7ba36a07898a8ffaf9c6b25d973fb05d6 (patch)
tree07168074c0ee93ea72350ebad63559c112333ade
parent69acbc5156a69393ab97e444f51945706365da4b (diff)
Support default passphrase specification
-rw-r--r--KeyRing.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index db9e9c3..a88a0a7 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -171,13 +171,11 @@ data InputFile = HomeSec
171 171
172-- type UsageTag = String 172-- type UsageTag = String
173type Initializer = String 173type Initializer = String
174type PassWordFile = InputFile 174type PasswordFile = InputFile
175 175
176-- TODO: This should become a simple enum. 176data FileType = KeyRingFile (Maybe PasswordFile)
177-- The parameter to PEMFile will be subsumed by 177 -- ^ PasswordFile parameter is deprecated in favor
178-- the KF_Match fill/spill KeyFilter styles. The parameter 178 -- of kPassphrases. TODO: remove it.
179-- to KeyRingFile will be subsumbed by kPassphrases
180data FileType = KeyRingFile (Maybe PassWordFile)
181 | PEMFile 179 | PEMFile
182 | WalletFile -- (Maybe UsageTag) 180 | WalletFile -- (Maybe UsageTag)
183 | Hosts 181 | Hosts
@@ -225,7 +223,7 @@ ispem :: FileType -> Bool
225ispem (PEMFile {}) = True 223ispem (PEMFile {}) = True
226ispem _ = False 224ispem _ = False
227 225
228pwfile :: FileType -> Maybe PassWordFile 226pwfile :: FileType -> Maybe PasswordFile
229pwfile (KeyRingFile f) = f 227pwfile (KeyRingFile f) = f
230pwfile _ = Nothing 228pwfile _ = Nothing
231 229
@@ -1661,14 +1659,20 @@ makeMemoizingDecrypter operation ctx = do
1661 guard $ isNothing $ passSpecKeySpec spec 1659 guard $ isNothing $ passSpecKeySpec spec
1662 passSpecRingFile spec) 1660 passSpecRingFile spec)
1663 (kPassphrases operation) 1661 (kPassphrases operation)
1662 defpw <- do
1663 Traversable.mapM (cachedContents ctx . passSpecPassFile)
1664 $ listToMaybe $ filter (\sp -> isNothing (passSpecRingFile sp)
1665 && isNothing (passSpecKeySpec sp))
1666 $ kPassphrases operation
1664 unkeysRef <- newIORef Map.empty 1667 unkeysRef <- newIORef Map.empty
1665 return $ doDecrypt unkeysRef (pws `Map.union` pws2) 1668 return $ doDecrypt unkeysRef (pws `Map.union` pws2) defpw
1666 where 1669 where
1667 doDecrypt :: IORef (Map.Map KeyKey Packet) 1670 doDecrypt :: IORef (Map.Map KeyKey Packet)
1668 -> Map.Map FilePath (IO S.ByteString) 1671 -> Map.Map FilePath (IO S.ByteString)
1672 -> Maybe (IO S.ByteString)
1669 -> MappedPacket 1673 -> MappedPacket
1670 -> IO (KikiCondition Packet) 1674 -> IO (KikiCondition Packet)
1671 doDecrypt unkeysRef pws mp = do 1675 doDecrypt unkeysRef pws defpw mp = do
1672 unkeys <- readIORef unkeysRef 1676 unkeys <- readIORef unkeysRef
1673 let wk = packet mp 1677 let wk = packet mp
1674 kk = keykey wk 1678 kk = keykey wk