From f907d986330ac5f88f9e921bdd6c0572d4691003 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Wed, 4 Apr 2012 10:59:00 -0400 Subject: Add newtype wrapper for lists for the purpose of avoiding the cereal instance. --- Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | 7 ++++--- Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs index 2383ff3..64f7236 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs @@ -9,7 +9,7 @@ module Codec.Encryption.OpenPGP.ASCIIArmor.Decode ( , decodeArmor ) where -import Codec.Encryption.OpenPGP.Serialize (getPackets) +import Codec.Encryption.OpenPGP.Serialize () import Codec.Encryption.OpenPGP.Types import Control.Applicative (many, (<|>), (<$>)) import Data.Attoparsec.ByteString (Parser, many1, string, inClass, notInClass, satisfy, word8, (), parse, IResult(..)) @@ -20,6 +20,7 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as BC8 import qualified Data.ByteString.Base64 as Base64 import Data.Digest.CRC24 (crc24) +import Data.Serialize (get) import Data.Serialize.Get (Get, runGet, getWord8) import Data.Serialize.Put (runPut, putWord32be) import Data.String (IsString, fromString) @@ -38,9 +39,9 @@ parseArmor = do blankishLine "blank line" payload <- base64Data "base64 data" endLine atype "end line" - case runGet getPackets payload of + case runGet get payload of Left err -> fail err - Right packets -> return $ Armor atype headers packets + Right packets -> return $ Armor atype headers (unBlock packets) beginLine :: (Integral a, Read a, Show a) => Parser (ArmorType a) beginLine = do diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs index d08c3c1..c9c9641 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs @@ -7,13 +7,14 @@ module Codec.Encryption.OpenPGP.ASCIIArmor.Encode ( armor ) where -import Codec.Encryption.OpenPGP.Serialize (putPackets) +import Codec.Encryption.OpenPGP.Serialize () import Codec.Encryption.OpenPGP.Types import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as BC8 import qualified Data.ByteString.Base64 as Base64 import Data.Digest.CRC24 (crc24) +import Data.Serialize (put) import Data.Serialize.Put (runPut, putWord32be) import Data.String (IsString, fromString) @@ -44,7 +45,7 @@ armorHeaders ahs = BC8.unlines . map armorHeader $ ahs armorHeader (k, v) = k `B.append` BC8.pack ": " `B.append` v opgpStream :: [Packet] -> ByteString -opgpStream = runPut . putPackets +opgpStream = runPut . put . Block armorData :: ByteString -> ByteString armorData = BC8.unlines . wrap76 . Base64.encode -- cgit v1.2.3