summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 16:52:23 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 16:52:23 -0500
commitdb574b20691ba16f64f33d797b8135d256835ca3 (patch)
tree27e7215db79c3ac9f26aba07e1a538a25f9b4703
parent5170c6cbfc5e6f2bb3eb901bbadb8eed9eb15640 (diff)
NotationDataPacket
-rw-r--r--Data/OpenPGP.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index f152aeb..dff3ae5 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -700,6 +700,11 @@ data SignatureSubpacket =
700 revocation_key_fingerprint::String 700 revocation_key_fingerprint::String
701 } | 701 } |
702 IssuerPacket String | 702 IssuerPacket String |
703 NotationDataPacket {
704 human_readable::Bool,
705 notation_name::String,
706 notation_value::String
707 } |
703 UnsupportedSignatureSubpacket Word8 B.ByteString 708 UnsupportedSignatureSubpacket Word8 B.ByteString
704 deriving (Show, Read, Eq) 709 deriving (Show, Read, Eq)
705 710
@@ -756,6 +761,18 @@ put_signature_subpacket (RevocationKeyPacket sensitive kalgo fpr) =
756 fpri = fst $ head $ readHex fpr 761 fpri = fst $ head $ readHex fpr
757put_signature_subpacket (IssuerPacket keyid) = 762put_signature_subpacket (IssuerPacket keyid) =
758 (encode (fst $ head $ readHex keyid :: Word64), 16) 763 (encode (fst $ head $ readHex keyid :: Word64), 16)
764put_signature_subpacket (NotationDataPacket human_readable name value) =
765 (B.concat [
766 B.pack [flag1,0,0,0],
767 encode (fromIntegral (B.length namebs) :: Word16),
768 encode (fromIntegral (B.length valuebs) :: Word16),
769 namebs,
770 valuebs
771 ], 20)
772 where
773 valuebs = B.fromString value
774 namebs = B.fromString name
775 flag1 = if human_readable then 0x80 else 0x0
759put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) = 776put_signature_subpacket (UnsupportedSignatureSubpacket tag bytes) =
760 (bytes, tag) 777 (bytes, tag)
761 778
@@ -802,6 +819,20 @@ parse_signature_subpacket 16 = do
802 return $ IssuerPacket (pad $ map toUpper $ showHex keyid "") 819 return $ IssuerPacket (pad $ map toUpper $ showHex keyid "")
803 where 820 where
804 pad s = replicate (16 - length s) '0' ++ s 821 pad s = replicate (16 - length s) '0' ++ s
822-- NotationDataPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.16
823parse_signature_subpacket 20 = do
824 (flag1,_,_,_) <- get4word8
825 (m,n) <- liftM2 (,) get get :: Get (Word16,Word16)
826 name <- fmap B.toString $ getSomeByteString $ fromIntegral m
827 value <- fmap B.toString $ getSomeByteString $ fromIntegral n
828 return $ NotationDataPacket {
829 human_readable = flag1 == 0x80,
830 notation_name = name,
831 notation_value = value
832 }
833 where
834 get4word8 :: Get (Word8,Word8,Word8,Word8)
835 get4word8 = liftM4 (,,,) get get get get
805-- Represent unsupported packets as their tag and literal bytes 836-- Represent unsupported packets as their tag and literal bytes
806parse_signature_subpacket tag = 837parse_signature_subpacket tag =
807 fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString 838 fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString