summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs37
1 files changed, 0 insertions, 37 deletions
diff --git a/kiki.hs b/kiki.hs
index b23e304..e901625 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -91,9 +91,6 @@ secp256k1_id = 0x2b8104000a
91 91
92warn str = hPutStrLn stderr str 92warn str = hPutStrLn stderr str
93 93
94unprefix c spec = if null (snd p) then swap p else (fst p, tail (snd p))
95 where p = break (==c) spec
96
97 94
98{- 95{-
99RSAPrivateKey ::= SEQUENCE { 96RSAPrivateKey ::= SEQUENCE {
@@ -653,14 +650,6 @@ getPassphrase cmd =
653 650
654#define HOMEOPTION (def &= explicit &= name "homedir" &= typDir ) 651#define HOMEOPTION (def &= explicit &= name "homedir" &= typDir )
655 652
656is40digitHex xs = ys == xs && length ys==40
657 where
658 ys = filter ishex xs
659 ishex c | '0' <= c && c <= '9' = True
660 | 'A' <= c && c <= 'F' = True
661 | 'a' <= c && c <= 'f' = True
662 ishex c = False
663
664flattenKeys :: Bool -> KeyDB -> Message 653flattenKeys :: Bool -> KeyDB -> Message
665flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db) 654flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db)
666 where 655 where
@@ -864,29 +853,6 @@ show_wip keyspec wkgrip db = do
864 let nwb = maybe 0x80 CryptoCoins.secretByteFromName $ snd s 853 let nwb = maybe 0x80 CryptoCoins.secretByteFromName $ snd s
865 putStrLn $ walletImportFormat nwb k 854 putStrLn $ walletImportFormat nwb k
866 855
867parseSpec :: String -> String -> (KeySpec,Maybe String)
868parseSpec grip spec = (topspec,subspec)
869 where
870 (topspec0,subspec0) = unprefix '/' spec
871 (toptyp,top) = unprefix ':' topspec0
872 (subtyp,sub) = unprefix ':' subspec0
873 topspec = case () of
874 _ | null top && or [ subtyp=="fp"
875 , null subtyp && is40digitHex sub
876 ]
877 -> KeyGrip sub
878 _ | null top && null grip -> KeyUidMatch sub
879 _ | null top -> KeyGrip grip
880 _ | toptyp=="fp" || (null toptyp && is40digitHex top)
881 -> {- trace "using top" $ -} KeyGrip top
882 _ | toptyp=="u" -> KeyUidMatch top
883 _ | otherwise -> KeyUidMatch top
884 subspec = case subtyp of
885 "t" -> Just sub
886 "fp" | top=="" -> Nothing
887 "" | top=="" && is40digitHex sub -> Nothing
888 "" -> listToMaybe sub >> Just sub
889
890-- | systemEnv 856-- | systemEnv
891-- This is like System.Process.system except that it lets you set 857-- This is like System.Process.system except that it lets you set
892-- some environment variables. 858-- some environment variables.
@@ -1766,9 +1732,6 @@ isTopKey p@(SecretKeyPacket {}) | not (is_subkey p) = True
1766isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True 1732isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True
1767isTopKey _ = False 1733isTopKey _ = False
1768 1734
1769filterMatches :: KeySpec -> [(KeyKey,KeyData)] -> [(KeyKey,KeyData)]
1770filterMatches spec ks = filter (matchSpec spec) ks
1771
1772selectSecretKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet 1735selectSecretKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet
1773selectSecretKey (spec,mtag) db = selectKey0 False (spec,mtag) db 1736selectSecretKey (spec,mtag) db = selectKey0 False (spec,mtag) db
1774 1737