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?

  • 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 – Frank Thomas Sep 6 '17 at 12:37
  • Providing the full terminal output (with perhaps -vvvvvv verbosity) for all the decryptions would be very helpful – Xen2050 Sep 7 '17 at 6:17
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 alice@example.org -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 alice@example.org --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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.