summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-10-05 19:03:34 -0400
committerjoe <joe@jerkface.net>2013-10-05 19:03:34 -0400
commit749306b18c26c868b1653e854a51ad7f6bf83cb9 (patch)
tree56edbba538ea318f86b4011d490f4b13d2c862a7
parent9454d4571d6098c390dbf9920493a5deb8a26a30 (diff)
Implemented public command which recovers a public ring from a secret
one.
-rw-r--r--keys.hs32
1 files 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
81 Left (_,_,_) -> return [] 81 Left (_,_,_) -> return []
82 82
83 83
84secretToPublic pkt@(SecretKeyPacket {}) =
85 PublicKeyPacket { version = version pkt
86 , timestamp = timestamp pkt
87 , key_algorithm = key_algorithm pkt
88 , key = let seckey = key pkt
89 pubs = public_key_fields (key_algorithm pkt)
90 in filter (\(k,v) -> k `elem` pubs) seckey
91 , is_subkey = is_subkey pkt
92 , v3_days_of_validity = Nothing
93 }
94secretToPublic pkt = pkt
95
84isKey (PublicKeyPacket {}) = True 96isKey (PublicKeyPacket {}) = True
85isKey (SecretKeyPacket {}) = True 97isKey (SecretKeyPacket {}) = True
86isKey _ = False 98isKey _ = False
@@ -585,6 +597,8 @@ data Arguments =
585 , passphrase_fd :: Maybe Int 597 , passphrase_fd :: Maybe Int
586 , input :: FilePath 598 , input :: FilePath
587 , output :: FilePath} 599 , output :: FilePath}
600 | Public { homedir :: Maybe FilePath
601 , output :: FilePath}
588 deriving (Show, Data, Typeable) 602 deriving (Show, Data, Typeable)
589 603
590#define HOMEOPTION (def &= explicit &= name "homedir" &= typDir ) 604#define HOMEOPTION (def &= explicit &= name "homedir" &= typDir )
@@ -598,14 +612,17 @@ main = do
598 &= help "Shows the current working key set that will be used to make signatures." 612 &= help "Shows the current working key set that will be used to make signatures."
599 , AutoSign HOMEOPTION 613 , AutoSign HOMEOPTION
600 (def &= opt ("passphrase"::String) 614 (def &= opt ("passphrase"::String)
601 &= help (unlines ["file descriptor from" 615 &= (help . concat) ["file descriptor from"
602 ,"which to read passphrase"])) 616 ,"which to read passphrase"])
603 (def &= argPos 1 &= typFile ) 617 (def &= argPos 1 &= typFile )
604 (def &=argPos 2 &= typFile) 618 (def &=argPos 2 &= typFile)
605 &= (help . concat) 619 &= (help . concat)
606 [ "Copies the first file to the second while adding" 620 [ "Copies the first file to the second while adding"
607 , " signatures for tor-style uids that match" 621 , " signatures for tor-style uids that match"
608 , " cross-certified keys." ] 622 , " cross-certified keys." ]
623 , Public HOMEOPTION
624 (def &= argPos 1 &= typFile )
625 &= help "Extract public keys into the given file."
609 ] 626 ]
610 &= program "keys" 627 &= program "keys"
611 &= summary "keys - a pgp key editing utility" 628 &= summary "keys - a pgp key editing utility"
@@ -797,6 +814,17 @@ main = do
797 let signed_bs = encode (Message pub') 814 let signed_bs = encode (Message pub')
798 L.writeFile (output cmd) signed_bs 815 L.writeFile (output cmd) signed_bs
799 816
817 doCmd cmd@(Public {}) = do
818 ( homedir -- e3ozbhvej4jvlu43.onion/gpg/gnupghome
819 , sec -- e3ozbhvej4jvlu43.onion/gpg/gnupghome/secring.gpg
820 , grip -- Just "AD1CA892FCF4ED9829C762269BDEA5B4D5643321"
821 ) <- getPGPEnviron cmd
822 let pub = map secretToPublic sec
823 bs = encode (Message pub)
824 L.writeFile (output cmd) bs
825
826
827
800groupBindings pub = 828groupBindings pub =
801 let (sigs,bindings) = getBindings pub 829 let (sigs,bindings) = getBindings pub
802 bindings' = accBindings bindings 830 bindings' = accBindings bindings