Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to encryption in general and GPG in particular. My use case is storing personal documents on a network drive. These documents are scans (e.g. diplomas, papers). I generated a GPG key using gpg --gen-key, then encrypted a few images using gpg -e -r <name> <file>. By default it seems to output files named after the original and suffixed by .gpg, for instance diploma.jpg becomes diploma.jpg.gpg.

If the type of the document is known, am I opening the door to a known plaintext attack?

Also, what steps should I take to backup my key (print it on paper...)?

share|improve this question
up vote 2 down vote accepted

i would not worry about the filename and possible knowledge of the first few bytes. but if you are uneasy with that, consider this:

  • you might use a container, either .7z or .zip with aes encryption
  • you might use a container program such as truecrypt

keep in mind:

  • gpg encrypts your file in mixed mode, meaning: it uses the asymetric key to encrypt a "session key" and then use that session key to encrypt the actual data. so, you actually gain nothing by using asymetric keys to encrypt stuff that only you care about (remember: asymetric encryption is only useful for something like key-exchange when the amount of data is relatively small)

  • there is no reason to not use symetric encryption since you want to memorize the passphrase to your files / the container anyway: gpg --symmetric -e

since you described yourself as a newbie to the topic: read a little bit about it in the gnupg-manual:

share|improve this answer
Thanks for the info, I did not know about the symmetric encryption feature. – Rom1 Aug 19 '11 at 8:26

GPG will compress the file prior to encrypting it, which reduces the chances of a plain text attack, regardless of file type. Furthermore, should a rare case of a message being compromised occur it is not indicative of a compromised key amongst the recipients of that message.

The reason for the latter part pertains to the process by which GPG encrypts messages and files. First the content is compressed, usually using zlib. Then the compressed data is symmetrically encrypted with a one time password called a session key. Then the session key is asymmetrically encrypted with the public keys of the recipients. When the message is decrypted the process is reversed: the recipient unlocks the session key using their secret key and passphrase, GPG uses the session key to decrypt the symmetrically encrypted data and finally it is uncompressed.

An attack on a single message is more likely to result in determining the session key than compromising any of the public keys.

If you still want to conceal the file types then do this:

gpg -ear $RECIPIENT_ID -o filename.asc filename.odt

To restore the original filename when decrypting, do this:

gpg --use-embedded-filename filename.asc

GPG will write the decrypted data to the original filename, which is stored in the symmetrically encrypted data, along with other information necessary to rebuild the data.

Note: do not use the above embedded filename flag if manually decrypting ciphertext from an email program, especially if using Thunderbird and Enigmail. Many email encryption programs (including Thunderbird and Enigmail) do not assign an original filename from the draft and decrypting that way could cause problems, like trying to write data to a null filename.

share|improve this answer

AFAIK knowing the data type an encrypted file holds is of no use at all for cracking, since encryption doesn't care about the type of data. For encryption, they're mere bits (numbers) with no meaning at all.

About your key, most secure option is to remember it because your mind cannot be accessed ;)

share|improve this answer
It does not care about the type of the data, but if a bad guy knows that my cleartext file begins with PNG it might tell something about the key...? Also the key is not something that I can commit to memory (unlike the passphrase), it is much too long. – Rom1 Aug 19 '11 at 8:10
Even if he knows it begins with PNG that tells nothing about the key. He might even know the whole data and still no go (unless brute-forcing or doing dictionary attacks). You can store your key in a keyring, or on another encrypted file with a different encryption scheme. I don't like the paper solution since paper is more easily accessable than one might think. – m0skit0 Aug 19 '11 at 8:16

You must log in to answer this question.

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