An Android Phone As A Secure Key Container

26 December 2019

Speaking of recycling old Droids, there is an application that I am particularly interested in and that is keeping encryption and signing keys secure even while using them. An encryption key in its form is a small piece of data (a couple kilobytes). It is, by its nature, very easy to steal, on the other hand, it is very difficult to forge. A device that allows the user to use such a key without risking that the computer may leak it, is called a smart card.

What are smart cards?

A smart card is a so-called authorization device that can be used for a purpose similar what we would hire an actual doorkeeper for. A doorkeeper holds keys for doors, he or she can recognize you (authenticate) and can use one of the keys for you if he or she finds your permissions eligible (authorize). The keys, however, are never given in your hands. The most you can ask such an electronic doorman is to throw a key away, no matter who you are.

smart cards

A smart card is a hardware device designed among other purposes to secure the use of encryption, one time pad and other keys of that matter. Once you’ve sent a key to a smart card, you are unable to retrieve it again. After proving you identity (usually by entering a PIN or touching a fingerprint sensor), you can use the key, or you can delete it, but you cannot download it. As a consequence, neither a spyware is able to do that on your machine, waiting to steal your key. The hardware simply does not support that instruction. The most harm a virus could cause against this protection is using the hardware while it is plugged into the computer. Disconnecting it leaves the malicious software is disarmed.

What can I do with a smart card?

With a computer, a smart card may come in hand for:

  • Encrypting or decrypting data
  • Digitally signing software, emails or messages
  • Using for authentication, even for logging into a remote resource, such as a VPN server or a machine through SSH

Okay, maybe you’re sold, maybe not. Let me present the idea anyway :)

A “silent” smart phone as a secure key container

Disclaimer: what I am thinking about is not converting an Android phone into an NFC card reader, neither emulating a contactless NFC smart card. (Here is an interesting article by Mohamed Hamdaoui on the topic). Instead, I would like to create a safe key container that is accessible from a computer via a smart card interface.

If you have a phone that is incapable of remotely transmitting data (preferably, either by physically damaging or removing the transmitters - well, if this is possible at all -, or at least by rooting the phone and disabling the drivers), your phone can also behave like a secure container…

…but, wouldn’t it be simpler to just purchase a smart card instead of all that hassle above, then?

Well, If you need maximum security in an enterprise environment, preferably with support and hardware certification, then I strongly suggest you investing in actual smart cards and stop reading. This is a proof of concept project at the “i have an idea” state, not a robust solution. On the other hand, if you only would like to use a somewhat better safe for your OpenPGP or S/MIME signing keys than your computer itself, you may consider these advantages:

  • Given a complete solution of this project, converting your phone would be as easy as installing an app and downloading a driver for your computer.
  • You don’t need to purchase hardware (in comparison: a YubiKey device usually costs around $40)
  • You can emulate virtually any number of smart cards on a single android device - as keys are quite small -, therefore what you get is a virtually unlimited number of smart cards.
    • This is particularly useful in the case of OpenPGP keys where the standard only allows you to have one key per purpose on a smart card.

In order to achieve that, we need a secure, and preferably a stable, independent communication line to our Android device - and a WiFi connection is not something I would consider eligible for that purpose, even if it is much easier to implement. This is my motivation behind achieving communication over USB with an android app.

Ambitious talk…

Actually, converting an old phone into a smart card-like device in that sense seems to be a big enough topic for me and for my free time to have the reason to worry about quantum computing. It may evolve to the point quicker, where data signing and encryption may no longer will be relevant, than I will be able to build something useful out of an old phone for this purpose. However, I still like this idea for keeping encryption keys secure and I am willing to invest some amount of time in it for the sake of experience.

At the very least, I am ready to do some research.

Follow the series for updates!