3: (None, None),
}
+ _packet_types = {
+ 0: 'reserved',
+ 1: 'public-key encrypted session key packet',
+ 2: 'signature packet',
+ 3: 'symmetric-key encrypted session key packet',
+ 4: 'one-pass signature packet',
+ 5: 'secret-key packet',
+ 6: 'public-key packet',
+ 7: 'secret-subkey packet',
+ 8: 'compressed data packet',
+ 9: 'symmetrically encrypted data packet',
+ 10: 'marker packet',
+ 11: 'literal data packet',
+ 12: 'trust packet',
+ 13: 'user id packet',
+ 14: 'public-subkey packet',
+ 17: 'user attribute packet',
+ 18: 'sym. encrypted and integrity protected data packet',
+ 19: 'modification detection code packet',
+ 60: 'private',
+ 61: 'private',
+ 62: 'private',
+ 63: 'private',
+ }
+
def from_bytes(self, data):
offset = self._parse_header(data=data)
packet = data[offset:offset + self['length']]
raise ValueError('most significant packet tag bit not set')
self['new-format'] = packet_tag & 1 << 6
if self['new-format']:
- self['packet-tag'] = packet_tag & 0b111111
+ type_code = packet_tag & 0b111111
raise NotImplementedError('new-format packet length')
else:
- self['packet-tag'] = packet_tag >> 2 & 0b1111
+ type_code = packet_tag >> 2 & 0b1111
self['length-type'] = packet_tag & 0b11
length_bytes, length_type = self._old_format_packet_length_type[
self['length-type']]
length_data = data[offset: offset + length_bytes]
offset += length_bytes
self['length'] = _struct.unpack(length_format, length_data)[0]
+ self['type'] = self._packet_types[type_code]
return offset
def to_bytes(self):