summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/openpgp.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/openpgp.hs b/lib/openpgp.hs
index a52d255..2848538 100644
--- a/lib/openpgp.hs
+++ b/lib/openpgp.hs
@@ -6,6 +6,21 @@ import Data.Word
6newtype Message = Message [Packet] deriving Show 6newtype Message = Message [Packet] deriving Show
7data Packet = EmptyPacket | Len Word8 Word32 deriving Show 7data Packet = EmptyPacket | Len Word8 Word32 deriving Show
8 8
9-- A message is encoded as a list that takes the entire file
10instance Binary Message where
11 put (Message []) = return ()
12 put (Message (x:xs)) = do
13 put x
14 put (Message xs)
15 get = do
16 done <- isEmpty
17 if done then do
18 return (Message [])
19 else do
20 next_packet <- get :: Get Packet
21 (Message tail) <- get :: Get Message
22 return (Message (next_packet:tail))
23
9instance Binary Packet where 24instance Binary Packet where
10 get = do 25 get = do
11 tag <- get :: Get Word8 26 tag <- get :: Get Word8