Add key expiration time subpacket parsing to PGPPacket
authorW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 23:05:11 +0000 (15:05 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 02:32:14 +0000 (18:32 -0800)
From RFC 4880 [1]:

  (4-octet time field)

  The validity period of the key.  This is the number of seconds after
  the key creation time that the key expires.  If this is not present
  or has a value of zero, the key never expires.  This is found only
  on a self-signature.

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

gpg-migrate.py

index 47ea115904569695299a043a8a47af1421645ee2..30b80b4566cb48cc3f521f0ccda25cb208b9af91 100755 (executable)
@@ -295,6 +295,9 @@ class PGPPacket (dict):
     def _str_issuer_signature_subpacket(self, subpacket):
         return subpacket['issuer'][-8:].upper()
 
+    def _str_key_expiration_time_signature_subpacket(self, subpacket):
+        return str(subpacket['key-expiration-time'])
+
     def _str_preferred_symmetric_algorithms_signature_subpacket(
             self, subpacket):
         return ', '.join(
@@ -583,6 +586,10 @@ class PGPPacket (dict):
     def _parse_issuer_signature_subpacket(self, data, subpacket):
         subpacket['issuer'] = ''.join('{:02x}'.format(byte) for byte in data)
 
+    def _parse_key_expiration_time_signature_subpacket(
+            self, data, subpacket):
+        subpacket['key-expiration-time'] = _struct.unpack('>I', data)[0]
+
     def _parse_preferred_symmetric_algorithms_signature_subpacket(
             self, data, subpacket):
         subpacket['preferred-symmetric-algorithms'] = [