summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-12-29 11:34:25 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-12-29 11:34:25 -0500
commit3bd37771256f6a8f98c2e112c10e3bba84d6de78 (patch)
tree0d4cf4c702bfcbf1982a326f593f011f0b099630
parent4b5e0e3d27973f8627ed3d83013f55c3b365b306 (diff)
EncryptedDataPacket
-rw-r--r--Data/OpenPGP.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index c6c22e4..90c254f 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -14,6 +14,7 @@ module Data.OpenPGP (
14 MarkerPacket, 14 MarkerPacket,
15 LiteralDataPacket, 15 LiteralDataPacket,
16 UserIDPacket, 16 UserIDPacket,
17 EncryptedDataPacket,
17 ModificationDetectionCodePacket, 18 ModificationDetectionCodePacket,
18 UnsupportedPacket, 19 UnsupportedPacket,
19 compression_algorithm, 20 compression_algorithm,
@@ -217,6 +218,10 @@ data Packet =
217 content::B.ByteString 218 content::B.ByteString
218 } | 219 } |
219 UserIDPacket String | 220 UserIDPacket String |
221 EncryptedDataPacket {
222 version::Word8, -- 0 for old-skool no-MDC (tag 9)
223 encrypted_data::B.ByteString
224 } |
220 ModificationDetectionCodePacket B.ByteString | 225 ModificationDetectionCodePacket B.ByteString |
221 UnsupportedPacket Word8 B.ByteString 226 UnsupportedPacket Word8 B.ByteString
222 deriving (Show, Read, Eq) 227 deriving (Show, Read, Eq)
@@ -474,6 +479,9 @@ put_packet (LiteralDataPacket { format = format, filename = filename,
474 filename_l = (fromIntegral $ B.length lz_filename) :: Word8 479 filename_l = (fromIntegral $ B.length lz_filename) :: Word8
475 lz_filename = B.fromString filename 480 lz_filename = B.fromString filename
476put_packet (UserIDPacket txt) = (B.fromString txt, 13) 481put_packet (UserIDPacket txt) = (B.fromString txt, 13)
482put_packet (EncryptedDataPacket 0 encrypted_data) = (encrypted_data, 9)
483put_packet (EncryptedDataPacket version encrypted_data) =
484 (B.concat [encode version, encrypted_data], 18)
477put_packet (ModificationDetectionCodePacket bstr) = (bstr, 19) 485put_packet (ModificationDetectionCodePacket bstr) = (bstr, 19)
478put_packet (UnsupportedPacket tag bytes) = (bytes, fromIntegral tag) 486put_packet (UnsupportedPacket tag bytes) = (bytes, fromIntegral tag)
479put_packet x = error ("Unsupported Packet version or type in put_packet: " ++ show x) 487put_packet x = error ("Unsupported Packet version or type in put_packet: " ++ show x)
@@ -630,6 +638,8 @@ parse_packet 8 = do
630 compression_algorithm = algorithm, 638 compression_algorithm = algorithm,
631 message = unsafeRunGet get (decompress algorithm message) 639 message = unsafeRunGet get (decompress algorithm message)
632 } 640 }
641-- EncryptedDataPacket, http://tools.ietf.org/html/rfc4880#section-5.7
642parse_packet 9 = EncryptedDataPacket 0 <$> getRemainingByteString
633-- MarkerPacket, http://tools.ietf.org/html/rfc4880#section-5.8 643-- MarkerPacket, http://tools.ietf.org/html/rfc4880#section-5.8
634parse_packet 10 = return MarkerPacket 644parse_packet 10 = return MarkerPacket
635-- LiteralDataPacket, http://tools.ietf.org/html/rfc4880#section-5.9 645-- LiteralDataPacket, http://tools.ietf.org/html/rfc4880#section-5.9
@@ -652,6 +662,8 @@ parse_packet 13 =
652parse_packet 14 = do 662parse_packet 14 = do
653 p <- parse_packet 6 663 p <- parse_packet 6
654 return p {is_subkey = True} 664 return p {is_subkey = True}
665-- EncryptedDataPacket, http://tools.ietf.org/html/rfc4880#section-5.13
666parse_packet 18 = EncryptedDataPacket <$> get <*> getRemainingByteString
655-- ModificationDetectionCodePacket, http://tools.ietf.org/html/rfc4880#section-5.14 667-- ModificationDetectionCodePacket, http://tools.ietf.org/html/rfc4880#section-5.14
656parse_packet 19 = 668parse_packet 19 =
657 fmap ModificationDetectionCodePacket getRemainingByteString 669 fmap ModificationDetectionCodePacket getRemainingByteString