def _str_signature_packet(self):
lines = [self['signature-type']]
+ if self['hashed-subpackets']:
+ lines.append(' hashed subpackets:')
+ lines.extend(self._str_signature_subpackets(
+ self['hashed-subpackets'], prefix=' '))
if self['unhashed-subpackets']:
lines.append(' unhashed subpackets:')
- for subpacket in self['unhashed-subpackets']:
- method_name = '_str_{}_signature_subpacket'.format(
- self._clean_type(type=subpacket['type']))
- method = getattr(self, method_name, None)
- if method:
- lines.append(' {}: {}'.format(
- subpacket['type'],
- method(subpacket=subpacket)))
- else:
- lines.append(' {}'.format(subpacket['type']))
+ lines.extend(self._str_signature_subpackets(
+ self['unhashed-subpackets'], prefix=' '))
return '\n'.join(lines)
+ def _str_signature_subpackets(self, subpackets, prefix):
+ lines = []
+ for subpacket in subpackets:
+ method_name = '_str_{}_signature_subpacket'.format(
+ self._clean_type(type=subpacket['type']))
+ method = getattr(self, method_name, None)
+ if method:
+ lines.append(' {}: {}'.format(
+ subpacket['type'],
+ method(subpacket=subpacket)))
+ else:
+ lines.append(' {}'.format(subpacket['type']))
+ return lines
+
def _str_issuer_signature_subpacket(self, subpacket):
return subpacket['issuer'][-8:].upper()
offset += 1
hashed_count = _struct.unpack('>H', data[offset: offset + 2])[0]
offset += 2
- self['hashed-subpackets'] = data[offset: offset + hashed_count]
+ self['hashed-subpackets'] = list(self._parse_signature_subpackets(
+ data[offset: offset + hashed_count]))
offset += hashed_count
unhashed_count = _struct.unpack('>H', data[offset: offset + 2])[0]
offset += 2