From 2ba92ff7189a2512cb12857566aa6d7afb1584e9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 20 Dec 2013 14:58:20 -0800 Subject: [PATCH] Add primary user id signature subpacket parsing to PGPPacket From RFC 4880 [1]: (1 octet, Boolean) This is a flag in a User ID's self-signature that states whether this User ID is the main User ID for this key. It is reasonable for an implementation to resolve ambiguities in preferences, etc. by referring to the primary User ID. If this flag is absent, its value is zero. If more than one User ID in a key is marked as primary, the implementation may resolve the ambiguity in any way it sees fit, but it is RECOMMENDED that priority be given to the User ID with the most recent self-signature. When appearing on a self-signature on a User ID packet, this subpacket applies only to User ID packets. When appearing on a self-signature on a User Attribute packet, this subpacket applies only to User Attribute packets. That is to say, there are two different and independent "primaries" -- one for User IDs, and one for User Attributes. [1]: http://tools.ietf.org/search/rfc4880#section-5.2.3.19 --- gpg-migrate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gpg-migrate.py b/gpg-migrate.py index 6273367..6abc19e 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -311,6 +311,9 @@ class PGPPacket (dict): return ', '.join( x for x in sorted(subpacket['key-server-preferences'])) + def _str_primary_user_id_signature_subpacket(self, subpacket): + return str(subpacket['primary-user-id']) + def _str_key_flags_signature_subpacket(self, subpacket): return ', '.join(x for x in sorted(subpacket['key-flags'])) @@ -594,6 +597,9 @@ class PGPPacket (dict): if data[0] & 0x80: subpacket['key-server-preferences'].add('no-modify') + def _parse_primary_user_id_signature_subpacket(self, data, subpacket): + subpacket['primary-user-id'] = bool(data[0]) + def _parse_key_flags_signature_subpacket(self, data, subpacket): subpacket['key-flags'] = set() if data[0] & 0x1: -- 2.26.2