javaandroidencryptionpublic-keykeyczar

Asymmetric encryption for Android using KeyCzar


I want to create an application that encrypts messages for the server with the public key of the server. I thought to use KeyCzar, but if you have better or other good ideas, I will be glad to hear.

My questions:

  1. The application has to save the public key. Where should I store it?
  2. How can I encrypt messages with this public key? I didn't find asymmetric encryption functions. (The application will encrypt symmetric key, and the data will be encrypted by the symmetric key)

By the way, I must use public key, because messages from the same sender should not be linked by the recipient.

References and examples to such a hybrid encryption, or even just to the use of public key encryption scheme (using KeyCzar or other recommended tools), will be appreciated.


Solution

  • For Keyczar, the hybrid encryption api's are in SessionCrypter.

    There is a little more info about it in the C# version docs and should apply to java for the most part.

    Keyczar will store all of it's keys in a keyset on disk, that keyset allows for key rotation by default. But I've seen it modified to load keys from jar resources.