From 749306b18c26c868b1653e854a51ad7f6bf83cb9 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 5 Oct 2013 19:03:34 -0400 Subject: Implemented public command which recovers a public ring from a secret one. --- keys.hs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/keys.hs b/keys.hs index 844b544..10bec0c 100644 --- a/keys.hs +++ b/keys.hs @@ -81,6 +81,18 @@ getPackets = do Left (_,_,_) -> return [] +secretToPublic pkt@(SecretKeyPacket {}) = + PublicKeyPacket { version = version pkt + , timestamp = timestamp pkt + , key_algorithm = key_algorithm pkt + , key = let seckey = key pkt + pubs = public_key_fields (key_algorithm pkt) + in filter (\(k,v) -> k `elem` pubs) seckey + , is_subkey = is_subkey pkt + , v3_days_of_validity = Nothing + } +secretToPublic pkt = pkt + isKey (PublicKeyPacket {}) = True isKey (SecretKeyPacket {}) = True isKey _ = False @@ -585,6 +597,8 @@ data Arguments = , passphrase_fd :: Maybe Int , input :: FilePath , output :: FilePath} + | Public { homedir :: Maybe FilePath + , output :: FilePath} deriving (Show, Data, Typeable) #define HOMEOPTION (def &= explicit &= name "homedir" &= typDir ) @@ -598,14 +612,17 @@ main = do &= help "Shows the current working key set that will be used to make signatures." , AutoSign HOMEOPTION (def &= opt ("passphrase"::String) - &= help (unlines ["file descriptor from" - ,"which to read passphrase"])) + &= (help . concat) ["file descriptor from" + ,"which to read passphrase"]) (def &= argPos 1 &= typFile ) (def &=argPos 2 &= typFile) &= (help . concat) [ "Copies the first file to the second while adding" , " signatures for tor-style uids that match" , " cross-certified keys." ] + , Public HOMEOPTION + (def &= argPos 1 &= typFile ) + &= help "Extract public keys into the given file." ] &= program "keys" &= summary "keys - a pgp key editing utility" @@ -797,6 +814,17 @@ main = do let signed_bs = encode (Message pub') L.writeFile (output cmd) signed_bs + doCmd cmd@(Public {}) = do + ( homedir -- e3ozbhvej4jvlu43.onion/gpg/gnupghome + , sec -- e3ozbhvej4jvlu43.onion/gpg/gnupghome/secring.gpg + , grip -- Just "AD1CA892FCF4ED9829C762269BDEA5B4D5643321" + ) <- getPGPEnviron cmd + let pub = map secretToPublic sec + bs = encode (Message pub) + L.writeFile (output cmd) bs + + + groupBindings pub = let (sigs,bindings) = getBindings pub bindings' = accBindings bindings -- cgit v1.2.3