self['type'] = self._packet_types[type_code]
return offset
+ def _parse_public_key_packet(self, data):
+ self._parse_generic_public_key_packet(data=data)
+
+ def _parse_public_subkey_packet(self, data):
+ self._parse_generic_public_key_packet(data=data)
+
+ def _parse_generic_public_key_packet(self, data):
+ self['key-version'] = data[0]
+ offset = 1
+ if self['key-version'] != 4:
+ raise NotImplementedError(
+ 'public (sub)key packet version {}'.format(
+ self['key-version']))
+ length = 5
+ self['creation_time'], self['public-key-algorithm'] = _struct.unpack(
+ '>IB', data[offset: offset + length])
+ offset += length
+ self['key'] = data[offset:]
+
def to_bytes(self):
pass
['gpg', '--export', old_key])
old_key_packets = list(
packets_from_bytes(data=old_key_export))
+ if old_key_packets[0]['type'] != 'public-key packet':
+ raise ValueError(
+ '{} does not start with a public-key packet'.format(
+ old_key))
old_key_secret_export = _get_stdout(
['gpg', '--export-secret-keys', old_key])
old_key_secret_packets = list(