Add key server preferences signature subpacket parsing to PGPPacket
authorW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 22:52:57 +0000 (14:52 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 02:32:14 +0000 (18:32 -0800)
From RFC 4880 [1]:

  (N octets of flags)

  This is a list of one-bit flags that indicate preferences that the
  key holder has about how the key is handled on a key server.  All
  undefined flags MUST be zero.

  First octet: 0x80 = No-modify
    the key holder requests that this key only be modified or updated
    by the key holder or an administrator of the key server.

  This is found only on a self-signature.

[1]: http://tools.ietf.org/search/rfc4880#section-5.2.3.17

gpg-migrate.py

index 6055eb105020b88528ce07b113151590aa95ec2e..6273367b8fc6c64a03815c927431bb5cb7c8b51c 100755 (executable)
@@ -307,6 +307,10 @@ class PGPPacket (dict):
         return ', '.join(
             algo for algo in subpacket['preferred-compression-algorithms'])
 
         return ', '.join(
             algo for algo in subpacket['preferred-compression-algorithms'])
 
+    def _str_key_server_preferences_signature_subpacket(self, subpacket):
+        return ', '.join(
+            x for x in sorted(subpacket['key-server-preferences']))
+
     def _str_key_flags_signature_subpacket(self, subpacket):
         return ', '.join(x for x in sorted(subpacket['key-flags']))
 
     def _str_key_flags_signature_subpacket(self, subpacket):
         return ', '.join(x for x in sorted(subpacket['key-flags']))
 
@@ -584,6 +588,12 @@ class PGPPacket (dict):
         subpacket['preferred-compression-algorithms'] = [
             self._compression_algorithms[d] for d in data]
 
         subpacket['preferred-compression-algorithms'] = [
             self._compression_algorithms[d] for d in data]
 
+    def _parse_key_server_preferences_signature_subpacket(
+            self, data, subpacket):
+        subpacket['key-server-preferences'] = set()
+        if data[0] & 0x80:
+            subpacket['key-server-preferences'].add('no-modify')
+
     def _parse_key_flags_signature_subpacket(self, data, subpacket):
         subpacket['key-flags'] = set()
         if data[0] & 0x1:
     def _parse_key_flags_signature_subpacket(self, data, subpacket):
         subpacket['key-flags'] = set()
         if data[0] & 0x1: