summaryrefslogtreecommitdiff
path: root/KeyRing.hs
diff options
context:
space:
mode:
Diffstat (limited to 'KeyRing.hs')
-rw-r--r--KeyRing.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index e57861f..58868b6 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -1151,6 +1151,7 @@ isCryptoCoinKey p =
1151 , lookup 'c' (key p) == Just (MPI secp256k1_id) 1151 , lookup 'c' (key p) == Just (MPI secp256k1_id)
1152 ] 1152 ]
1153 1153
1154getCryptoCoinTag :: Packet -> Maybe CryptoCoins.CoinNetwork
1154getCryptoCoinTag p | isSignaturePacket p = do 1155getCryptoCoinTag p | isSignaturePacket p = do
1155 -- CryptoCoins.secret 1156 -- CryptoCoins.secret
1156 let sps = hashed_subpackets p ++ unhashed_subpackets p 1157 let sps = hashed_subpackets p ++ unhashed_subpackets p
@@ -1170,6 +1171,7 @@ coinKeysOwnedBy db wk = do
1170 tag <- take 1 $ mapMaybe getCryptoCoinTag (map (packet . fst) sigs) 1171 tag <- take 1 $ mapMaybe getCryptoCoinTag (map (packet . fst) sigs)
1171 return (tag,mp) 1172 return (tag,mp)
1172 1173
1174walletImportFormat :: Word8 -> Packet -> String
1173walletImportFormat idbyte k = secret_base58_foo 1175walletImportFormat idbyte k = secret_base58_foo
1174 where 1176 where
1175 -- isSecret (SecretKeyPacket {}) = True 1177 -- isSecret (SecretKeyPacket {}) = True
@@ -1206,6 +1208,7 @@ writeWalletKeys krd db wk = do
1206 report <- foldM writeWallet [] (files isMutableWallet) 1208 report <- foldM writeWallet [] (files isMutableWallet)
1207 return $ KikiSuccess report 1209 return $ KikiSuccess report
1208 1210
1211ifSecret :: Packet -> t -> t -> t
1209ifSecret (SecretKeyPacket {}) t f = t 1212ifSecret (SecretKeyPacket {}) t f = t
1210ifSecret _ t f = f 1213ifSecret _ t f = f
1211 1214
@@ -1219,8 +1222,13 @@ showPacket p | isKey p = (if is_subkey p
1219showPacket0 p = concat . take 1 $ words (show p) 1222showPacket0 p = concat . take 1 $ words (show p)
1220 1223
1221 1224
1225importPublic :: Maybe Bool
1222importPublic = Just True 1226importPublic = Just True
1227
1228importSecret :: Maybe Bool
1223importSecret = Just False 1229importSecret = Just False
1230
1231subkeysOnly :: Maybe Bool
1224subkeysOnly = Nothing 1232subkeysOnly = Nothing
1225 1233
1226guardAuthentic :: KeyRingRuntime -> KeyData -> Maybe () 1234guardAuthentic :: KeyRingRuntime -> KeyData -> Maybe ()
@@ -1299,6 +1307,7 @@ getSubkeysForExport kk subspec db = do
1299 subkeysForExport subspec kd 1307 subkeysForExport subspec kd
1300-} 1308-}
1301 1309
1310subkeysForExport :: Maybe String -> KeyData -> [MappedPacket]
1302subkeysForExport subspec (KeyData key _ _ subkeys) = do 1311subkeysForExport subspec (KeyData key _ _ subkeys) = do
1303 let subs tag = do 1312 let subs tag = do
1304 e <- Map.elems subkeys 1313 e <- Map.elems subkeys
@@ -1313,6 +1322,7 @@ subkeysForExport subspec (KeyData key _ _ subkeys) = do
1313 sigtrusts 1322 sigtrusts
1314 in fmap fst v==Just True 1323 in fmap fst v==Just True
1315 1324
1325writePEM :: String -> String -> String
1316writePEM typ dta = pem 1326writePEM typ dta = pem
1317 where 1327 where
1318 pem = unlines . concat $ 1328 pem = unlines . concat $
@@ -1354,6 +1364,8 @@ rsaPrivateKeyFromPacket pkt@(SecretKeyPacket {}) = do
1354rsaPrivateKeyFromPacket _ = Nothing 1364rsaPrivateKeyFromPacket _ = Nothing
1355 1365
1356 1366
1367writeKeyToFile ::
1368 Bool -> String -> FilePath -> Packet -> IO [(FilePath, KikiReportAction)]
1357writeKeyToFile False "PEM" fname packet = 1369writeKeyToFile False "PEM" fname packet =
1358 case key_algorithm packet of 1370 case key_algorithm packet of
1359 RSA -> do 1371 RSA -> do