Help Key: How to protect your webmail with GnuPG and FireGPG

Encryption scares a lot of people - me included - because it’s based on really complicated mathematics. Thankfully, the state of encryption software has advanced sufficiently in the last couple of years that it’s pretty easy for laypeople like us to take advantage of the protection it offers. Just like you don’t shop online without a secured HTTPS connection, you really ought not engage in private conversations online without encrypting your messages. When you encrypt your messages, you don’t need to worry so much about a college kid hacking into your Yahoo! account when you’re appointed to some high office: sure, they might get into your account, but the contents of your messages are still protected. And in this age of cloud computing, when we’re never entirely sure where any particular bit of our data might be, nor who might have access to it, encryption starts to look even more attractive.

I recommend GnuPG, the GNU Privacy Guard, the free (as in speech) implementation of the Pretty Good Privacy standard developed by Phil Zimmerman, and the FireGPG add-on for Mozilla Firefox. The great thing about this combo is that it works on GNU/Linux, Mac OSX and Windows. GnuPG uses a public key infrastructure, which takes two keys to properly encrypt anything. One key is public, which you give to everyone and anyone. The other key is private, which you must absolutely keep protected: if your private key is ever compromised, then your encrypted messages might as well be posted to Wikileaks for the world to see. Folks use your public key to encrypt a message that only you can decrypt. You use your private key to do that decrypting.

You can also use your private key to mathematically prove that you generated a message that was encrypted to someone else. Your private key is used to make something that only your public key can verify, and thus the recipient, who has a copy of your public key, knows that you sent it. There’s a whole “web of trust” involved in GnuPG’s public key infrastructure which I’m not going to cover now. You should definitely read up on the matter, though, to know how to maximimze your use of the tool.

First, download and install GnuPG. It’s a command-line tool, and a shortcoming of the installer is that it doesn’t add the GnuPG directory to your path, so you should do that now: right click My Computer, click Properties, select Advanced, click the “Environment Variables” button, highlight the PATH variable, click the Edit button, and add at the end something like this: “C:\Program Files (x86)\GNU\GnuPG”. If you’re using a 32-bit version of Windows, don’t include the ” (x86)” portion. Click OK. Let’s make sure that was done correctly: start a command prompt (Start -> Run -> “cmd”) and type “gpg –help”. GnuPG should spit out a lot of text explaining how to use its various features.

Now that GnuPG is installed, you need to generate private and public keys. This is easy. As mentioned above, your private key truly is the key to your encryption kingdom, and needs to be protected. GnuPG helps by encrypting your private key with a passphrase of your choosing. Whenever the private key is accessed, you’ll be prompted to unlock it by typing in your passphrase. You must absolutely not use as your passphrase any password you use anywhere else. I generally recommend that folks use a sentence, rather than a password: sentences are reasonably complex, in that they start with a capital letter, have lower case letters, and end in punctuation. If you can toss in a digit or two into that sentence somewhere, you have a pretty complex password. John Biggs would probably use a haiku, and that’s fine, too. Please don’t use a line from your favorite song, or poem, or television sitcom. Please don’t use a phrase you’re fond of saying out loud. Your passphrase really does need to be something absolutely private.

So, on to generating keys! From the command line, type “gpg --gen-key“. Select the default value of “DSA and Elgamal”. Next select how many bits you want in your key. The more bits there are, in theory, the more effort will be required to crack your key. The default value is 2048, and that seems pretty reasonable to me. Bigger keys means more work for your CPU, and although that’s not a big deal in this age of quad-core desktop PCs, I haven’t had anyone explain to me that a 4096 bit key is demonstrably better than a 2048 bit key. As an extra level of protection, you can set an expiration date for your key. This has a couple of nice benefits, and some real gotchas to keep in mind. An expired key is, effectively, worthless. Anything encrypted with that expired key becomes unlockable after the expiration date. This might be fine if you’re encrypting incriminating evidence, but it might be a real pain if you’re encrypting information you might want to later decrypt — say, an email you need to reference some years down the road. I generally elect not to assign an expiration date on my keys, but your circumstances might suggest otherwise. Next you need to enter some identifying information about the owner of this key (that is, you). Specifically you need to supply a name and an email address, and optionally a comment. Next you’re prompted for the passphrase for your private key. Remember, pick a good, strong passphrase. When everything is done, GnuPG will execute a complex mathematical operation looking for gigantic prime numbers. This will take a short while. When it’s all done, you’ll see the details of your key printed.

So now you have a public and a private key pair. On Windows XP, the files live in “C:\Documents and Settings\username\Application Data\gnupg”, and in Vista they should live in C:\Users\username\gnupg. You should back up your private key to a CD or USB stick, seal it in an envelope, and then deposit it into your safe deposit box. If you lose your private key, you will be unable to decrypt anything sent to you. You should keep your private key safe, and private. As is often the case with computer security, physical access trumps most software protection measures. If your computer is stolen, your private key should be considered compromised: an attacker has all the time in the world to now execute brute force attacks against the passphrase protecting your private key. If you want to be extra sneaky with your private key, you can relocate the GnuPG directory (I recommend C:\Windows\Help — who looks in there for anything?), and reference the new location from the registry or even from the command line. That, plus the strong passphrase you selected for your private key, should help protect it, but in reality a lost or stolen private key should be considered compromised, and revoked.

With your private key safe, and your computer under your control, you’re ready to start sending and receiving encrypted emails. To receive encrypted emails, you need to get your public key to those folks who send you email; and to send encrypted emails you need to get the public keys from your recipients. Ideally, the key exchange should take place in person, so that you know that the key you receive really does belong to that individual: it’s actually pretty easy to perform a man-in-the-middle attack on public key transfers, such that you think you’re getting a friend’s public key but in reality you end up getting Joe Hacker’s public key. Then, whenever you go to encrypt something to your friend, it gets encrypted to Joe Hacker’s public key: your friend can’t decrypt it and Joe Hacker can. You can post your public key on your website, or simply email it to your intended recipients, which is probably good enough to get you started. You can also use keyservers like pgp.mit.edu to look for someone’s key.

GnuPG is a command line program, which means that you need to type a bunch of commands to import new public keys, or manually feed it a text file to encrypt or decrypt. That gets pretty old pretty quickly. This is where FireGPG comes in. Install the add-on to your Firefox installation, and it’ll allow you to do most of your GnuPG tasks from a comfortable point-and-click GUI. FireGPG has a few options to set, most of which you won’t need to adjust.

Now that you have FireGPG installed, you can send yourself a test encrypted message. Using any webmail - GMail, Yahoo, Hotmail, whatever - prepare your message as you normally do. When you’re done composing the body of your message, highlight the whole thing (control + A) and right-click the selection. From the FireGPG menu, select “Encrypt”.

A window will pop up listing all of the public keys you have. Since you’re just getting started, the only public key in the list should be your own. Select your key and click OK.

Notice how the body of your message has been replaced by an indecipherable block of letters and numbers!

It’s important that you only encrypt your message when you’re actually done composing it, because it’s hard to fix a typo in that block of ciphertext.

Click send, and then check your mail. Open up the encrypted message that should now be sitting in your Inbox.

Highlight the text, right click it, select the FireGPG menu, and click Decrypt.

You’re now prompted for your private key’s passphrase.

Key it in, and click OK. A new window pops up with the plaintext contents of the message you just sent.

Congratulations: you’ve just encrypted and decrypted your first message! Remember, encryption is not a cure-all for privacy, and it requires a fair bit of diligence on your part to make it work correctly: you need to keep your private key secure, you need to verify the identity of the people who’s public keys you acquire, and you still need to use common sense when sending something that could be damaging to your future career plans.

28 Comments/Pingbacks so far

 
no image
nick (Who am I?)

No wonder no one uses Encryption in their email - did anyone else’s eyes glaze over with the complexity?

 
no image
Alex (Who am I?)

Mine sure did. But while my eyes were moving through the paragraphs, I finally remembered the name of the kid in my high school that always wore Black Sabbath T-shirts.

I’ll have to keep this post and use it when I need to peer into my sub-conscious again.

 
no image
Zoli Erdos (Who am I?)

This is indeed a very secure method… it would force us to get off email and go back to pigeons and smoke signals :-)

 
no image
AW (Who am I?)

Seriously?

“Thankfully, the state of encryption software has advanced sufficiently in the last couple of years that it’s pretty easy for laypeople like us to take advantage of the protection it offers”

You seriously need to reword your introduction, because through the other ninety-nine paragraphs in this post was like living death.

 
no image
Ginger (Who am I?)

I’ll just keep all of my comments rated G and not share any VIP info in my email. Maybe even keep my thoughts to myself… ROFL, change my font to “wingdings”. LOL

Ginger

 
no image
Piet (Who am I?)

And the klutzy complexity exposed here is only the tip of the iceberg!

Let’s suppose you want to send your friend an email which you not only want to encrypt (so that no-one else can read it) but you also want want to digitally sign (so that s/he knows that it is coming from you).

Simple.

Just encrypt it using your friend’s public key, and then encrypt it again using your private key. Then send it.

Your friend decrypts it using your public key, and then decrypts it again using hir private key.

Hours of fun for all!

 
no image
dasdas (Who am I?)

“Encryption scares a lot of people ” … do you have any idea how condescending that sounds?

 
no image
AW (Who am I?)

Thinking about this a little more, PGP-encrypted email could really take off with a little bit of integration from Google and some OpenID-inspired auto discovery of public keys based on domain names.

 
no image
Aaron Dragushan (Who am I?)

Absolutely. But until they do, you won’t be encrypting your mail as suggested here because it ALSO requires all your buddies to bother with it on their end. fail.

Love the idea, but until someone makes it easy on both ends it’ll never take off.

 
no image
magixman (Who am I?)

Or it you are Sarah Palin and want someone to hack your email and make the juicy parts public because there are no juicy parts then don’t encrypt :-)

 
no image
Tv (Who am I?)

Or use Hushmail…?

 
no image
raxit (Who am I?)

interesting but not useful :)

-raxit

 
no image
DaniMagoo (Who am I?)

If Sarah Palin can follow this, I may change my mind and vote Republican.

 
no image
Snowyprincess (Who am I?)

Nice job…but pretty complex!!!

 
no image
Ron (Who am I?)

‘gpg -–gen-key’ (not ‘gpg –gen-key’). Please fix that.

 
no image
Mike (Who am I?)

Nice post - take no notice of the “reading challenged”.

 
no image
Castle Steps (Who am I?)

I work at a hotel in Prague, and we are currently searching for a way to encrypt e-mails that we send to our guests. These e-mails include sensitive information about our guests, so obviously we need a secure way to send this to them. However, this seems much too complicated as it would require our guests to use the public key which we give them. Does anyone know of any other software that we can use which will still encrypt the information on our end, but not require our guests to do anything more than open their e-mail (as many of them only speak a little English, so these instructions would be impossible for them to understand)? Is there an e-mail service we can use which has very secure encryption?

 
no image
Stephen Paul Weber (Who am I?)

The only other ways are PKI (which requires a CA to be involved - blech) and Symmetric encryption, which encrypts to a passphrase. GPG can do symmetric encryption with FireGPG or any other tool :)

 
no image
F. D. Bryant III (Who am I?)

The problem with email encryption is that your recipient has to be able to de-crypt it. This means that they must get your public key and then use it to de-crypt it. Until we develop a system where public keys are retrieved and cached automatically and transparently email is going to remain a largely clear text activity and never a private means of communication.

Another problem is we do encryption at the wrong level for just using as a method of secure (if not necessarily private) point to point communication (which is why it cannot replace fax machines). It should be possible to form an email address with a flag to encrypt an email during transit - for instance instead of example@example.com you would send it to example@$example.com. This would tell your SMTP server that you wish this message to be encrypted. Your SMTP server would check a cache of public keys to see if it has the one for example.com. If not it would then contact SMTP server (or perhaps a key server) for example.com who would send your server its public key (perhaps via SSL as a verification method). Your server then encrypts the message and sends it. When example.com receives the message it decrypts it and the puts it in the mailbox for the recipient. This would provide method of secure communication across the Internet that is transparent and easy to use by the average user.

We have the technology, just not the infrastructure.

 
no image
Minh N. (Who am I?)

This process is a little too unwieldy for regular use with the exception of mom’s top secret lasagna recipe.

At work, we do encrypt quite a few e-mails but I would guess it is less than 1%. We do use keys for file transmission via SSH, and sometimes we even encrypt the file too.

 
no image
Stephen Paul Weber (Who am I?)

One problem with this post is the focus on Windows. On most linuxes, installing and configuring GPG is easy and can be done from a GUI. The low hanging fruit there is key verification (which is unmentioned in this post).

On Mac, there are just a few apps to install (the one installer and one DMG) to get full integration into Mail.app
Thunderbird on Mac/Linux is also not too bad.

The problem is that gpg on windows is that few nice UIs have been written.

 
Kaj Kandler

Gee, I did not know about the Firefox extensions. For those that love convenience, use HushMail (http://www.hushmail.com/) and get all this in one package.

For those that live still in the stone ages of desktop apps, use Thunderbird (http://www.mozilla.com/thunderbird/) and Enigmail (http://enigmail.mozdev.org/)

And if you want to eliminate spam, go and sign (not necessarily encrypt) every message you send. Then spam filters (http://search.cpan.org/~brondsem/Mail-SpamAssassin-Plugin-OpenPGP-1.0.4/lib/Mail/SpamAssassin/Plugin/OpenPGP.pm) can be sure it is your message and filter (pass) accordingly.

 
Kaj Kandler

You do not get the schema. In order to send encrypted information to someone you need to have the recipients public key.

If you encrypt something with your own key and publish the public key, then anybody can retrieve the public key and decrypt it (zero security).

If you guest want secure encrypted message from you, they need to have their own private/public key. If you encrypt the message with their public key, they are the only person to be able to decrypt it, because they are the only one that have the private key.

 
no image
Anon (Who am I?)

You can forget about Google doing this. How would they know which ads to show you if the message was encrypted? Just like Chrome won’t block ads, Gmail won’t encrypt messages.

 
veqon

Encryption is a great idea, but I know most of my clients would not even try to set it up. Palin’s account was hacked through password recovery. Use nonsensical answers on the questions used to establish an account. “What was the name of your first pet?” Use something like HtwoO here or georgeBush. “What city were you born in?” Not Kansas City, use Audi or Sun. Try not to get hacked in the first place.

 
Rich

Nifty stuff, Skippy. Shame the illiterate people got here to comment first. Yes, it’s complex, and you did a good job of explaining it such that it’s understandable to people who care enough about privacy to take the time to actually read it.

Fortunately, for the most part, folks too lazy to be willing to read a page of instructions generally don’t have anything worth saying in email anyways, so they’re probably not missing out on anything.

 
no image
AW (Who am I?)

Man, let me tell you, Rich, if I weren’t illiterate I’d really let you have it!

 
no image
ashutosh (Who am I?)

vegon’s advice seems more plausible to me :)

Trackbacks/Pings

Leave a Comment

« Back to text comment

Comment template by SezWho

CrunchGear Sponsors