diff options
author | Clint Adams <clint@debian.org> | 2012-07-27 23:48:27 -0400 |
---|---|---|
committer | Clint Adams <clint@debian.org> | 2012-07-27 23:48:27 -0400 |
commit | c708dc4b1d84bc85c52c5c3255f65c62a67ee039 (patch) | |
tree | 59dcc5dff95c2803e531e009bd411e85405ac5ee /Codec | |
parent | 3a9f6d91f4b1e36d92ea18237ae8caf1bb639203 (diff) |
Make -Wall-clean and build with -Wall.
Diffstat (limited to 'Codec')
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | 39 | ||||
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs | 3 | ||||
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | 3 |
3 files changed, 20 insertions, 25 deletions
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs index b1cc5c0..98934a0 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | |||
@@ -17,7 +17,6 @@ import Data.Attoparsec.ByteString (Parser, many1, string, inClass, notInClass, s | |||
17 | import qualified Data.Attoparsec.ByteString as AS | 17 | import qualified Data.Attoparsec.ByteString as AS |
18 | import qualified Data.Attoparsec.ByteString.Lazy as AL | 18 | import qualified Data.Attoparsec.ByteString.Lazy as AL |
19 | import Data.Attoparsec.ByteString.Char8 (isDigit_w8, anyChar) | 19 | import Data.Attoparsec.ByteString.Char8 (isDigit_w8, anyChar) |
20 | import Data.Attoparsec.Combinator (manyTill) | ||
21 | import Data.Bits (shiftL) | 20 | import Data.Bits (shiftL) |
22 | import Data.ByteString (ByteString) | 21 | import Data.ByteString (ByteString) |
23 | import qualified Data.ByteString as B | 22 | import qualified Data.ByteString as B |
@@ -25,23 +24,21 @@ import qualified Data.ByteString.Lazy as BL | |||
25 | import qualified Data.ByteString.Char8 as BC8 | 24 | import qualified Data.ByteString.Char8 as BC8 |
26 | import qualified Data.ByteString.Base64 as Base64 | 25 | import qualified Data.ByteString.Base64 as Base64 |
27 | import Data.Digest.CRC24 (crc24) | 26 | import Data.Digest.CRC24 (crc24) |
28 | import Data.Serialize (get) | ||
29 | import Data.Serialize.Get (Get, runGet, getWord8) | 27 | import Data.Serialize.Get (Get, runGet, getWord8) |
30 | import Data.Serialize.Put (runPut, putWord32be) | ||
31 | import Data.String (IsString, fromString) | 28 | import Data.String (IsString, fromString) |
32 | import Data.Word (Word32) | 29 | import Data.Word (Word32) |
33 | 30 | ||
34 | decode :: IsString e => ByteString -> Either e [Armor] | 31 | decode :: IsString e => ByteString -> Either e [Armor] |
35 | decode bs = go (AS.parse parseArmors bs) | 32 | decode bs = go (AS.parse parseArmors bs) |
36 | where | 33 | where |
37 | go (AS.Fail t c e) = Left (fromString e) | 34 | go (AS.Fail _ _ e) = Left (fromString e) |
38 | go (AS.Partial cont) = go (cont B.empty) | 35 | go (AS.Partial cont) = go (cont B.empty) |
39 | go (AS.Done _ r) = Right r | 36 | go (AS.Done _ r) = Right r |
40 | 37 | ||
41 | decodeLazy :: IsString e => BL.ByteString -> Either e [Armor] | 38 | decodeLazy :: IsString e => BL.ByteString -> Either e [Armor] |
42 | decodeLazy bs = go (AL.parse parseArmors bs) | 39 | decodeLazy bs = go (AL.parse parseArmors bs) |
43 | where | 40 | where |
44 | go (AL.Fail t c e) = Left (fromString e) | 41 | go (AL.Fail _ _ e) = Left (fromString e) |
45 | go (AL.Done _ r) = Right r | 42 | go (AL.Done _ r) = Right r |
46 | 43 | ||
47 | parseArmors :: Parser [Armor] | 44 | parseArmors :: Parser [Armor] |
@@ -52,10 +49,10 @@ parseArmor = prefixed (clearsigned <|> armor) <?> "armor" | |||
52 | 49 | ||
53 | clearsigned :: Parser Armor | 50 | clearsigned :: Parser Armor |
54 | clearsigned = do | 51 | clearsigned = do |
55 | string "-----BEGIN PGP SIGNED MESSAGE-----" <?> "clearsign header" | 52 | _ <- string "-----BEGIN PGP SIGNED MESSAGE-----" <?> "clearsign header" |
56 | lineEnding <?> "line ending" | 53 | _ <- lineEnding <?> "line ending" |
57 | headers <- armorHeaders <?> "clearsign headers" | 54 | headers <- armorHeaders <?> "clearsign headers" |
58 | blankishLine <?> "blank line" | 55 | _ <- blankishLine <?> "blank line" |
59 | cleartext <- dashEscapedCleartext | 56 | cleartext <- dashEscapedCleartext |
60 | sig <- armor | 57 | sig <- armor |
61 | return $ ClearSigned headers (BL.fromChunks [cleartext]) sig | 58 | return $ ClearSigned headers (BL.fromChunks [cleartext]) sig |
@@ -64,18 +61,18 @@ armor :: Parser Armor | |||
64 | armor = do | 61 | armor = do |
65 | atype <- beginLine <?> "begin line" | 62 | atype <- beginLine <?> "begin line" |
66 | headers <- armorHeaders <?> "headers" | 63 | headers <- armorHeaders <?> "headers" |
67 | blankishLine <?> "blank line" | 64 | _ <- blankishLine <?> "blank line" |
68 | payload <- base64Data <?> "base64 data" | 65 | payload <- base64Data <?> "base64 data" |
69 | endLine atype <?> "end line" | 66 | _ <- endLine atype <?> "end line" |
70 | return $ Armor atype headers (BL.fromChunks [payload]) | 67 | return $ Armor atype headers (BL.fromChunks [payload]) |
71 | 68 | ||
72 | beginLine :: Parser ArmorType | 69 | beginLine :: Parser ArmorType |
73 | beginLine = do | 70 | beginLine = do |
74 | string "-----BEGIN PGP " <?> "leading minus-hyphens" | 71 | _ <- string "-----BEGIN PGP " <?> "leading minus-hyphens" |
75 | atype <- pubkey <|> privkey <|> parts <|> message <|> signature | 72 | atype <- pubkey <|> privkey <|> parts <|> message <|> signature |
76 | string "-----" <?> "trailing minus-hyphens" | 73 | _ <- string "-----" <?> "trailing minus-hyphens" |
77 | many (satisfy (inClass " \t")) <?> "whitespace" | 74 | _ <- many (satisfy (inClass " \t")) <?> "whitespace" |
78 | lineEnding <?> "line ending" | 75 | _ <- lineEnding <?> "line ending" |
79 | return atype | 76 | return atype |
80 | where | 77 | where |
81 | message = string "MESSAGE" *> return ArmorMessage | 78 | message = string "MESSAGE" *> return ArmorMessage |
@@ -85,7 +82,7 @@ beginLine = do | |||
85 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) | 82 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) |
86 | partsdef = do | 83 | partsdef = do |
87 | firstnum <- num | 84 | firstnum <- num |
88 | word8 (fromIntegral . fromEnum $ '/') | 85 | _ <- word8 (fromIntegral . fromEnum $ '/') |
89 | secondnum <- num | 86 | secondnum <- num |
90 | return $ ArmorSplitMessage (BL.pack firstnum) (BL.pack secondnum) | 87 | return $ ArmorSplitMessage (BL.pack firstnum) (BL.pack secondnum) |
91 | partsindef = ArmorSplitMessageIndefinite . BL.pack <$> num | 88 | partsindef = ArmorSplitMessageIndefinite . BL.pack <$> num |
@@ -100,9 +97,9 @@ armorHeaders = many armorHeader | |||
100 | armorHeader :: Parser (String, String) | 97 | armorHeader :: Parser (String, String) |
101 | armorHeader = do | 98 | armorHeader = do |
102 | key <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) | 99 | key <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) |
103 | string ": " | 100 | _ <- string ": " |
104 | val <- many1 (satisfy (notInClass "\n\r")) | 101 | val <- many1 (satisfy (notInClass "\n\r")) |
105 | lineEnding | 102 | _ <- lineEnding |
106 | return (w8sToString key, w8sToString val) | 103 | return (w8sToString key, w8sToString val) |
107 | where | 104 | where |
108 | w8sToString = BC8.unpack . B.pack | 105 | w8sToString = BC8.unpack . B.pack |
@@ -112,7 +109,7 @@ blankishLine = many (satisfy (inClass " \t")) *> lineEnding | |||
112 | 109 | ||
113 | endLine :: ArmorType -> Parser ByteString | 110 | endLine :: ArmorType -> Parser ByteString |
114 | endLine atype = do | 111 | endLine atype = do |
115 | string $ "-----END PGP " `B.append` aType atype `B.append` "-----" | 112 | _ <- string $ "-----END PGP " `B.append` aType atype `B.append` "-----" |
116 | lineEnding | 113 | lineEnding |
117 | 114 | ||
118 | aType :: ArmorType -> ByteString | 115 | aType :: ArmorType -> ByteString |
@@ -140,16 +137,16 @@ base64Data = do | |||
140 | base64Line = do | 137 | base64Line = do |
141 | b64 <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")) | 138 | b64 <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")) |
142 | pad <- many (word8 (fromIntegral . fromEnum $ '=')) | 139 | pad <- many (word8 (fromIntegral . fromEnum $ '=')) |
143 | lineEnding | 140 | _ <- lineEnding |
144 | let line = B.pack b64 `B.append` B.pack pad | 141 | let line = B.pack b64 `B.append` B.pack pad |
145 | case Base64.decode line of | 142 | case Base64.decode line of |
146 | Left err -> fail err | 143 | Left err -> fail err |
147 | Right bs -> return bs | 144 | Right bs -> return bs |
148 | checksumLine :: Parser ByteString | 145 | checksumLine :: Parser ByteString |
149 | checksumLine = do | 146 | checksumLine = do |
150 | word8 (fromIntegral . fromEnum $ '=') | 147 | _ <- word8 (fromIntegral . fromEnum $ '=') |
151 | b64 <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")) | 148 | b64 <- many1 (satisfy (inClass "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")) |
152 | lineEnding | 149 | _ <- lineEnding |
153 | let line = B.pack b64 | 150 | let line = B.pack b64 |
154 | case Base64.decode line of | 151 | case Base64.decode line of |
155 | Left err -> fail err | 152 | Left err -> fail err |
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs index a1f8bba..c437439 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs | |||
@@ -12,13 +12,10 @@ import Codec.Encryption.OpenPGP.ASCIIArmor.Types | |||
12 | import Data.ByteString.Lazy (ByteString) | 12 | import Data.ByteString.Lazy (ByteString) |
13 | import qualified Data.ByteString as B | 13 | import qualified Data.ByteString as B |
14 | import qualified Data.ByteString.Lazy as BL | 14 | import qualified Data.ByteString.Lazy as BL |
15 | import qualified Data.ByteString.Char8 as BC8 | ||
16 | import qualified Data.ByteString.Lazy.Char8 as BLC8 | 15 | import qualified Data.ByteString.Lazy.Char8 as BLC8 |
17 | import qualified Data.ByteString.Base64 as Base64 | 16 | import qualified Data.ByteString.Base64 as Base64 |
18 | import Data.Digest.CRC24 (crc24Lazy) | 17 | import Data.Digest.CRC24 (crc24Lazy) |
19 | import Data.Serialize (put) | ||
20 | import Data.Serialize.Put (runPutLazy, putWord32be) | 18 | import Data.Serialize.Put (runPutLazy, putWord32be) |
21 | import Data.String (IsString, fromString) | ||
22 | 19 | ||
23 | encode :: [Armor] -> B.ByteString | 20 | encode :: [Armor] -> B.ByteString |
24 | encode = B.concat . BL.toChunks . encodeLazy | 21 | encode = B.concat . BL.toChunks . encodeLazy |
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs index 385074f..0334c7e 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | |||
@@ -13,11 +13,12 @@ import Data.ByteString.Lazy (ByteString) | |||
13 | import qualified Data.ByteString.Lazy as BL | 13 | import qualified Data.ByteString.Lazy as BL |
14 | 14 | ||
15 | multipartMerge :: [Armor] -> Armor | 15 | multipartMerge :: [Armor] -> Armor |
16 | multipartMerge as = go as (Armor ArmorMessage [] BL.empty) | 16 | multipartMerge as' = go as' (Armor ArmorMessage [] BL.empty) |
17 | where | 17 | where |
18 | go :: [Armor] -> Armor -> Armor | 18 | go :: [Armor] -> Armor -> Armor |
19 | go [] state = state | 19 | go [] state = state |
20 | go (Armor at hs bs:as) state = go as (go' at hs bs state) | 20 | go (Armor at hs bs:as) state = go as (go' at hs bs state) |
21 | go _ _ = error "This shouldn't happen." | ||
21 | go' :: ArmorType -> [(String,String)] -> ByteString -> Armor -> Armor | 22 | go' :: ArmorType -> [(String,String)] -> ByteString -> Armor -> Armor |
22 | go' (ArmorSplitMessage _ _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `BL.append` bs) | 23 | go' (ArmorSplitMessage _ _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `BL.append` bs) |
23 | go' (ArmorSplitMessageIndefinite _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `BL.append` bs) | 24 | go' (ArmorSplitMessageIndefinite _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `BL.append` bs) |