summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 17:56:09 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 17:56:09 -0500
commitb572d14100eabd30869a6886e972d988e21183cf (patch)
tree1b67258dee2fad06686ec9870c1de9f6bc785204 /Data
parentfa19e9b7e8fab70d9c817890e7efe6918e49df74 (diff)
KeyFlagsPacket
Diffstat (limited to 'Data')
-rw-r--r--Data/OpenPGP.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index bf99198..28a0941 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -711,6 +711,15 @@ data SignatureSubpacket =
711 PreferredKeyServerPacket String | 711 PreferredKeyServerPacket String |
712 PrimaryUserIDPacket Bool | 712 PrimaryUserIDPacket Bool |
713 PolicyURIPacket String | 713 PolicyURIPacket String |
714 KeyFlagsPacket {
715 certify_keys::Bool,
716 sign_data::Bool,
717 encrypt_communication::Bool,
718 encrypt_storage::Bool,
719 split_key::Bool,
720 authentication::Bool,
721 group_key::Bool
722 } |
714 UnsupportedSignatureSubpacket Word8 B.ByteString 723 UnsupportedSignatureSubpacket Word8 B.ByteString
715 deriving (Show, Read, Eq) 724 deriving (Show, Read, Eq)
716 725
@@ -791,6 +800,19 @@ put_signature_subpacket (PrimaryUserIDPacket isprimary) =
791 (encode $ enum_to_word8 isprimary, 25) 800 (encode $ enum_to_word8 isprimary, 25)
792put_signature_subpacket (PolicyURIPacket uri) = 801put_signature_subpacket (PolicyURIPacket uri) =
793 (B.fromString uri, 26) 802 (B.fromString uri, 26)
803put_signature_subpacket (KeyFlagsPacket certify sign encryptC encryptS split auth group) =
804 ( B.singleton $
805 flag 0x01 certify .|.
806 flag 0x02 sign .|.
807 flag 0x04 encryptC .|.
808 flag 0x08 encryptS .|.
809 flag 0x10 split .|.
810 flag 0x20 auth .|.
811 flag 0x80 group
812 , 27)
813 where
814 flag x True = x
815 flag _ False = 0x0
794put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = 816put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) =
795 (bytes, tag) 817 (bytes, tag)
796 818
@@ -874,6 +896,19 @@ parse_signature_subpacket 25 =
874-- PolicyURIPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.20 896-- PolicyURIPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.20
875parse_signature_subpacket 26 = 897parse_signature_subpacket 26 =
876 fmap (PolicyURIPacket . B.toString) getRemainingByteString 898 fmap (PolicyURIPacket . B.toString) getRemainingByteString
899-- KeyFlagsPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.21
900parse_signature_subpacket 27 = do
901 empty <- isEmpty
902 flag1 <- if empty then return 0 else get :: Get Word8
903 return $ KeyFlagsPacket {
904 certify_keys = flag1 .&. 0x01 == 0x01,
905 sign_data = flag1 .&. 0x02 == 0x02,
906 encrypt_communication = flag1 .&. 0x04 == 0x04,
907 encrypt_storage = flag1 .&. 0x08 == 0x08,
908 split_key = flag1 .&. 0x10 == 0x10,
909 authentication = flag1 .&. 0x20 == 0x20,
910 group_key = flag1 .&. 0x80 == 0x80
911 }
877-- Represent unsupported packets as their tag and literal bytes 912-- Represent unsupported packets as their tag and literal bytes
878parse_signature_subpacket tag = 913parse_signature_subpacket tag =
879 fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString 914 fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString