From b113bea8a21e7646903ee3825bf499756c546cbc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 20 Dec 2013 14:10:21 -0800 Subject: [PATCH] Add features signature subpacket parsing to PGPPacket From RFC 4880 [1]: (N octets of flags) The Features subpacket denotes which advanced OpenPGP features a user's implementation supports. This is so that as features are added to OpenPGP that cannot be backwards-compatible, a user can state that they can use that feature. The flags are single bits that indicate that a given feature is supported. This subpacket is similar to a preferences subpacket, and only appears in a self-signature. An implementation SHOULD NOT use a feature listed when sending to a user who does not state that they can use it. Defined features are as follows: First octet: 0x01 - Modification Detection (packets 18 and 19) [1]: http://tools.ietf.org/search/rfc4880#section-5.2.3.24 --- gpg-migrate.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gpg-migrate.py b/gpg-migrate.py index 9fa4c02..6055eb1 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -310,6 +310,9 @@ class PGPPacket (dict): def _str_key_flags_signature_subpacket(self, subpacket): return ', '.join(x for x in sorted(subpacket['key-flags'])) + def _str_features_signature_subpacket(self, subpacket): + return ', '.join(x for x in sorted(subpacket['features'])) + def _str_embedded_signature_signature_subpacket(self, subpacket): return subpacket['embedded']['signature-type'] @@ -598,6 +601,11 @@ class PGPPacket (dict): if data[0] & 0x80: subpacket['key-flags'].add('private shared') + def _parse_features_signature_subpacket(self, data, subpacket): + subpacket['features'] = set() + if data[0] & 0x1: + subpacket['features'].add('modification detection') + def _parse_embedded_signature_signature_subpacket(self, data, subpacket): subpacket['embedded'] = PGPPacket() subpacket['embedded']._parse_signature_packet(data=data) -- 2.26.2