The Situation
I'm working with RSA encryption in Java. I'm trying to encrypt data on an HTC Saphire (32B) developer phone equipped with Cyanogenmod's Android 2.2 and then decrypt said data on a 64 bit server running Mandriva Linux 2010. I am using the same public key, private key pair on both machines, can correctly encrypt/decrypt data on the Android phone, can correctly encrypt/decrypt data on the Linux server, but I am unable to encrypt data on the phone and then decrypt it on the server. I get bad padding exceptions. I have confirmed that the data is being sent correctly by the phone and is being parsed correctly by the server. As such, I cannot figure out why decryption fails. Can anyone help me with this? Perhaps the RSA algorithm in Java has some underlying assumption about word size?
Further information:
- My encryption/decryption library is based on the guide found here.
- My encryption key is 2048 bits in length, but I see similar behaviour with different key sizes.
- I have packaged my RSA encryption/decryption code into a jar file. It was compiled through Eclipse on the server's machine.
- The program using the encryption library on the Android phone uses the above library. It too was built using Eclipse.
- The server program was built using Netbeans (as it was easier at the time to do so).
Other Questions
- Are there other free public-key encryption algorithms / libraries available for Java? Do they work cross-platform? What performance would one expect from them? Etc., etc. I've looked into this and haven't found much; perhaps I'm looking with the wrong keywords.
Phew! I think that's it. Thanks for your help in advance!