How To: Lockdown Your Mobile E-Mail

Update 2015-04-27: We now recommend OpenKeychain over APG, the app described in this blog post. The set up is drastically easier, so you probably don’t even need this HOWTO anymore. Start by downloading K-9 and OpenKeychain, then go into OpenKeychain and start the config there.

Over the past few years it’s become increasingly popular to sound the call that ‘email is dead.’ And while many complementary forms of synchronous and asynchronous communication – from IM to social networking – have evolved since email first came on the scene, it’s hard to see email suddenly disappearing from its role as the most important way organizations communicate. I expect to be scooting around on my hoverboard by the time email goes the way of the dinosaur.

Unfortunately, many of the protocols involved in sending and receiving e-mail are not considered secure – in the sense that they are vulnerable to eavesdropping. Simple Mail Transport Protocol (SMTP) – the Internet standard for e-mail transmission across IP networks  most commonly used by client applications for sending messages to a mail server for relaying – is typically implemented without any type of transport encryption. Internet Message Access Protocol (IMAP) and Post Office Protocol (POP) suffer from the same eavesdropping issues as SMTP when implemented without transport encryption. Even when SMTP is implemented with transport encryption it does not, by default, require the authentication of e-mail message senders. As a result, mail servers cannot be sure that the senders of messages are really who they claim to be. And even though POP and IMAP require users to authenticate, messages are sent and delivered using SMTP.

The result is a situation where the recipient of an e-mail message can be positively identified but the sender cannot. Along with the eavesdropping concerns mentioned at the top of the paragraph, this is an alarming state of affairs. Imagine if the same were true of snail mail – there would be rioting in the streets! Fortunately there has been a lot of great work done to combat these fears – the main issue being that the problem itself is  still one  that is often ignored or not fully understood by the layperson. As secure solutions for mobile platforms gain momentum, we’re hoping to change things.

Enter OpenPGP, an IETF standard for encryption and decryption of data. The version of OpenPGP that exists today is the evolution of PGP, which was created in 1991 as a means for secure BBSs communication and message storage (it ironically also stands for “Pretty Good Privacy”). Why do you need PGP? In the words of its inventory, Phil Zimmerman: “It empowers people to take their privacy into their own hands.” How it works is a whole other story – one too complex for the purposes of this posting – but we’ll do our  best to scrape the surface quickly. Disclaimer: The following is meant solely as an introduction. There are many people out there who are experts in these topics, and we welcome any and all comments – especially if we misstate or misrepresent anything!

PGP uses a serial combination of hashing, data compression, symmetric-key cryptography, and, finally, public-key cryptography. From the user’s perspective, it creates two cryptographic keys to encrypt and decrypt data. The first of these two is called the Public Key – which can be freely shared with anyone the user wishes and is used by others to encrypt data so that it can be decrypted by only the intended recipient. The second key is the Private Key, which should be kept as private and safe as possible. It is used to decrypt data that has been encrypted using a specific Public Key. As long as the Private Key is kept secret, only the owner is  able to decrypt data that has been encrypted with a Public Key. One problem with older methods of encryption was the relative ease with which codes could be broken. With increasingly powerful computers that are able to crack codes via pure ‘brute force,’ encoding methods must be incredibly complex to stand up. To combat this, PGP uses a key that is astronomically large,  meaning that the security of PGP encryption lies entirely with the key as opposed to keeping the method for key generation a secret. In fact, the methods that PGP encryption uses are known and widely documented. In addition, the size of keys can be increased whenever necessary to stay one step ahead of technological advances. And for the time being, each of the algorithms in current use by PGP is not known to have cryptanalytic weaknesses.

So how secure does this make your information? Italian Police, the FBI, and British police have been unable to crack its security and have resorted to demanding private keys. It’s been likened as “the closest you’re likely to get to military-grade encryption” by cryptographer Bruce Schneier. Short answer: pretty darn good, as long as you guard your private key wisely.

You’ve probably guessed by now that the reason for this posting is to show you how to effectively use OpenPGP to secure your mobile email. And while we would’ve loved to just jump right into the tutorial, there are a few more things you should know first. Android Privacy Guard (or APG for short), is a first step at bringing OpenPGP to the Android platform, letting you manage OpenPGP keys directly from your Android phone – and use them to encrypt, sign and decrypt emails and files. Very recently the teams behind APG and the popular, open-source Android email client K-9 Mail have joined forces in a limited edition team-up to create a beta version of K-9 that plays nice with APG quite seamlessly. We’ve been using it as our default email solution at Guardian for weeks now and want to share it with you!

Note: Currently APG only supports importing and deleting keys – not generating them – so you’ve got to use a desktop implementation of OpenPGP (such as GNU Privacy Guard) to actually generate your keypair if you don’t already have one. A number of front-end applications and libraries are available to perform this task. If you already have a keypair set up, you should skip the first step.

1. Download and Install GnuPG Generate an OpenPGP keypair

Install GnuPG  here. There are binaries available for whatever OS flavor you prefer, and since they do a great job of making documentation and How-To Guides available, we’ll skip the part where we reinvent the wheel.

2. Generate and export your keypair

Follow the instructions here to create a new keypair. Export your public and private keys (re-direct from stdout to a file) and stick that file on your Android device’s SD card. Usually it’s best to create a new folder /APG to keep things organized, especially if your SD card is a mess like ours :)

3. Download APG and import your keys

If you don’t already have it, download Android Privacy Guard from its repository here or point your barcode scanner to the QR code below. You can also find it on the Market if you prefer.

Fire up APG and select ‘Manage Public Keys’ from the menu:

From the ‘Manage Public Keys’ screen, select ‘Import Keys':

From the popup dialog, select the public key that you’ve transferred to your SD card. It’s helpful to use a file browser program like Astro File Manager if you don’t already have it installed:

Once your public key(s) are successfully imported, return to the main APG menu, select ‘Manage Secret Keys’ and repeat the steps above for your Private Key.

4. Download and Configure K-9 Mail

Download the latest version of K-9 mail featuring APG integration. You can find it on the Downloads page here or, again, point your barcode scanner to the QR Code below. Whatever floats your boat.

Set up your email account by entering your email address and password, then give it a name.

For more popular accounts such as gmail, Yahoo!, etc., K-9 will automatically detect the correct configuration. For more complex accounts such as Exchange, please check out the K-9 wiki page here.

5. Send and Receive Encrypted Email!

Thanks to the integration effort by the teams at APG and K-9, actually using secure mobile email becomes easy. The compose screen features a prominent checkbox and button that allow you to sign and encrypt your outbound messages, respectively.

Decrypting messages with your private key is even easier and is literally a 1-touch experience:

Enjoy! As always, please post all questions, concerns, and jokes (only good ones please) in the Comments section. We’re very excited about the powerful combination that these two apps bring and we’d love to hear from you!

If you find any issues with APG, please report them here:

Likewise, report issues with K-9 here.

22 thoughts on “How To: Lockdown Your Mobile E-Mail

  1. Hello, everybody, nice mail client!
    But can anybody help me how to send the attach as crypted one? The only way how I did it was encrypt it in AGP, save it and then put it in client. It is the safe way, but little bit uncomfortable. It would be fine, if it could be done by one touch.
    Thanks, good work guys!

    1. Hi Pablo –
      Great question. It looks like that in the current versions of APG & K-9, the process your outline is the best one. You should feel free to contribute to the GPG integration feature request for K-9 here!

  2. K9 Pushes drafts to gmail in cleartext
    when I am formulating a reply in k9mail for android that I intend to encrypt, whenever I switch to another application, for example, to copy/paste a url, k9 save the draft and pushes it to gmail.

    This often produces many drafts during an editing session that are sent and stored in cleartext. In the gmail client only 1 draft is saved ( locally and remotely), but using k9 clutters the local and remote draft folders. Moreover, it kind of defeats the purpose of encrypting if I’m giving gmail clear text copy that could be analyzed with encrypted mail sent, possibly allowing extraction of the private key. Is there a way to stop this behavior?

  3. So does the private key have to be stored in plain text on the SD card without being guarded by the password? Because if so, this is a risk, not only if the phone gets stolen.

    1. The private key is only temporarily on the SD card until you import it into the internal APG store. Every Android app is a unique Unix user within its own sandboxed storage area within the internal /data/data path on the internal device memory.

      1. But, is the private key encrypted, as it is when using GnuPG? If someone steals your phone and is able to find your plain-text private key (be it inside of a sandboxed sstorage area or not), you could be in big trouble.

        1. It is password-protected, meaning yes, it is encrypted. However, we generally recommend that until you have full disk encryption on your device, or even possible then, that you create a new “mobile key” that is signed by your existing permanent GPG key. This way, you can limit the risk of losing a key due to device theft or unjust search.

  4. In my sad case, APG does not interoperate properly with Android 2.3.5 on Samsung Galaxy S2 Skyrocket. When encrypting, it creates undecipherable messages. One of the problems is screwing up the End-of-Line, like this (note absence of line break after “…PGP MESSAGE—–” and before “—–END PGP…”:

    —–BEGIN PGP MESSAGE—– Version: APG v1.0.8 hQGMAwBqtX3xbNliAQwAlzta0/Mj4oCnW9GD0Blt+Imhdrt3hfO4LV5bQJk2C+LI
    W1XAkEuvVD8KHJwQCepOHWTBCghT/B98WgP4p50HG2fC7r66QrhCbVnfA8LAlFEo f186uwNn7Ouosg9tX2owXnSCYNG7vhajLt/OdeqAxCwO7tTffKQ= =a1AK —–END PGP MESSAGE—–

    Clearsig messages suffer from the same problem, and K-9 plus APG don’t even try to verify/validate the signature…

    Any help would be appreciated!

    1. I know it’s an old comment, but I just worked out if I set K9 to plain text instead of HTML it works fine.

  5. whatever i do…not a single key could be imported. even the ones APG generated it self could not be loaded of the SD card once the key was deleted in APG. This software just is not good at all.

  6. Hi have just installed K9, APG, and imported my keys. I sent an email signed and encrypted successfully. But, when I sent one to the K9 client to read, I don’t get a decrypt. Instead I get an error saying, “PGP/MIME messages are not supported yet.” I got K9 from the Google Play store, do I need a newer one from elsewhere? Thanks

  7. I had installed k-9 previously and I decided to use APG to encrypt e-mails. So I did install APG on my Android device. Everything wrks fine but when I create a new e-mail a message is show on the screen saying that “k-9 doesn’t has the enough permissions to connect to APG” So when I click on send button it goes to APG and ask me to authorize the use of a key.
    Is there anyway to solve this issue? I can use all features anyway but having to allow permissions everytime I send an email is annoying.

  8. Hello
    are you still recommending APG or do you think the latest version of open keychain is better?
    APG seems to store public and secret keys in its folder unencrypted so if anyone were to access the phone unlocked they could just export the keys easily. open keychain seems not to store them in its folder that is accessible from the file manager.

    1. OpenKeychain is definitely preferred over APG. It is actively maintained, and the developers have been working hard on getting it well integrated with K-9.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>