diff options
author | Joe Crayne <joe@jerkface.net> | 2020-05-10 20:58:07 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-05-10 20:58:07 -0400 |
commit | a3b9c59b4c2839a2f31a060082624937fa4e32dc (patch) | |
tree | d7f74696cdfa86fd99d269692ad5c498cf54b16f | |
parent | 71048681d402d5f692bf293a2785dc83fb32d384 (diff) |
Option to render SHA256 based fingerprints.
-rw-r--r-- | kiki.hs | 109 | ||||
-rw-r--r-- | lib/Kiki.hs | 23 | ||||
-rw-r--r-- | stack.yaml | 2 |
3 files changed, 91 insertions, 43 deletions
@@ -22,6 +22,7 @@ import Data.Maybe | |||
22 | import Data.OpenPGP | 22 | import Data.OpenPGP |
23 | import Data.Ord | 23 | import Data.Ord |
24 | import Data.String | 24 | import Data.String |
25 | import Text.Read | ||
25 | import Text.Show.Pretty as PP ( ppShow ) | 26 | import Text.Show.Pretty as PP ( ppShow ) |
26 | import Data.Text.Encoding | 27 | import Data.Text.Encoding |
27 | import System.Posix.Files | 28 | import System.Posix.Files |
@@ -45,7 +46,7 @@ import Data.Monoid ( (<>) ) | |||
45 | import Data.Binary.Put | 46 | import Data.Binary.Put |
46 | 47 | ||
47 | import CommandLine | 48 | import CommandLine |
48 | import Data.OpenPGP.Util (verify, fingerprint, GenerateKeyParams(..)) | 49 | import Data.OpenPGP.Util (verify, fingerprint, fingerprintv, GenerateKeyParams(..)) |
49 | import ScanningParser | 50 | import ScanningParser |
50 | import PEM | 51 | import PEM |
51 | import DotLock | 52 | import DotLock |
@@ -99,8 +100,8 @@ checkSelfAuthenticating parsed subs = do | |||
99 | guard (len >= 16) | 100 | guard (len >= 16) |
100 | listToMaybe $ filter match $ subkeysForDomain (uid_topdomain parsed) subs | 101 | listToMaybe $ filter match $ subkeysForDomain (uid_topdomain parsed) subs |
101 | 102 | ||
102 | listKeys :: [Packet] -> [Char] | 103 | listKeys :: FingerprintStyle -> [Packet] -> [Char] |
103 | listKeys pkts = listKeysFiltered [] pkts | 104 | listKeys style pkts = listKeysFiltered style [] pkts |
104 | 105 | ||
105 | -- | listKeysFiltered | 106 | -- | listKeysFiltered |
106 | -- @grips fingerprints of keys to show | 107 | -- @grips fingerprints of keys to show |
@@ -108,9 +109,12 @@ listKeys pkts = listKeysFiltered [] pkts | |||
108 | -- Build the display output | 109 | -- Build the display output |
109 | -- Operates in List Monad... | 110 | -- Operates in List Monad... |
110 | -- returns all output as a single string | 111 | -- returns all output as a single string |
111 | listKeysFiltered :: Foldable t => t [Char] -> [Packet] -> [Char] | 112 | listKeysFiltered :: Foldable t => FingerprintStyle -> t [Char] -> [Packet] -> [Char] |
112 | listKeysFiltered grips pkts = do | 113 | listKeysFiltered style grips pkts = do |
113 | let masterkeys = filter (\k -> isKey k && not (is_subkey k)) pkts | 114 | let fp = case style of |
115 | FingerprintAuto -> \p -> show (fingerprint p) | ||
116 | Fingerprint5 -> \p -> show (fingerprintv 5 p) | ||
117 | masterkeys = filter (\k -> isKey k && not (is_subkey k)) pkts | ||
114 | (certs,bs) = getBindings pkts | 118 | (certs,bs) = getBindings pkts |
115 | as = accBindings bs | 119 | as = accBindings bs |
116 | defaultkind (k:_) hs = k | 120 | defaultkind (k:_) hs = k |
@@ -128,11 +132,11 @@ listKeysFiltered grips pkts = do | |||
128 | matchgrip ((code,(top,sub), kind, hashed,claimants):_) | any (flip fpmatch top . Just) grips = True | 132 | matchgrip ((code,(top,sub), kind, hashed,claimants):_) | any (flip fpmatch top . Just) grips = True |
129 | matchgrip _ = False | 133 | matchgrip _ = False |
130 | gs = filter matchgrip $ groupBy sameMaster (sortBy (comparing code) as) | 134 | gs = filter matchgrip $ groupBy sameMaster (sortBy (comparing code) as) |
131 | singles = filter (\k -> show (fingerprint k) `notElem` map (show . fingerprint) parents) masterkeys -- \\ parents | 135 | singles = filter (\k -> fp k `notElem` map fp parents) masterkeys -- \\ parents |
132 | where parents = do | 136 | where parents = do |
133 | subs@((_,(top,_),_,_,_):_) <- gs | 137 | subs@((_,(top,_),_,_,_):_) <- gs |
134 | return top | 138 | return top |
135 | showsigs claimants = map (\k -> " " ++ "^ signed: " ++ show (fingerprint k)) claimants | 139 | showsigs claimants = map (\k -> " " ++ "^ signed: " ++ fp k) claimants |
136 | subs0 <- map Left gs ++ map Right singles | 140 | subs0 <- map Left gs ++ map Right singles |
137 | let (top,subs) = case subs0 of Left subs1@((_,(top0,_),_,_,_):_) -> (top0,subs1) | 141 | let (top,subs) = case subs0 of Left subs1@((_,(top0,_),_,_,_):_) -> (top0,subs1) |
138 | Right top0 -> (top0,[]) | 142 | Right top0 -> (top0,[]) |
@@ -156,7 +160,7 @@ listKeysFiltered grips pkts = do | |||
156 | , ar | 160 | , ar |
157 | , formkind | 161 | , formkind |
158 | , " " | 162 | , " " |
159 | , show $ fingerprint sub | 163 | , fp sub |
160 | , kcipher sub | 164 | , kcipher sub |
161 | -- , " " ++ (torhash sub) | 165 | -- , " " ++ (torhash sub) |
162 | -- , " " ++ (concatMap (printf "%02X") $ S.unpack (ecc_curve sub)) | 166 | -- , " " ++ (concatMap (printf "%02X") $ S.unpack (ecc_curve sub)) |
@@ -191,7 +195,7 @@ listKeysFiltered grips pkts = do | |||
191 | checkSelfAuthenticating parsed subs | 195 | checkSelfAuthenticating parsed subs |
192 | unlines $ (" " ++ ar ++ "@" ++ " " ++ uid_full parsed) : showsigs secondary | 196 | unlines $ (" " ++ ar ++ "@" ++ " " ++ uid_full parsed) : showsigs secondary |
193 | -- (_,sigs) = unzip certs | 197 | -- (_,sigs) = unzip certs |
194 | "master-key " ++ show (fingerprint top) ++ kcipher top ++ "\n" ++ uid ++" ...\n" ++ subkeys ++ "\n" | 198 | "master-key " ++ fp top ++ kcipher top ++ "\n" ++ uid ++" ...\n" ++ subkeys ++ "\n" |
195 | 199 | ||
196 | 200 | ||
197 | {- | 201 | {- |
@@ -219,8 +223,8 @@ toLast f [x] = [f x] | |||
219 | toLast f (x:xs) = x : toLast f xs | 223 | toLast f (x:xs) = x : toLast f xs |
220 | 224 | ||
221 | -- partitionStaticArguments :: Ord a => [(a, Int)] -> [a] -> ([[a]], [a]) | 225 | -- partitionStaticArguments :: Ord a => [(a, Int)] -> [a] -> ([[a]], [a]) |
222 | partitionStaticArguments :: [([Char], Int)] | 226 | partitionStaticArguments :: [(String, Int)] |
223 | -> [[Char]] -> ([[[Char]]], [[Char]]) | 227 | -> [String] -> ([[String]], [String]) |
224 | partitionStaticArguments specs args = psa args | 228 | partitionStaticArguments specs args = psa args |
225 | where | 229 | where |
226 | smap = Map.fromList specs | 230 | smap = Map.fromList specs |
@@ -233,15 +237,16 @@ partitionStaticArguments specs args = psa args | |||
233 | Nothing -> second (a:) $ psa as | 237 | Nothing -> second (a:) $ psa as |
234 | Just n -> first ((a:take n as):) $ psa (drop n as) | 238 | Just n -> first ((a:take n as):) $ psa (drop n as) |
235 | 239 | ||
236 | show_wk :: FilePath | 240 | show_wk :: FingerprintStyle |
241 | -> FilePath | ||
237 | -> Maybe [Char] -> KeyDB -> IO () | 242 | -> Maybe [Char] -> KeyDB -> IO () |
238 | show_wk secring_file grip db = do | 243 | show_wk style secring_file grip db = do |
239 | -- printf "show_wk(%s,%s,%s)\n" (show secring_file) (show grip) (show db) | 244 | -- printf "show_wk(%s,%s,%s)\n" (show secring_file) (show grip) (show db) |
240 | let gripmatch (KeyData p _ _ _) = | 245 | let gripmatch (KeyData p _ _ _) = |
241 | Map.member secring_file (locations p) | 246 | Map.member secring_file (locations p) |
242 | || Map.member "&secret" (locations p) | 247 | || Map.member "&secret" (locations p) |
243 | Message sec = flattenFiltered False gripmatch db | 248 | Message sec = flattenFiltered False gripmatch db |
244 | putStrLn $ listKeysFiltered (maybeToList grip) sec | 249 | putStrLn $ listKeysFiltered style (maybeToList grip) sec |
245 | 250 | ||
246 | debug_dump :: FilePath -> p -> KeyDB -> IO () | 251 | debug_dump :: FilePath -> p -> KeyDB -> IO () |
247 | debug_dump secring_file grip db = do | 252 | debug_dump secring_file grip db = do |
@@ -251,10 +256,10 @@ debug_dump secring_file grip db = do | |||
251 | Message sec = flattenFiltered False gripmatch db | 256 | Message sec = flattenFiltered False gripmatch db |
252 | mapM_ print sec | 257 | mapM_ print sec |
253 | 258 | ||
254 | show_all :: KeyDB -> IO () | 259 | show_all :: FingerprintStyle -> KeyDB -> IO () |
255 | show_all db = do | 260 | show_all style db = do |
256 | let Message packets = flattenFiltered True (const True) db | 261 | let Message packets = flattenFiltered True (const True) db |
257 | putStrLn $ listKeys packets | 262 | putStrLn $ listKeys style packets |
258 | 263 | ||
259 | show_packets :: (Eq a, IsString a) => | 264 | show_packets :: (Eq a, IsString a) => |
260 | [a] -> KeyDB -> IO () | 265 | [a] -> KeyDB -> IO () |
@@ -298,15 +303,15 @@ dnsPresentationFromPacket k = do | |||
298 | 303 | ||
299 | ] | 304 | ] |
300 | 305 | ||
301 | show_id :: String -> p -> KeyDB -> IO () | 306 | show_id :: FingerprintStyle -> String -> p -> KeyDB -> IO () |
302 | show_id keyspec wkgrip db = do | 307 | show_id style keyspec wkgrip db = do |
303 | let s = parseSpec "" keyspec | 308 | let s = parseSpec "" keyspec |
304 | let ps = do | 309 | let ps = do |
305 | (_,k) <- filterMatches (fst s) (kkData db) | 310 | (_,k) <- filterMatches (fst s) (kkData db) |
306 | mp <- flattenTop "" True k | 311 | mp <- flattenTop "" True k |
307 | return $ packet mp | 312 | return $ packet mp |
308 | -- putStrLn $ "show key " ++ show s | 313 | -- putStrLn $ "show key " ++ show s |
309 | putStrLn $ listKeys ps | 314 | putStrLn $ listKeys style ps |
310 | 315 | ||
311 | show_wip :: [Char] -> String -> KeyDB -> IO () | 316 | show_wip :: [Char] -> String -> KeyDB -> IO () |
312 | show_wip keyspec wkgrip db = do | 317 | show_wip keyspec wkgrip db = do |
@@ -655,6 +660,9 @@ kiki_usage ((== Export) -> bExport) ((== Import) -> bImport) ((== Secret) -> bSe | |||
655 | ," --trace-verify" | 660 | ," --trace-verify" |
656 | ," For debugging, stderr traces for every signature verification." | 661 | ," For debugging, stderr traces for every signature verification." |
657 | ,"" | 662 | ,"" |
663 | ," --fingerprint=5" | ||
664 | ," Use SHA256-based (PGP v5) fingerprints even for PGP v4 key packets." | ||
665 | ,"" | ||
658 | ] ++ documentHomeDir ++ [""] | 666 | ] ++ documentHomeDir ++ [""] |
659 | ++ documentPassphraseFDFlag bExport bImport bSecret | 667 | ++ documentPassphraseFDFlag bExport bImport bSecret |
660 | showwk :: [String] | 668 | showwk :: [String] |
@@ -941,6 +949,12 @@ documentHostsOption bExport bImport bSecret = | |||
941 | ,""] | 949 | ,""] |
942 | 950 | ||
943 | 951 | ||
952 | commonArgSpec :: [(String,Int)] | ||
953 | commonArgSpec = [ ("--homedir",1) | ||
954 | , ("--passphrase-fd",1) | ||
955 | , ("--fingerprint",1) | ||
956 | , ("--help",0) | ||
957 | ] | ||
944 | 958 | ||
945 | -- | | 959 | -- | |
946 | -- Arguments: | 960 | -- Arguments: |
@@ -964,10 +978,6 @@ processArgs sargspec polyVariadicArgs defaultPoly args_raw = (sargs,margs) | |||
964 | where | 978 | where |
965 | (args,trail1) = break (=="--") args_raw | 979 | (args,trail1) = break (=="--") args_raw |
966 | trail = drop 1 trail1 | 980 | trail = drop 1 trail1 |
967 | commonArgSpec = [ ("--homedir",1) | ||
968 | , ("--passphrase-fd",1) | ||
969 | , ("--help",0) | ||
970 | ] | ||
971 | sargspec' = commonArgSpec ++ sargspec | 981 | sargspec' = commonArgSpec ++ sargspec |
972 | (sargs,margs) = | 982 | (sargs,margs) = |
973 | (sargs, foldl' (\m (k:xs)->Map.alter (appendArgs k xs) k m) | 983 | (sargs, foldl' (\m (k:xs)->Map.alter (appendArgs k xs) k m) |
@@ -991,10 +1001,14 @@ processArgs sargspec polyVariadicArgs defaultPoly args_raw = (sargs,margs) | |||
991 | 1001 | ||
992 | parseCommonArgs :: (Ord k, IsString k) => | 1002 | parseCommonArgs :: (Ord k, IsString k) => |
993 | Map.Map k [[Char]] -> CommonArgsParsed | 1003 | Map.Map k [[Char]] -> CommonArgsParsed |
994 | parseCommonArgs margs = CommonArgsParsed { cap_homespec = homespec, cap_passfd = passfd } | 1004 | parseCommonArgs margs = CommonArgsParsed |
1005 | { cap_homespec = homespec | ||
1006 | , cap_passfd = passfd | ||
1007 | , cap_fpstyle = style } | ||
995 | where | 1008 | where |
996 | passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs | 1009 | passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs |
997 | homespec = join . take 1 <$> Map.lookup "--homedir" margs | 1010 | homespec = join . take 1 <$> Map.lookup "--homedir" margs |
1011 | style = maybe FingerprintAuto read $ join . take 1 <$> Map.lookup "--fingerprint" margs | ||
998 | passfd = fmap (FileDesc . read) passphrase_fd | 1012 | passfd = fmap (FileDesc . read) passphrase_fd |
999 | 1013 | ||
1000 | parseKeySpecs :: [String] -> [Maybe (String,String,String)] | 1014 | parseKeySpecs :: [String] -> [Maybe (String,String,String)] |
@@ -1060,6 +1074,9 @@ moreSync :: [Maybe (String, String, String)] -> Map.Map String [FilePath] -> May | |||
1060 | moreSync keypairs0 margs passphrase_fd bExport bImport bSecret cmdarg keyrings_ wallets sargs = do | 1074 | moreSync keypairs0 margs passphrase_fd bExport bImport bSecret cmdarg keyrings_ wallets sargs = do |
1061 | let keypairs = catMaybes keypairs0 | 1075 | let keypairs = catMaybes keypairs0 |
1062 | homespec = join . take 1 <$> Map.lookup "--homedir" margs | 1076 | homespec = join . take 1 <$> Map.lookup "--homedir" margs |
1077 | style = fromMaybe FingerprintAuto $ do | ||
1078 | fs <- Map.lookup "--fingerprint" margs | ||
1079 | readMaybe $ concat $ take 1 fs | ||
1063 | passfd = fmap (FileDesc . read) passphrase_fd | 1080 | passfd = fmap (FileDesc . read) passphrase_fd |
1064 | -- reftyp is used as value for 'fill field' in StreamInfo, walts and rings | 1081 | -- reftyp is used as value for 'fill field' in StreamInfo, walts and rings |
1065 | reftyp | bExport == Export = KF_Subkeys -- export to rings when they have master present | 1082 | reftyp | bExport == Export = KF_Subkeys -- export to rings when they have master present |
@@ -1111,16 +1128,16 @@ moreSync keypairs0 margs passphrase_fd bExport bImport bSecret cmdarg keyrings_ | |||
1111 | , opHome = homespec | 1128 | , opHome = homespec |
1112 | } | 1129 | } |
1113 | let usage f = maybe f (const $ kiki_usage bExport bImport bSecret cmdarg) $ Map.lookup "--help" margs | 1130 | let usage f = maybe f (const $ kiki_usage bExport bImport bSecret cmdarg) $ Map.lookup "--help" margs |
1114 | usage $ moreMoreSync kikiOp sargs | 1131 | usage $ moreMoreSync style kikiOp sargs |
1115 | 1132 | ||
1116 | moreMoreSync :: KeyRingOperation -> [[String]] -> IO () | 1133 | moreMoreSync :: FingerprintStyle -> KeyRingOperation -> [[String]] -> IO () |
1117 | moreMoreSync kikiOp sargs = do | 1134 | moreMoreSync style kikiOp sargs = do |
1118 | KikiResult rt report <- runKeyRing kikiOp | 1135 | KikiResult rt report <- runKeyRing kikiOp |
1119 | 1136 | ||
1120 | case rt of | 1137 | case rt of |
1121 | KikiSuccess rt -> do -- interpret --show-* commands. | 1138 | KikiSuccess rt -> do -- interpret --show-* commands. |
1122 | let grip = rtGrip rt | 1139 | let grip = rtGrip rt |
1123 | let shspec = Map.fromList [("--show-wk", const $ show_wk (rtSecring rt) grip) | 1140 | let shspec = Map.fromList [("--show-wk", const $ show_wk style (rtSecring rt) grip) |
1124 | {-,("--show-all",const show_all) | 1141 | {-,("--show-all",const show_all) |
1125 | ,("--show-whose-key", const $ show_whose_key input_key) | 1142 | ,("--show-whose-key", const $ show_whose_key input_key) |
1126 | ,("--show-key",\[x] -> show_id x $ fromMaybe "" grip) | 1143 | ,("--show-key",\[x] -> show_id x $ fromMaybe "" grip) |
@@ -1192,9 +1209,12 @@ kiki "help" args = forM_ args $ \arg -> case lookup arg commands of | |||
1192 | Nothing -> putStrLn $ "No help available for commmand '" ++ arg ++ "'." | 1209 | Nothing -> putStrLn $ "No help available for commmand '" ++ arg ++ "'." |
1193 | _ -> kiki arg ["--help"] | 1210 | _ -> kiki arg ["--help"] |
1194 | 1211 | ||
1195 | kiki "show" [] = kiki "show" ["--working"] | ||
1196 | kiki "show" args = do | 1212 | kiki "show" args = do |
1197 | let (sargs,margs) = processArgs sargspec polyVariadicArgs "--show" args | 1213 | let (sargs0,margs) = processArgs sargspec polyVariadicArgs "--show" args |
1214 | notCommon xss = concat (take 1 xss) `notElem` map fst commonArgSpec | ||
1215 | sargs = case filter notCommon sargs0 of | ||
1216 | [] -> ["--working"] : sargs0 | ||
1217 | _ -> sargs0 | ||
1198 | sargspec = [ ("--working",0) --("--show-wk",0) | 1218 | sargspec = [ ("--working",0) --("--show-wk",0) |
1199 | , ("--dump",0) --("--show-all",0) | 1219 | , ("--dump",0) --("--show-all",0) |
1200 | , ("--all",0) --("--show-all",0) | 1220 | , ("--all",0) --("--show-all",0) |
@@ -1249,11 +1269,11 @@ kiki "show" args = do | |||
1249 | case rt of | 1269 | case rt of |
1250 | KikiSuccess rt -> do -- interpret --show-* commands. | 1270 | KikiSuccess rt -> do -- interpret --show-* commands. |
1251 | let grip = rtGrip rt | 1271 | let grip = rtGrip rt |
1252 | let shspec = Map.fromList [("--working", const $ show_wk (rtSecring rt) grip) | 1272 | let shspec = Map.fromList [("--working", const $ show_wk (cap_fpstyle cap) (rtSecring rt) grip) |
1253 | ,("--all",const show_all) | 1273 | ,("--all",const (show_all (cap_fpstyle cap))) |
1254 | ,("--whose-key", const $ show_whose_key input_key) | 1274 | ,("--whose-key", const $ show_whose_key input_key) |
1255 | ,("--packets", show_packets) | 1275 | ,("--packets", show_packets) |
1256 | ,("--key",\[x] -> show_id x $ fromMaybe "" grip) | 1276 | ,("--key",\[x] -> show_id (cap_fpstyle cap) x $ fromMaybe "" grip) |
1257 | ,("--pem",\[x] -> show_pem x $ fromMaybe "" grip) | 1277 | ,("--pem",\[x] -> show_pem x $ fromMaybe "" grip) |
1258 | ,("--dns",\[x] -> show_dns x $ fromMaybe "" grip) | 1278 | ,("--dns",\[x] -> show_dns x $ fromMaybe "" grip) |
1259 | ,("--ssh",\[x] -> show_ssh x $ fromMaybe "" grip) | 1279 | ,("--ssh",\[x] -> show_ssh x $ fromMaybe "" grip) |
@@ -1343,15 +1363,15 @@ kiki "merge" args = do | |||
1343 | case rt of | 1363 | case rt of |
1344 | KikiSuccess rt -> do let db = rtKeyDB rt | 1364 | KikiSuccess rt -> do let db = rtKeyDB rt |
1345 | if bShowAll | 1365 | if bShowAll |
1346 | then show_all db | 1366 | then show_all style db |
1347 | else forM_ keyspecs $ \keyspec -> do | 1367 | else forM_ keyspecs $ \keyspec -> do |
1348 | show_id keyspec (error "show_id wkgrip") db | 1368 | show_id style keyspec (error "show_id wkgrip") db |
1349 | when bPackets $ show_packets [] db | 1369 | when bPackets $ show_packets [] db |
1350 | err -> putStrLn $ errorString err | 1370 | err -> putStrLn $ errorString err |
1351 | forM_ report $ \(fname,act) -> do | 1371 | forM_ report $ \(fname,act) -> do |
1352 | putStrLn $ fname ++ ": " ++ reportString act | 1372 | putStrLn $ fname ++ ": " ++ reportString act |
1353 | where | 1373 | where |
1354 | (_,((_,keyspecs),op)) = foldl' buildOp (True,((flow0,[]),noop)) args3 | 1374 | (_,((_,keyspecs),op)) = foldl' buildOp (True,((flow0,[]),noop)) args4 |
1355 | (args',mbAgent) = case break (=="--agent") args of | 1375 | (args',mbAgent) = case break (=="--agent") args of |
1356 | (as,[]) -> (as, id) | 1376 | (as,[]) -> (as, id) |
1357 | (as,_:bs) -> ( as++bs | 1377 | (as,_:bs) -> ( as++bs |
@@ -1362,6 +1382,10 @@ kiki "merge" args = do | |||
1362 | (args3,bPackets) = case break (=="--packets") args'' of | 1382 | (args3,bPackets) = case break (=="--packets") args'' of |
1363 | (as,[]) -> (as, False) | 1383 | (as,[]) -> (as, False) |
1364 | (as,_:bs) -> (as++bs, True) | 1384 | (as,_:bs) -> (as++bs, True) |
1385 | (args4,style) = case break (=="--fingerprint") args3 of | ||
1386 | (as,b:bs) | Just s <- readMaybe b | ||
1387 | -> (as++bs, s) | ||
1388 | (as,[]) -> (as, FingerprintAuto) | ||
1365 | noop = KeyRingOperation | 1389 | noop = KeyRingOperation |
1366 | { opFiles = Map.empty | 1390 | { opFiles = Map.empty |
1367 | , opTransforms = [] | 1391 | , opTransforms = [] |
@@ -1712,7 +1736,14 @@ main = do | |||
1712 | return $ as ++ bs | 1736 | return $ as ++ bs |
1713 | case args_raw of | 1737 | case args_raw of |
1714 | 1738 | ||
1715 | [] -> kiki "show" ["--working"] | 1739 | [] -> kiki "show" args_raw |
1740 | |||
1741 | ["--help"] -> do | ||
1742 | putStrLn "Showing help for the default \"show\" command." | ||
1743 | putStrLn "Use \"help\" without leading hyphens to see other available commands." | ||
1744 | putStrLn "\n" | ||
1745 | kiki "show" args_raw | ||
1746 | ('-':_):_ -> kiki "show" args_raw | ||
1716 | 1747 | ||
1717 | cmd : args | cmd `elem` map fst commands | 1748 | cmd : args | cmd `elem` map fst commands |
1718 | -> kiki cmd args | 1749 | -> kiki cmd args |
diff --git a/lib/Kiki.hs b/lib/Kiki.hs index f89aad2..96ad9ff 100644 --- a/lib/Kiki.hs +++ b/lib/Kiki.hs | |||
@@ -49,7 +49,7 @@ import qualified SSHKey as SSH | |||
49 | import CommandLine | 49 | import CommandLine |
50 | import DotLock | 50 | import DotLock |
51 | import GnuPGAgent (Query (..)) | 51 | import GnuPGAgent (Query (..)) |
52 | import qualified IntMapClass as I | 52 | -- import qualified IntMapClass as I |
53 | import KeyRing hiding (pemFromPacket) | 53 | import KeyRing hiding (pemFromPacket) |
54 | import KeyDB | 54 | import KeyDB |
55 | import KeyRing.BuildKeyDB (gpgipv6addr, Hostnames, allNames) | 55 | import KeyRing.BuildKeyDB (gpgipv6addr, Hostnames, allNames) |
@@ -104,7 +104,22 @@ refresh root homepass = do | |||
104 | KikiSuccess rt -> refreshCache rt mroot | 104 | KikiSuccess rt -> refreshCache rt mroot |
105 | _ -> return () -- XXX: silent fail? | 105 | _ -> return () -- XXX: silent fail? |
106 | 106 | ||
107 | data CommonArgsParsed = CommonArgsParsed { cap_homespec :: Maybe String, cap_passfd :: Maybe InputFile } | 107 | data CommonArgsParsed = CommonArgsParsed |
108 | { cap_homespec :: Maybe String | ||
109 | , cap_passfd :: Maybe InputFile | ||
110 | , cap_fpstyle :: FingerprintStyle | ||
111 | } | ||
112 | |||
113 | data FingerprintStyle | ||
114 | = FingerprintAuto | ||
115 | | Fingerprint5 | ||
116 | deriving (Eq,Ord,Show) | ||
117 | |||
118 | instance Read FingerprintStyle where | ||
119 | readsPrec _ s = case break isSpace s of | ||
120 | ("auto",t) -> [(FingerprintAuto, drop 1 t)] | ||
121 | ("5",t) -> [(Fingerprint5, drop 1 t)] | ||
122 | _ -> [] | ||
108 | 123 | ||
109 | streaminfo :: StreamInfo | 124 | streaminfo :: StreamInfo |
110 | streaminfo = StreamInfo | 125 | streaminfo = StreamInfo |
@@ -519,7 +534,8 @@ refreshCache rt rootdir = do | |||
519 | let exportOp = passphrases <> pemSecrets | 534 | let exportOp = passphrases <> pemSecrets |
520 | <> minimalOp False | 535 | <> minimalOp False |
521 | (CommonArgsParsed (Just $ takeDirectory $ rtPubring rt) | 536 | (CommonArgsParsed (Just $ takeDirectory $ rtPubring rt) |
522 | Nothing) | 537 | Nothing |
538 | FingerprintAuto) | ||
523 | where | 539 | where |
524 | passphrases = mempty { opPassphrases = [PassphraseMemoizer (rtPassphrases rt)] } | 540 | passphrases = mempty { opPassphrases = [PassphraseMemoizer (rtPassphrases rt)] } |
525 | pemSecrets = mempty { opFiles = Map.fromList | 541 | pemSecrets = mempty { opFiles = Map.fromList |
@@ -712,6 +728,7 @@ dashdashHomedir :: Args CommonArgsParsed | |||
712 | dashdashHomedir = CommonArgsParsed | 728 | dashdashHomedir = CommonArgsParsed |
713 | <$> optional (arg "--homedir") | 729 | <$> optional (arg "--homedir") |
714 | <*> optional (FileDesc <$> read <$> arg "--passphrase-fd") | 730 | <*> optional (FileDesc <$> read <$> arg "--passphrase-fd") |
731 | <*> (fromMaybe FingerprintAuto <$> optional (read <$> arg "--fingerprint")) | ||
715 | 732 | ||
716 | dashdashCipher :: Args SymmetricAlgorithm | 733 | dashdashCipher :: Args SymmetricAlgorithm |
717 | dashdashCipher = fromMaybe CAST5 <$> optional (cipherFromString <$> arg "--cipher") | 734 | dashdashCipher = fromMaybe CAST5 <$> optional (cipherFromString <$> arg "--cipher") |
@@ -4,7 +4,7 @@ packages: | |||
4 | extra-deps: | 4 | extra-deps: |
5 | # - ../openpgp-util | 5 | # - ../openpgp-util |
6 | - git: d@cryptonomic.net:public_git/openpgp-util.git | 6 | - git: d@cryptonomic.net:public_git/openpgp-util.git |
7 | commit: 02680b1ed3b37c0cc16e04e51e613d53ff9dbab8 | 7 | commit: 47fdd273f68e0af73595daa1f3a9cdff2c8a9320 |
8 | - git: d@cryptonomic.net:public_git/openpgp-asciiarmor.git | 8 | - git: d@cryptonomic.net:public_git/openpgp-asciiarmor.git |
9 | commit: 9694b1b6ae3763c44d3b1361b5faa0a7b27e77a9 | 9 | commit: 9694b1b6ae3763c44d3b1361b5faa0a7b27e77a9 |
10 | - modular-arithmetic-1.2.1.5 | 10 | - modular-arithmetic-1.2.1.5 |