Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

If I have a cryptosystem built around PGP/GnuPG, I can keep my secrets safe by using an OpenPGP smart card and storing my private keys there. If I'm instead using DJB's NaCl, is there any sort of programmable smart card that I can use to store my private keys and also the NaCl code that operates on them?

I've read about Java Cards, but it seems that the only way to put your own code onto them was through the now defunct MUSCLE project, so that doesn't seem to be a viable approach. I'd love to heard that I'm wrong about this though, as it otherwise seemed promising.

My goal is ultimately to have some degree of trusted encryption on my cell phone (a BlackBerry 10, but a solution that works for Android and iPhone would be ideal), so I'm not tied to smart cards exactly, but just the idea of offloading the private key part of the encryption onto a trusted device. If there's some way to load NaCl onto a tiny linux device and talk to that from my blackberry through NFC, that would work too. All suggestions are welcome.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

These days, Java Cards have competition: .NET Cards. The main principle is the same: user-provided code runs in a virtual machine hosted by the card itself. Your main problem will be of performance.

An important part of why such programmable cards are believed to be "secure" relies on this VM: the applicative code cannot escape the VM boundaries; for instance, it won't have a buffer overflow or be able to read or write arbitrary bytes in RAM. This feature comes at a heavy price: all the applicative code is interpreted. A smart card is already quite underpowered (a good smart card may feature, say, a 50 MHz ARM-like CPU) but the interpretation implies an additional slowdown factor of 10x or 20x, meaning that any cryptography you would like to perform on such a system will be slow as Hell.

To cope with that, these smart cards include hardware accelerators, i.e. native code and dedicated circuitry to do some specific operations, usually RSA. So such a card can still compute a 2048-bit RSA signature in less than a second, a performance which is quite a feat, given the hardware. But you won't have an accelerator for a not-yet-mainstream curves like the ones in NaCl -- you usually don't have accelerator for any curve at all.

Smart cards try to achieve tamper resistance: a secret stored in such a card should remain secret, even if it is stolen and the thief tries to pry it open. This kind of security tends to come at a heavy price. It may also be quite overkill in your case.

share|improve this answer
    
Do you have experience with the .NET cards? Can one write programs for them that will interact with a normal SmartCard reader? The page says that the card can support PKCS#11, so I assume that the answer is yes, but if you have first-hand experience with this, I'd like to hear about it. –  tsuraan Sep 20 '13 at 21:03
    
I have not tried that specific feature yet, but as far as I understand, custom code works on APDU. PKCS#11 is higher-level than that, and deals only with crypto; the PKCS#11 library (the one provided by the card vendor) works by sending APDU to the card. With Windows, APDU can be sent with SCardTransmit() (from the system DLL winscard); on Linux, it seems that a PC/SC driver is to be used, e.g. from MUSCLE. Are you sure it is dead ? The mailing-list seems quite active. –  Tom Leek Sep 20 '13 at 22:14
add comment

Java cards aren't dead, you can even buy some and download the SDK to program some.

You don't need to use the provide API for everything, and you can implement your own algorithm there (given the limitations it has: memory size, processing power, etc).

Storing the private key there shouldn't be that hard. Put all the NaCl there, on the other hand, might be problematic.

share|improve this answer
1  
Maybe Java Card could be viable. All the SDK links on the given page are dead (pointing to the defunct cds.sun.com), but this page seems to have functional links to recent "revenue releases" of the SDK. Have you used Java Cards? Is getting the code running on them to interface with a typical Smart Card reader a pleasant task? –  tsuraan Sep 20 '13 at 21:15
    
Used javacards few years ago, could make them perform simple tasks, but the time/play fun ratio wasn't good. :) –  woliveirajr Sep 23 '13 at 12:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.