diff options
Diffstat (limited to 'Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs')
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs index b62ff6a..5d28e46 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | |||
@@ -25,6 +25,7 @@ import qualified Data.ByteString.Char8 as BC8 | |||
25 | import qualified Data.ByteString.Base64 as Base64 | 25 | import qualified Data.ByteString.Base64 as Base64 |
26 | import Data.Digest.CRC24 (crc24) | 26 | import Data.Digest.CRC24 (crc24) |
27 | import Data.Binary.Get (Get, runGetOrFail, getWord8) | 27 | import Data.Binary.Get (Get, runGetOrFail, getWord8) |
28 | import Data.Functor (($>)) | ||
28 | import Data.String (IsString, fromString) | 29 | import Data.String (IsString, fromString) |
29 | import Data.Word (Word32) | 30 | import Data.Word (Word32) |
30 | 31 | ||
@@ -75,10 +76,10 @@ beginLine = do | |||
75 | _ <- lineEnding <?> "line ending" | 76 | _ <- lineEnding <?> "line ending" |
76 | return atype | 77 | return atype |
77 | where | 78 | where |
78 | message = string "MESSAGE" *> return ArmorMessage | 79 | message = string "MESSAGE" $> ArmorMessage |
79 | pubkey = string "PUBLIC KEY BLOCK" *> return ArmorPublicKeyBlock | 80 | pubkey = string "PUBLIC KEY BLOCK" $> ArmorPublicKeyBlock |
80 | privkey = string "PRIVATE KEY BLOCK" *> return ArmorPrivateKeyBlock | 81 | privkey = string "PRIVATE KEY BLOCK" $> ArmorPrivateKeyBlock |
81 | signature = string "SIGNATURE" *> return ArmorSignature | 82 | signature = string "SIGNATURE" $> ArmorSignature |
82 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) | 83 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) |
83 | partsdef = do | 84 | partsdef = do |
84 | firstnum <- num | 85 | firstnum <- num |
@@ -113,12 +114,12 @@ endLine atype = do | |||
113 | lineEnding | 114 | lineEnding |
114 | 115 | ||
115 | aType :: ArmorType -> B.ByteString | 116 | aType :: ArmorType -> B.ByteString |
116 | aType (ArmorMessage) = BC8.pack "MESSAGE" | 117 | aType ArmorMessage = BC8.pack "MESSAGE" |
117 | aType (ArmorPublicKeyBlock) = BC8.pack "PUBLIC KEY BLOCK" | 118 | aType ArmorPublicKeyBlock = BC8.pack "PUBLIC KEY BLOCK" |
118 | aType (ArmorPrivateKeyBlock) = BC8.pack "PRIVATE KEY BLOCK" | 119 | aType ArmorPrivateKeyBlock = BC8.pack "PRIVATE KEY BLOCK" |
119 | aType (ArmorSplitMessage x y) = BC8.pack "MESSAGE, PART " `B.append` l2s x `B.append` BC8.singleton '/' `B.append` l2s y | 120 | aType (ArmorSplitMessage x y) = BC8.pack "MESSAGE, PART " `B.append` l2s x `B.append` BC8.singleton '/' `B.append` l2s y |
120 | aType (ArmorSplitMessageIndefinite x) = BC8.pack "MESSAGE, PART " `B.append` l2s x | 121 | aType (ArmorSplitMessageIndefinite x) = BC8.pack "MESSAGE, PART " `B.append` l2s x |
121 | aType (ArmorSignature) = BC8.pack "SIGNATURE" | 122 | aType ArmorSignature = BC8.pack "SIGNATURE" |
122 | 123 | ||
123 | l2s :: BL.ByteString -> B.ByteString | 124 | l2s :: BL.ByteString -> B.ByteString |
124 | l2s = B.concat . BL.toChunks | 125 | l2s = B.concat . BL.toChunks |