diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-12-29 11:34:25 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-12-29 11:34:25 -0500 |
commit | 3bd37771256f6a8f98c2e112c10e3bba84d6de78 (patch) | |
tree | 0d4cf4c702bfcbf1982a326f593f011f0b099630 /Data | |
parent | 4b5e0e3d27973f8627ed3d83013f55c3b365b306 (diff) |
EncryptedDataPacket
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 12 |
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 |
476 | put_packet (UserIDPacket txt) = (B.fromString txt, 13) | 481 | put_packet (UserIDPacket txt) = (B.fromString txt, 13) |
482 | put_packet (EncryptedDataPacket 0 encrypted_data) = (encrypted_data, 9) | ||
483 | put_packet (EncryptedDataPacket version encrypted_data) = | ||
484 | (B.concat [encode version, encrypted_data], 18) | ||
477 | put_packet (ModificationDetectionCodePacket bstr) = (bstr, 19) | 485 | put_packet (ModificationDetectionCodePacket bstr) = (bstr, 19) |
478 | put_packet (UnsupportedPacket tag bytes) = (bytes, fromIntegral tag) | 486 | put_packet (UnsupportedPacket tag bytes) = (bytes, fromIntegral tag) |
479 | put_packet x = error ("Unsupported Packet version or type in put_packet: " ++ show x) | 487 | put_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 | ||
642 | parse_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 |
634 | parse_packet 10 = return MarkerPacket | 644 | parse_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 = | |||
652 | parse_packet 14 = do | 662 | parse_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 | ||
666 | parse_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 |
656 | parse_packet 19 = | 668 | parse_packet 19 = |
657 | fmap ModificationDetectionCodePacket getRemainingByteString | 669 | fmap ModificationDetectionCodePacket getRemainingByteString |