toofishes / python-pgpdump

PGP packet parser library
Other
55 stars 26 forks source link

Support to dump raw packets again #14

Open tyll opened 11 years ago

tyll commented 11 years ago

I am planning to add support to dump raw packets after parsing, allowing to remove or add packets to a message. I want to use this especially to remove public keys from encrypted files without reencrypting them. Is this something that might be added here or is this project intended to be allow to only read OpenPGP data?

toofishes commented 11 years ago

I wouldn't be opposed to it if it doesn't double the size of the library and make it harder to use for read-only cases. Additionally, I have been ensuring everything is source compatible (aka no 2to3 usage) for both Python 2.6+ and Python 3.2+. This can be a bit tricky with binary data, but it is not impossible.

Removing packages and then dumping the new packet stream seems easy enough if you hold onto the original data and slice and dice it in some way. For adding packets, what would this look like- populate a Python object and then ask the library to encode it, or simply attach the raw packet data directly?

tyll commented 11 years ago

I just realized that GPG is not the proper format for what I had in mind, therefore adding packets is not of priority for me anymore. For the dumping I planned to just store the raw data together with the original header in a packet object.

tyll commented 11 years ago

I just needed to split raw packet data, therefore I took a look and a quick and dirty solution is here: commit 4b4810ccb4a2d6908fe9048acbf0ad57b8bf8023

I am not yet sure about the variable naming, maybe "rawdata" instead of "raw_data" would follow the style of the test cases more. Also the test could be added to more test cases.