summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-05-13 13:05:56 -0400
committerJoe Crayne <joe@jerkface.net>2020-05-19 11:58:22 -0400
commit53849fa83d96f6f1b45f2a8d2b8001747a053357 (patch)
tree3a033f7cf7969862942d8d3207e86d31d57008ce
parentde7e70d424da07993fbf3efcccbdb8b1d8bff82d (diff)
Updated Features packet (draft-ietf-openpgp-rfc4880bis-09).
-rw-r--r--Data/OpenPGP.hs18
1 files changed, 14 insertions, 4 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 104c551..571e8a4 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -1185,7 +1185,11 @@ data SignatureSubpacket =
1185 } | 1185 } |
1186 SignerUserIDPacket String | 1186 SignerUserIDPacket String |
1187 ReasonForRevocationPacket RevocationCode String | 1187 ReasonForRevocationPacket RevocationCode String |
1188 FeaturesPacket {supports_mdc :: Bool} | 1188 FeaturesPacket {
1189 supports_mdc :: Bool,
1190 supports_aead :: Bool,
1191 supports_v5 :: Bool
1192 } |
1189 SignatureTargetPacket { 1193 SignatureTargetPacket {
1190 target_key_algorithm :: KeyAlgorithm, 1194 target_key_algorithm :: KeyAlgorithm,
1191 target_hash_algorithm :: HashAlgorithm, 1195 target_hash_algorithm :: HashAlgorithm,
@@ -1292,8 +1296,12 @@ put_signature_subpacket (SignerUserIDPacket userid) =
1292 (B.fromString userid, 28) 1296 (B.fromString userid, 28)
1293put_signature_subpacket (ReasonForRevocationPacket code string) = 1297put_signature_subpacket (ReasonForRevocationPacket code string) =
1294 (B.concat [encode code, B.fromString string], 29) 1298 (B.concat [encode code, B.fromString string], 29)
1295put_signature_subpacket (FeaturesPacket supports_mdc) = 1299put_signature_subpacket (FeaturesPacket supports_mdc supports_aead supports_v5) =
1296 (B.singleton $ if supports_mdc then 0x01 else 0x00, 30) 1300 (B.singleton $ mdc .|. aead .|. v5, 30)
1301 where
1302 mdc = if supports_mdc then 0x01 else 0x00
1303 aead = if supports_aead then 0x02 else 0x00
1304 v5 = if supports_v5 then 0x04 else 0x00
1297put_signature_subpacket (SignatureTargetPacket kalgo halgo hash) = 1305put_signature_subpacket (SignatureTargetPacket kalgo halgo hash) =
1298 (B.concat [encode kalgo, encode halgo, hash], 31) 1306 (B.concat [encode kalgo, encode halgo, hash], 31)
1299put_signature_subpacket (EmbeddedSignaturePacket packet) 1307put_signature_subpacket (EmbeddedSignaturePacket packet)
@@ -1403,7 +1411,9 @@ parse_signature_subpacket 30 = do
1403 empty <- isEmpty 1411 empty <- isEmpty
1404 flag1 <- if empty then return 0 else get :: Get Word8 1412 flag1 <- if empty then return 0 else get :: Get Word8
1405 return FeaturesPacket { 1413 return FeaturesPacket {
1406 supports_mdc = flag1 .&. 0x01 == 0x01 1414 supports_mdc = flag1 .&. 0x01 /= 0,
1415 supports_aead = flag1 .&. 0x02 /= 0,
1416 supports_v5 = flag1 .&. 0x04 /= 0
1407 } 1417 }
1408-- SignatureTargetPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.25 1418-- SignatureTargetPacket, http://tools.ietf.org/html/rfc4880#section-5.2.3.25
1409parse_signature_subpacket 31 = 1419parse_signature_subpacket 31 =