I was given a PGP encrypted file, and have been told I can decrypt it using a public key. I don't think that will work.

Can anyone that knows for sure how PGP works confirm that what I've been told is not achievable ?

How I've done PGP in the past was:

  1. Party A has private key (and password); A gives public key to Party B.
  2. Party B encrypts file using public key of A, then sends file back to A.
  3. Party A decrypts file, using private key (and password)

Please confirm this is how it should be done. (and preferably point me to sources that confirms exactly what I just said - there is plenty of information out there, but it is NOT explicit enough as I described).

  • Mathematically RSA decryption with a public key is possible (if the data has been encrypted with the private key). This "reversed" way is used in RSA signatures and the data that is encrypted is the signature hash. So instead of encrypting a hash you could encrypt an AES key used for encrypting some data. But as a public key is public by definition using RSA this way is useless as the encryption is ineffective as every body can decrypt the data.
    – Robert
    Feb 17, 2022 at 9:25
  • @Robert yeah those were my thoughts exactly by defn anyone could grab the public key and decrypt said file.
    – joedotnot
    Feb 17, 2022 at 19:48

1 Answer 1


Whoever told you this is almost certainly just confused. Public keys are not for decryption; your understanding is correct.

Mathematically, RSA public keys in particular could be used for decryption, and this is in fact how RSA signature verification is performed, but I doubt any library is going to let you take a public key and use it to decrypt an arbitrary-length data blob, much less an OpenPGP data packet. Besides, there's no guarantee that your file was encrypted using an RSA key at all.

The most likely explanation is just that the source of the file was a little confused, and they encrypted it with the public key (technically, PGP generates a symmetric key, encrypts the data with that key, and then encrypts the symmetric key with the public key). I assume you've already tried decrypting the file using your private key (if you have one), though.

The source of the file might also just have screwed up, and produced a detached signature rather than encrypting the file. You can verify that signature with a public key, assuming you also have the data from which it was generated (and remember that, for RSA in particular, signature verification is mathematically the same core steps as decryption even though there's a bunch of additional stuff like padding that encryption uses and signing doesn't), but I imagine if you'd been given access to the plaintext file you wouldn't be asking (and the signature alone is useless).

Best bet is just ask the source of the file exactly what they mean. Maybe get them to show you what they did, as in what command they executed or so on. If you don't even have an OpenPGP key pair, then either the source of the file could not possibly have created a file you could decrypt, or they used symmetric-only encryption (no public or private keys at all for encryption, though the data could still be signed using a private key).

  • There is a simpler explanation, the system integrator I was dealing with was just confused af, but thanks for confirming.
    – joedotnot
    Feb 17, 2022 at 19:49
  • You could use gpg --list-packets to see what crypto operation(s) was done on the message, and if that was pubkey-encryption or signing, also the keyid used (unless deliberately suppressed). This could identify or at least narrow down what the originator was trying to accomplish. Feb 18, 2022 at 2:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .