summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-18 00:35:30 -0400
committerjoe <joe@jerkface.net>2014-04-18 00:35:30 -0400
commit60f9591a217e07da45b6f16769a9b65a18301754 (patch)
tree55a296600c770f5daa558de7f5579f33303da655 /kiki.hs
parent67e5ad3df24cea8f16e7cb1f95e557c13b75d4ee (diff)
export secret keys as pem files
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/kiki.hs b/kiki.hs
index c29076a..42b1d98 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -1232,8 +1232,8 @@ main = do
1232 let keypairs = catMaybes keypairs0 1232 let keypairs = catMaybes keypairs0
1233 btcpairs = catMaybes btcpairs0 1233 btcpairs = catMaybes btcpairs0
1234 1234
1235 {-
1236 putStrLn $ "keypairs = "++show keypairs 1235 putStrLn $ "keypairs = "++show keypairs
1236 {-
1237 putStrLn $ "publics = "++show publics 1237 putStrLn $ "publics = "++show publics
1238 putStrLn $ "keyrings = "++show keyrings 1238 putStrLn $ "keyrings = "++show keyrings
1239 -} 1239 -}
@@ -1324,19 +1324,25 @@ main = do
1324 return db' 1324 return db'
1325 1325
1326 let homespec = join . take 1 <$> Map.lookup "--homedir" margs 1326 let homespec = join . take 1 <$> Map.lookup "--homedir" margs
1327 passfd = fmap (FileDesc . read) passphrase_fd
1328 pems = flip map keypairs
1329 $ \(usage,path,cmd) ->
1330 let cmd' = guard (not $ null cmd) >> return cmd
1331 in (ArgFile path, (MutableRef cmd', PEMFile usage))
1327 kikiOp = KeyRingData 1332 kikiOp = KeyRingData
1328 { kFiles = Map.fromList 1333 { kFiles = Map.fromList $
1329 [ ( HomeSec, (ConstRef, KeyRingFile (FileDesc 8)) ) 1334 [ ( HomeSec, (MutableRef Nothing, KeyRingFile passfd) )
1330 , ( HomePub, (ConstRef, KeyRingFile (FileDesc 8)) ) 1335 , ( HomePub, (MutableRef Nothing, KeyRingFile Nothing) )
1331 ] 1336 ]
1337 ++ pems
1332 , kImports = Map.empty 1338 , kImports = Map.empty
1333 , homeSpec = homespec 1339 , homeSpec = homespec
1334 } 1340 }
1335 1341
1336 rt <- runKeyRing kikiOp 1342 KikiResult rt report <- runKeyRing kikiOp
1337 1343
1338 case rt of 1344 case rt of
1339 KikiResult (KikiSuccess rt) _ -> do -- interpret --show-* commands. 1345 KikiSuccess rt -> do -- interpret --show-* commands.
1340 let grip = rtGrip rt 1346 let grip = rtGrip rt
1341 let shspec = Map.fromList [("--show-wk", const $ show_wk (rtSecring rt) grip) 1347 let shspec = Map.fromList [("--show-wk", const $ show_wk (rtSecring rt) grip)
1342 ,("--show-all",const $ show_all) 1348 ,("--show-all",const $ show_all)
@@ -1349,7 +1355,9 @@ main = do
1349 shargs = mapMaybe (\(x:xs) -> (,xs) <$> Map.lookup x shspec) sargs 1355 shargs = mapMaybe (\(x:xs) -> (,xs) <$> Map.lookup x shspec) sargs
1350 1356
1351 forM_ shargs $ \(cmd,args) -> cmd args (rtKeyDB rt) 1357 forM_ shargs $ \(cmd,args) -> cmd args (rtKeyDB rt)
1358 e -> putStrLn $ show (fmap (const ()) e)
1352 1359
1360 putStrLn $ show report
1353 return() 1361 return()
1354 where 1362 where
1355 1363