I need to create a nested message in OpenPGP (my understanding is that the protocol itself should support it).
Let's say I have Payload
("Time in Lordran is convoluted").
I do the usual PGP encryption routine with a public key PK1
, and as a result I get encrypted session key SK1
and encrypted payload EncPY1
. I can combine this output OUT1
as a single PGP message.
Now, I want to do the same thing again: encrypt OUT1
but with public key PK2
to get OUT2
. The problem here is that OUT1
is going to generate a Literal
data packet instead of Symmetrically Encrypted Data Packet
.
It means that to retrieve the Payload
, the decryption of OUT2
by GnuPG will happen in two passes (gpg -d OUT2.gpg | gpg -d
) instead of one (gpg -d OUT2.gpg
).
Excerpt from the RFC that confirms theoretical possibility:
The Symmetrically Encrypted Data packet contains data encrypted with
a symmetric-key algorithm. When it has been decrypted, it contains
other packets (usually a literal data packet or compressed data
packet, but in theory other Symmetrically Encrypted Data packets or
sequences of packets that form whole OpenPGP messages).
I have tried OpenPGP implementation in Go and there is no API to facilitate what I need. I would like to know if there is a library in Java, Python or any other language that fits my use case.
So far I haven't seen anyone in the libraries that I looked at that has tested creation of nested messages (except for compression).