diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-30 09:38:03 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-30 09:38:03 -0500 |
commit | 905e4e82e295b2fa0f547e7c8d458c3f35944bcc (patch) | |
tree | a6d42a650a41d68a89113236369e534616f6f26c /Data | |
parent | 9877a30e04b83d8ed24aee704ffe150dd0678d8d (diff) |
EmbeddedSignaturePacket
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index a9a5b4e..6e488eb 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -289,8 +289,8 @@ signature_packet_start (SignaturePacket { | |||
289 | ] | 289 | ] |
290 | where | 290 | where |
291 | hashed_subs = B.concat $ map encode hashed_subpackets | 291 | hashed_subs = B.concat $ map encode hashed_subpackets |
292 | signature_packet_start _ = | 292 | signature_packet_start x = |
293 | error "Trying to get start of signature packet for non signature packet." | 293 | error ("Trying to get start of signature packet for: " ++ show x) |
294 | 294 | ||
295 | -- The trailer is just the top of the body plus some crap | 295 | -- The trailer is just the top of the body plus some crap |
296 | calculate_signature_trailer :: Packet -> B.ByteString | 296 | calculate_signature_trailer :: Packet -> B.ByteString |
@@ -749,6 +749,7 @@ data SignatureSubpacket = | |||
749 | target_hash_algorithm::HashAlgorithm, | 749 | target_hash_algorithm::HashAlgorithm, |
750 | hash::B.ByteString | 750 | hash::B.ByteString |
751 | } | | 751 | } | |
752 | EmbeddedSignaturePacket Packet | | ||
752 | UnsupportedSignatureSubpacket Word8 B.ByteString | 753 | UnsupportedSignatureSubpacket Word8 B.ByteString |
753 | deriving (Show, Read, Eq) | 754 | deriving (Show, Read, Eq) |
754 | 755 | ||
@@ -850,6 +851,8 @@ put_signature_subpacket (FeaturesPacket supports_mdc) = | |||
850 | (B.singleton $ if supports_mdc then 0x01 else 0x00, 30) | 851 | (B.singleton $ if supports_mdc then 0x01 else 0x00, 30) |
851 | put_signature_subpacket (SignatureTargetPacket kalgo halgo hash) = | 852 | put_signature_subpacket (SignatureTargetPacket kalgo halgo hash) = |
852 | (B.concat [encode kalgo, encode halgo, hash], 31) | 853 | (B.concat [encode kalgo, encode halgo, hash], 31) |
854 | put_signature_subpacket (EmbeddedSignaturePacket packet) = | ||
855 | (encode (assert (isSignaturePacket packet) packet), 32) | ||
853 | put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = | 856 | put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = |
854 | (bytes, tag) | 857 | (bytes, tag) |
855 | 858 | ||
@@ -962,6 +965,12 @@ parse_signature_subpacket 30 = do | |||
962 | -- SignatureTargetPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.25 | 965 | -- SignatureTargetPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.25 |
963 | parse_signature_subpacket 31 = | 966 | parse_signature_subpacket 31 = |
964 | liftM3 SignatureTargetPacket get get getRemainingByteString | 967 | liftM3 SignatureTargetPacket get get getRemainingByteString |
968 | -- EmbeddedSignaturePacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.26 | ||
969 | parse_signature_subpacket 32 = | ||
970 | fmap (EmbeddedSignaturePacket . forceSignature) get | ||
971 | where | ||
972 | forceSignature x@(SignaturePacket {}) = x | ||
973 | forceSignature _ = error "EmbeddedSignature must contain signature" | ||
965 | -- Represent unsupported packets as their tag and literal bytes | 974 | -- Represent unsupported packets as their tag and literal bytes |
966 | parse_signature_subpacket tag = | 975 | parse_signature_subpacket tag = |
967 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString | 976 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString |