summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-05-04 19:31:13 -0400
committerjoe <joe@jerkface.net>2014-05-04 19:31:13 -0400
commit8ce5dba16886a1b19f5254e8d62810c303215387 (patch)
tree3cbe83e0133698b6b1ddb5a7d4509c2cdd85ba0b /kiki.hs
parent8eaa721b660d94fac606ff9907a2f6e98a879e45 (diff)
Address interface changes and warnings in kiki.hs
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs48
1 files changed, 13 insertions, 35 deletions
diff --git a/kiki.hs b/kiki.hs
index 19d8beb..1e4f1e4 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -32,7 +32,6 @@ import qualified Data.ByteString as S
32import qualified Data.ByteString.Lazy as L 32import qualified Data.ByteString.Lazy as L
33import qualified Data.ByteString.Lazy.Char8 as Char8 33import qualified Data.ByteString.Lazy.Char8 as Char8
34import qualified Data.Map as Map 34import qualified Data.Map as Map
35import qualified Data.Text as T
36import Control.Arrow (first,second) 35import Control.Arrow (first,second)
37import Data.Binary.Get (runGet) 36import Data.Binary.Get (runGet)
38import Data.Binary.Put (putWord32be,runPut,putByteString) 37import Data.Binary.Put (putWord32be,runPut,putByteString)
@@ -598,37 +597,6 @@ kiki_usage bSecret cmd = putStr $
598 ," 5E24CD442AA6965D2012E62A905C24185D5379C2" 597 ," 5E24CD442AA6965D2012E62A905C24185D5379C2"
599 ] 598 ]
600 599
601doAutosign rt kd@(KeyData k ksigs umap submap) = ops
602 where
603 ops = map (\u -> InducerSignature u []) us
604 us = filter torStyle $ Map.keys umap
605 torStyle str = and [ uid_topdomain parsed == "onion"
606 , uid_realname parsed `elem` ["","Anonymous"]
607 , uid_user parsed == "root"
608 , fmap (match . fst) (lookup (packet k) torbindings)
609 == Just True ]
610 where parsed = parseUID str
611 match = (==subdom) . take (fromIntegral len)
612 subdom0 = L.fromChunks [encodeUtf8 (uid_subdomain parsed)]
613 subdom = Char8.unpack subdom0
614 len = T.length (uid_subdomain parsed)
615 torbindings = getTorKeys (map packet $ flattenTop "" True kd)
616 getTorKeys pub = do
617 xs <- groupBindings pub
618 (_,(top,sub),us,_,_) <- xs
619 guard ("tor" `elem` us)
620 let torhash = fromMaybe "" $ derToBase32 <$> derRSA sub
621 return (top,(torhash,sub))
622
623 groupBindings pub = gs
624 where (_,bindings) = getBindings pub
625 bindings' = accBindings bindings
626 code (c,(m,s),_,_,_) = (fingerprint_material m,-c)
627 ownerkey (_,(a,_),_,_,_) = a
628 sameMaster (ownerkey->a) (ownerkey->b)
629 = fingerprint_material a==fingerprint_material b
630 gs = groupBy sameMaster (sortBy (comparing code) bindings')
631
632processArgs sargspec polyVariadicArgs defaultPoly args_raw = (sargs,margs) 600processArgs sargspec polyVariadicArgs defaultPoly args_raw = (sargs,margs)
633 where 601 where
634 (args,trail1) = break (=="--") args_raw 602 (args,trail1) = break (=="--") args_raw
@@ -725,7 +693,9 @@ sync bExport bImport bSecret cmdarg args_raw = do
725 , spill = KF_Match usage 693 , spill = KF_Match usage
726 , typ = PEMFile 694 , typ = PEMFile
727 , access = Sec 695 , access = Sec
728 , initializer = cmd' }) 696 , initializer = cmd'
697 , transforms = []
698 } )
729 else if isNothing cmd' 699 else if isNothing cmd'
730 then ( ArgFile path 700 then ( ArgFile path
731 , (buildStreamInfo KF_None PEMFile) 701 , (buildStreamInfo KF_None PEMFile)
@@ -750,7 +720,8 @@ sync bExport bImport bSecret cmdarg args_raw = do
750 , fill = rtyp 720 , fill = rtyp
751 , spill = KF_All 721 , spill = KF_All
752 , access = AutoAccess 722 , access = AutoAccess
753 , initializer = Nothing } 723 , initializer = Nothing
724 , transforms = [] }
754 kikiOp = KeyRingOperation 725 kikiOp = KeyRingOperation
755 { opFiles = Map.fromList $ 726 { opFiles = Map.fromList $
756 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All 727 [ ( HomeSec, buildStreamInfo (if bSecret && bImport then KF_All
@@ -764,7 +735,10 @@ sync bExport bImport bSecret cmdarg args_raw = do
764 ++ if bSecret then pems else [] 735 ++ if bSecret then pems else []
765 ++ if bSecret then walts else [] 736 ++ if bSecret then walts else []
766 ++ hosts 737 ++ hosts
767 , kManip = maybe noManip (const doAutosign) $ Map.lookup "--autosign" margs 738 , opPassphrases = do pfile <- maybeToList passfd
739 return $ PassphraseSpec Nothing Nothing pfile
740 , opTransforms = maybe [] (const [Autosign]) $ Map.lookup "--autosign" margs
741 , kManip = noManip
768 , opHome = homespec 742 , opHome = homespec
769 } 743 }
770 744
@@ -856,6 +830,7 @@ kiki "show" args = do
856 , spill = KF_All 830 , spill = KF_All
857 , initializer = Nothing 831 , initializer = Nothing
858 , access = AutoAccess 832 , access = AutoAccess
833 , transforms = []
859 } 834 }
860 kikiOp = KeyRingOperation 835 kikiOp = KeyRingOperation
861 { opFiles = Map.fromList $ 836 { opFiles = Map.fromList $
@@ -866,6 +841,9 @@ kiki "show" args = do
866 ++ pems 841 ++ pems
867 ++ walts 842 ++ walts
868 ++ hosts 843 ++ hosts
844 , opPassphrases = do pfile <- maybeToList passfd
845 return $ PassphraseSpec Nothing Nothing pfile
846 , opTransforms = []
869 , kManip = noManip 847 , kManip = noManip
870 , opHome = homespec 848 , opHome = homespec
871 } 849 }