return plaintext
-def packets_from_bytes(data):
- offset = 0
- while offset < len(data):
- packet = PGPPacket()
- offset += packet.from_bytes(data=data[offset:])
- yield packet
-
-
class PGPKey (object):
"""An OpenPGP key with public and private parts.
key_export = _get_stdout(
['gpg', '--export', self.fingerprint])
self.public_packets = list(
- packets_from_bytes(data=key_export))
+ self._packets_from_bytes(data=key_export))
if self.public_packets[0]['type'] != 'public-key packet':
raise ValueError(
'{} does not start with a public-key packet'.format(
key_secret_export = _get_stdout(
['gpg', '--export-secret-keys', self.fingerprint])
self.secret_packets = list(
- packets_from_bytes(data=key_secret_export))
+ self._packets_from_bytes(data=key_secret_export))
if self.secret_packets[0]['type'] != 'secret-key packet':
raise ValueError(
'{} does not start with a secret-key packet'.format(
self.fingerprint))
+ def _packets_from_bytes(self, data):
+ offset = 0
+ while offset < len(data):
+ packet = PGPPacket()
+ offset += packet.from_bytes(data=data[offset:])
+ yield packet
+
def export_to_gpg(self):
raise NotImplemetedError('export to gpg')