diff options
author | joe <joe@jerkface.net> | 2014-04-15 20:09:34 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-15 20:09:34 -0400 |
commit | 7cfd556b8681d0675b1a7df127bbdbe4b7c7e9ff (patch) | |
tree | 1df6f180509b595d31b4ceb23d40e568454f67bd /kiki.hs | |
parent | adab31d826113207bca7f4f7f9fb8013cead0ce1 (diff) |
importing of PEM files
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 37 |
1 files changed, 0 insertions, 37 deletions
@@ -91,9 +91,6 @@ secp256k1_id = 0x2b8104000a | |||
91 | 91 | ||
92 | warn str = hPutStrLn stderr str | 92 | warn str = hPutStrLn stderr str |
93 | 93 | ||
94 | unprefix 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 | {- |
99 | RSAPrivateKey ::= SEQUENCE { | 96 | RSAPrivateKey ::= 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 | ||
656 | is40digitHex 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 | |||
664 | flattenKeys :: Bool -> KeyDB -> Message | 653 | flattenKeys :: Bool -> KeyDB -> Message |
665 | flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db) | 654 | flattenKeys 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 | ||
867 | parseSpec :: String -> String -> (KeySpec,Maybe String) | ||
868 | parseSpec 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 | |||
1766 | isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True | 1732 | isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True |
1767 | isTopKey _ = False | 1733 | isTopKey _ = False |
1768 | 1734 | ||
1769 | filterMatches :: KeySpec -> [(KeyKey,KeyData)] -> [(KeyKey,KeyData)] | ||
1770 | filterMatches spec ks = filter (matchSpec spec) ks | ||
1771 | |||
1772 | selectSecretKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet | 1735 | selectSecretKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet |
1773 | selectSecretKey (spec,mtag) db = selectKey0 False (spec,mtag) db | 1736 | selectSecretKey (spec,mtag) db = selectKey0 False (spec,mtag) db |
1774 | 1737 | ||