diff options
Diffstat (limited to 'Codec/Encryption/OpenPGP')
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor.hs | 2 | ||||
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor.hs b/Codec/Encryption/OpenPGP/ASCIIArmor.hs index 26d58dd..6d0c172 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor.hs | |||
@@ -7,7 +7,9 @@ module Codec.Encryption.OpenPGP.ASCIIArmor ( | |||
7 | encode | 7 | encode |
8 | , decode | 8 | , decode |
9 | , parseArmor | 9 | , parseArmor |
10 | , multipartMerge | ||
10 | ) where | 11 | ) where |
11 | 12 | ||
12 | import Codec.Encryption.OpenPGP.ASCIIArmor.Encode (encode) | 13 | import Codec.Encryption.OpenPGP.ASCIIArmor.Encode (encode) |
13 | import Codec.Encryption.OpenPGP.ASCIIArmor.Decode (decode, parseArmor) | 14 | import Codec.Encryption.OpenPGP.ASCIIArmor.Decode (decode, parseArmor) |
15 | import Codec.Encryption.OpenPGP.ASCIIArmor.Multipart (multipartMerge) | ||
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs new file mode 100644 index 0000000..8719c7c --- /dev/null +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | |||
@@ -0,0 +1,24 @@ | |||
1 | -- ASCIIArmor/Multipart.hs: OpenPGP (RFC4880) ASCII armor implementation | ||
2 | -- Copyright Ⓒ 2012 Clint Adams | ||
3 | -- This software is released under the terms of the ISC license. | ||
4 | -- (See the LICENSE file). | ||
5 | |||
6 | module Codec.Encryption.OpenPGP.ASCIIArmor.Multipart ( | ||
7 | multipartMerge | ||
8 | ) where | ||
9 | |||
10 | import Codec.Encryption.OpenPGP.ASCIIArmor.Types | ||
11 | |||
12 | import Data.ByteString (ByteString) | ||
13 | import qualified Data.ByteString as B | ||
14 | |||
15 | multipartMerge :: [Armor] -> Armor | ||
16 | multipartMerge as = go as (Armor ArmorMessage [] B.empty) | ||
17 | where | ||
18 | go :: [Armor] -> Armor -> Armor | ||
19 | go [] state = state | ||
20 | go ((Armor at hs bs):as) state = go as (go' at hs bs state) | ||
21 | go' :: ArmorType -> [(String,String)] -> ByteString -> Armor -> Armor | ||
22 | go' (ArmorSplitMessage _ _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `B.append` bs) | ||
23 | go' (ArmorSplitMessageIndefinite _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `B.append` bs) | ||
24 | go' _ _ _ state = state | ||