0

I have file that had to be decrypted twice to get that actual data file. The command that I used to decrypt file is:

gpg -o Tesfile.txt -d Testfile.txt.pgp

What I read is, if the decrypted file is signed, the signature is also verified. -d option also verify and decrypt the file. But this particular file is not getting decrypted at once.

What gpg command should I use decrypt the file using a single command?

2
  • 1
    are you sure that particular file was not just encrypted twice? --decrypt should not need to run twice for a file (signed or otherwise), and if you did run it twice, you should not expect different results (eg once it did nothing and the second time it decrypted the file). gnupg.org/gph/en/manual/x110.html Sep 6, 2017 at 12:37
  • Providing the full terminal output (with perhaps -vvvvvv verbosity) for all the decryptions would be very helpful
    – Xen2050
    Sep 7, 2017 at 6:17

1 Answer 1

0

If a file is encrypted and signed in a single pass, you can also decrypt and verify in a single pass. In this case, the OpenPGP message is constructed of OpenPGP packets that provide the encryption layer, and inside the encryption container, the message is signed:

gpg --recipient [email protected] -o file.gpg --sign --encrypt file

But of course, one might first sign a message (for example by running gpg --clearsign file) and then encrypt the output manually (observe that gpg is called twize):

gpg --clearsign file | gpg --recipient [email protected] --encrypt -o file.gpg

In this case, the clearsigned file (this wraps both signature and message in a single file, instead of providing a separate signature file) is encrypted in a second run, and all OpenPGP headers are repeated.

You can analyze an OpenPGP message's structure by running gpg --list-packets <filename>, which provides a very technical description of the OpenPGP messages including all individual OpenPGP packets and headers. Reading RFC 4880, OpenPGP will help at understanding the output.

You must log in to answer this question.

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