diff options
Diffstat (limited to 'lib/KeyRing.hs')
-rw-r--r-- | lib/KeyRing.hs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs index 3a4bdc6..515faf6 100644 --- a/lib/KeyRing.hs +++ b/lib/KeyRing.hs | |||
@@ -112,8 +112,10 @@ import Debug.Trace | |||
112 | #endif | 112 | #endif |
113 | import Network.Socket -- (SockAddr) | 113 | import Network.Socket -- (SockAddr) |
114 | import qualified Data.ByteString.Lazy.Char8 as Char8 | 114 | import qualified Data.ByteString.Lazy.Char8 as Char8 |
115 | import Compat | 115 | import qualified Codec.Encryption.OpenPGP.ASCIIArmor as ASCIIArmor |
116 | import Codec.Encryption.OpenPGP.ASCIIArmor.Types | ||
116 | 117 | ||
118 | import Compat | ||
117 | import TimeUtil | 119 | import TimeUtil |
118 | import PEM | 120 | import PEM |
119 | import ScanningParser | 121 | import ScanningParser |
@@ -744,6 +746,14 @@ isauth rt keydata = dont_have keydata && maybe False (`has_good_sig` keydata) wk | |||
744 | guard $ matchSpec (KeyGrip fp) elm | 746 | guard $ matchSpec (KeyGrip fp) elm |
745 | return $ keyPacket elm | 747 | return $ keyPacket elm |
746 | 748 | ||
749 | mkarmor :: Access -> L.ByteString -> [Armor] | ||
750 | mkarmor access bs = [Armor typ [] bs] | ||
751 | where | ||
752 | typ = case access of | ||
753 | Pub -> ArmorPublicKeyBlock | ||
754 | Sec -> ArmorPrivateKeyBlock | ||
755 | AutoAccess -> ArmorPrivateKeyBlock -- I don't know, so don't make it look sharable. | ||
756 | |||
747 | writeRingKeys :: KeyRingOperation -> KeyRingRuntime -> Map.Map InputFile Message | 757 | writeRingKeys :: KeyRingOperation -> KeyRingRuntime -> Map.Map InputFile Message |
748 | -> [(FilePath,KikiReportAction)] | 758 | -> [(FilePath,KikiReportAction)] |
749 | {- | 759 | {- |
@@ -810,17 +820,18 @@ writeRingKeys krd rt {- db wk secring pubring -} unspilled report_manips = do | |||
810 | go (ws,report) ((f,stream),(new_packets,x)) = (ws++writes, report++(items <$> new_packets)) | 820 | go (ws,report) ((f,stream),(new_packets,x)) = (ws++writes, report++(items <$> new_packets)) |
811 | where | 821 | where |
812 | mutable = isMutable stream | 822 | mutable = isMutable stream |
813 | encoding = case typ stream of PGPPackets e -> e | 823 | writes | mutable = [(stream,f,x)] |
814 | _ -> BinaryPackets | ||
815 | writes | mutable = [(encoding,f,x)] | ||
816 | | otherwise = [] | 824 | | otherwise = [] |
817 | items c = ( concat $ resolveInputFile ctx f | 825 | items c = ( concat $ resolveInputFile ctx f |
818 | , bool MissingPacket NewPacket mutable $ showPacket (packet c) | 826 | , bool MissingPacket NewPacket mutable $ showPacket (packet c) |
819 | ) | 827 | ) |
820 | forM_ towrites $ \(encoding,f,xs) -> case encoding of | 828 | forM_ towrites $ \(stream,f,xs) -> do |
821 | BinaryPackets -> writeInputFileL ctx f $ encode $ Message $ map packet xs | 829 | let encoding = case typ stream of PGPPackets e -> e |
822 | AsciiArmor -> hPutStrLn stderr $ "Not writing " ++ show (resolveInputFile ctx f) | 830 | _ -> BinaryPackets |
823 | ++ " because ascii-armor is not implemented. (TODO)" | 831 | enc = case encoding of |
832 | BinaryPackets -> id | ||
833 | AsciiArmor -> ASCIIArmor.encodeLazy . mkarmor (access stream) | ||
834 | writeInputFileL ctx f $ enc $ encode $ Message $ map packet xs | ||
824 | return $ KikiSuccess report | 835 | return $ KikiSuccess report |
825 | 836 | ||
826 | 837 | ||