From: W. Trevor King Date: Sat, 21 Dec 2013 19:54:32 +0000 (-0800) Subject: Add symmetric encryption information to stringified secret key X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4aa02bf3c4b0550f07f009612279ab3ea2acbba6;p=gpg-migrate.git Add symmetric encryption information to stringified secret key You can compare this output with 'gpg --list-packets' for sanity. --- diff --git a/gpg-migrate.py b/gpg-migrate.py index c683a5b..b5050da 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -298,14 +298,31 @@ class PGPPacket (dict): def _str_public_subkey_packet(self): return self._str_generic_key_packet() + def _str_generic_key_packet(self): + return self['fingerprint'][-8:].upper() + def _str_secret_key_packet(self): - return self._str_generic_key_packet() + return self._str_generic_secret_key_packet() def _str_secret_subkey_packet(self): - return self._str_generic_key_packet() - - def _str_generic_key_packet(self): - return self['fingerprint'][-8:].upper() + return self._str_generic_secret_key_packet() + + def _str_generic_secret_key_packet(self): + lines = [self._str_generic_key_packet()] + for label, key in [ + ('symmetric encryption', + 'symmetric-encryption-algorithm'), + ('s2k hash', 'string-to-key-hash-algorithm'), + ('s2k count', 'string-to-key-count'), + ('s2k salt', 'string-to-key-salt'), + ('IV', 'initial-vector'), + ]: + if key in self: + value = self[key] + if isinstance(value, bytes): + value = ' '.join('{:02x}'.format(byte) for byte in value) + lines.append(' {}: {}'.format(label, value)) + return '\n'.join(lines) def _str_signature_packet(self): lines = [self['signature-type']]