summaryrefslogtreecommitdiff
path: root/lib/KeyRing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/KeyRing')
-rw-r--r--lib/KeyRing/BuildKeyDB.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/KeyRing/BuildKeyDB.hs b/lib/KeyRing/BuildKeyDB.hs
index 10e2d41..24b39b1 100644
--- a/lib/KeyRing/BuildKeyDB.hs
+++ b/lib/KeyRing/BuildKeyDB.hs
@@ -32,7 +32,7 @@ import Data.ASN1.Types (ASN1 (BitString, End, IntVal, Null, OID, Start
32 fromASN1, toASN1) 32 fromASN1, toASN1)
33import Data.Binary 33import Data.Binary
34import Data.Bits ((.&.), (.|.)) 34import Data.Bits ((.&.), (.|.))
35import Data.Bits (Bits) 35import Data.Bits (Bits, testBit)
36import qualified Data.ByteString as S (ByteString, breakSubstring, 36import qualified Data.ByteString as S (ByteString, breakSubstring,
37 concat, drop, hGetContents, 37 concat, drop, hGetContents,
38 hPutStr, length, null, 38 hPutStr, length, null,
@@ -41,7 +41,7 @@ import Data.ByteString.Lazy (ByteString)
41import qualified Data.ByteString.Lazy as L (ByteString, concat, empty, 41import qualified Data.ByteString.Lazy as L (ByteString, concat, empty,
42 fromChunks, hGetContents, 42 fromChunks, hGetContents,
43 null, readFile, toChunks, 43 null, readFile, toChunks,
44 toStrict) 44 toStrict, head)
45import Data.Char 45import Data.Char
46import Data.Function 46import Data.Function
47import Data.List 47import Data.List
@@ -318,13 +318,16 @@ decodeOrFail bs = Right (L.empty,1,decode bs)
318 318
319readPacketsFromFile :: InputFileContext -> InputFile -> IO (PacketsCodec, Message) 319readPacketsFromFile :: InputFileContext -> InputFile -> IO (PacketsCodec, Message)
320readPacketsFromFile ctx fname = do 320readPacketsFromFile ctx fname = do
321 -- warn $ fname ++ ": reading..."
322 input <- readInputFileL ctx fname 321 input <- readInputFileL ctx fname
323 return $ case decodeOrFail input of 322 let tryBinary = case decodeOrFail input of
324 Right (more,_,pkt) -> (,) BinaryPackets $ Message $ pkt : decodePacketList more 323 Right (more,_,pkt) -> (,) BinaryPackets $ Message $ pkt : decodePacketList more
325 Left (_,_,_) -> case ASCIIArmor.decodeLazy input of 324 Left (_,_,_) -> tryAscii
325 tryAscii = case ASCIIArmor.decodeLazy input of
326 Right (Armor pubOrSec headers bs:_) -> (,) AsciiArmor $ Message $ decodePacketList bs 326 Right (Armor pubOrSec headers bs:_) -> (,) AsciiArmor $ Message $ decodePacketList bs
327 _ -> (,) DetectAscii $ Message [] 327 _ -> (,) DetectAscii $ Message []
328 return $ if L.null input || testBit (L.head input) 7
329 then tryBinary
330 else tryAscii
328 331
329readPacketsFromWallet :: 332readPacketsFromWallet ::
330 Maybe Packet 333 Maybe Packet