diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 18:13:25 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 18:13:25 -0500 |
commit | dc97a42a4e0432b7aaca1b55612d90e82c5ca853 (patch) | |
tree | f53f0f8b44d0f141cd667c38ea68aeeb66506ad1 /Data | |
parent | 00f3838fdb81fef2fed80554582f0f17a59c6977 (diff) |
ReasonForRevocationPacket
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 012eead..4bbaf84 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -48,6 +48,7 @@ module Data.OpenPGP ( | |||
48 | KeyAlgorithm(..), | 48 | KeyAlgorithm(..), |
49 | SymmetricAlgorithm(..), | 49 | SymmetricAlgorithm(..), |
50 | CompressionAlgorithm(..), | 50 | CompressionAlgorithm(..), |
51 | RevocationCode(..), | ||
51 | MPI(..), | 52 | MPI(..), |
52 | find_key, | 53 | find_key, |
53 | fingerprint_material, | 54 | fingerprint_material, |
@@ -641,6 +642,26 @@ instance BINARY_CLASS CompressionAlgorithm where | |||
641 | put = put . enum_to_word8 | 642 | put = put . enum_to_word8 |
642 | get = fmap enum_from_word8 get | 643 | get = fmap enum_from_word8 get |
643 | 644 | ||
645 | data RevocationCode = NoReason | KeySuperseded | KeyCompromised | KeyRetired | UserIDInvalid | RevocationCode Word8 deriving (Show, Read, Eq) | ||
646 | |||
647 | instance Enum RevocationCode where | ||
648 | toEnum 00 = NoReason | ||
649 | toEnum 01 = KeySuperseded | ||
650 | toEnum 02 = KeyCompromised | ||
651 | toEnum 03 = KeyRetired | ||
652 | toEnum 32 = UserIDInvalid | ||
653 | toEnum x = RevocationCode $ fromIntegral x | ||
654 | fromEnum NoReason = 00 | ||
655 | fromEnum KeySuperseded = 01 | ||
656 | fromEnum KeyCompromised = 02 | ||
657 | fromEnum KeyRetired = 03 | ||
658 | fromEnum UserIDInvalid = 32 | ||
659 | fromEnum (RevocationCode x) = fromIntegral x | ||
660 | |||
661 | instance BINARY_CLASS RevocationCode where | ||
662 | put = put . enum_to_word8 | ||
663 | get = fmap enum_from_word8 get | ||
664 | |||
644 | -- A message is encoded as a list that takes the entire file | 665 | -- A message is encoded as a list that takes the entire file |
645 | newtype Message = Message [Packet] deriving (Show, Read, Eq) | 666 | newtype Message = Message [Packet] deriving (Show, Read, Eq) |
646 | instance BINARY_CLASS Message where | 667 | instance BINARY_CLASS Message where |
@@ -721,6 +742,7 @@ data SignatureSubpacket = | |||
721 | group_key::Bool | 742 | group_key::Bool |
722 | } | | 743 | } | |
723 | SignerUserIDPacket String | | 744 | SignerUserIDPacket String | |
745 | ReasonForRevocationPacket RevocationCode String | | ||
724 | UnsupportedSignatureSubpacket Word8 B.ByteString | 746 | UnsupportedSignatureSubpacket Word8 B.ByteString |
725 | deriving (Show, Read, Eq) | 747 | deriving (Show, Read, Eq) |
726 | 748 | ||
@@ -816,6 +838,8 @@ put_signature_subpacket (KeyFlagsPacket certify sign encryptC encryptS split aut | |||
816 | flag _ False = 0x0 | 838 | flag _ False = 0x0 |
817 | put_signature_subpacket (SignerUserIDPacket userid) = | 839 | put_signature_subpacket (SignerUserIDPacket userid) = |
818 | (B.fromString userid, 28) | 840 | (B.fromString userid, 28) |
841 | put_signature_subpacket (ReasonForRevocationPacket code string) = | ||
842 | (B.concat [encode code, B.fromString string], 29) | ||
819 | put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = | 843 | put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = |
820 | (bytes, tag) | 844 | (bytes, tag) |
821 | 845 | ||
@@ -915,6 +939,9 @@ parse_signature_subpacket 27 = do | |||
915 | -- SignerUserIDPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.22 | 939 | -- SignerUserIDPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.22 |
916 | parse_signature_subpacket 28 = | 940 | parse_signature_subpacket 28 = |
917 | fmap (SignerUserIDPacket . B.toString) getRemainingByteString | 941 | fmap (SignerUserIDPacket . B.toString) getRemainingByteString |
942 | -- ReasonForRevocationPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.23 | ||
943 | parse_signature_subpacket 29 = liftM2 ReasonForRevocationPacket get | ||
944 | (fmap B.toString getRemainingByteString) | ||
918 | -- Represent unsupported packets as their tag and literal bytes | 945 | -- Represent unsupported packets as their tag and literal bytes |
919 | parse_signature_subpacket tag = | 946 | parse_signature_subpacket tag = |
920 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString | 947 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString |