Author: Joe Barr
the public and secret versions of your GNU Privacy Guard (GnuPG) keys. But if you’re a government employee who wants to become a whistle-blower
and report corruption, evil-doers, or gross mismanagement, you’ll need to do more than create your keys. You’ll need to encrypt and sign the email you
send me with your exposé.A private key is just that: private. You protect it. You don’t share it, don’t publish it, and don’t email it to friends. You need access to your private key — that’s when you’re asked for your passphrase — when you:
- Read data encrypted with your public key
- Create a digital signature
Your public key, on the other hand, is meant to be shared. Publish it on a key
server, give it to friends, put it on your Web site. The more people that have
your public key, the more people who can send you secure communications. People need your
public key in order to:
- Encrypt data that can only be read with your private key
- Verify a digital signature as yours
Trust me on this: NOT
For secure communications, you need to logically fingerprint public keys, then verify the fingerprint with the
owner. Why? Because that’s the only way you can be sure that it was issued by the person claiming that it’s his. Anybody can generate a key using someone else’s name and email address, so check those fingerprints before trusting public keys overly much.
Here’s how to get a set of prints for a key on your keyring, where the string “joe@pjprimer” is unique to the key in question:
gpg --fingerprint joe@pjprimer
GnuPG will reply with a fingerprint in this format:
pub 1024D/CD6F1760 2004-05-11 Joe Barr <email@example.com>
Key fingerprint = C01C FA50 A9F0 AFC5 3285 AAC8 6EB9 FC1D CD6F 1760
Once you’ve verified that the public key really belongs to the person you think it does, you can use it to encrypt all your secret data and send it to him.
Assume that you have a text file on your system called hotscoop.txt that you don’t want exposed to anyone other than me, else heads will roll and yours might be one of them. Encrypting it — and signing it at the same time so that only I can read it and so that I can be sure it came from you — is as easy as typing:
gpg -es -r firstname.lastname@example.org hotscoop.txt
The output of the command shown above is a new file called hotscoop.txt.gpg. It’s a compressed binary file that you can send as an email attachment. Please note that you now have the same document on your system in both plaintext and encrypted form, and be aware that that is a very bad thing.
It’s much worse to compromise both versions than it is for someone to read the plaintext version, because with both versions of the data your key is compromised. That means that all of your previous and future “secure” communications based on the key are compromised as well. So get rid of at least one version.
The only folks I know who disagree that this is a dangerous practice are the Microsoft Exchange design people, who chose to send supposedly encrypted mail in plaintext between the email client and the Exchange server, then do the encryption, then send the mail on to its final destination. In doing so, they chose ease of use over any semblance of a clue about security.
Reading secret mail
When I receive the secret mail you’ve sent, decrypting it is easy. Just enter:
gpg --decrypt hotscoop.txt.gpg
GnuPG will ask for my passphrase, then produce print the plaintext data to your console. Since the data was also signed, the command also verifies the signature.
You can specify a file to be used for the output instead by inserting
--output hotscoop.txt between the
gpg command and the
Be aware that this leaves you with both plaintext and encrypted versions on your
system. One or the other should be removed.
OK, now that you know how to do it, start sending me all your secrets!