4

I use RSA encryption for sending messages between a server and client.

The server program is implemented in C# and the client is an Android application.

I want to know if it is possible for a message that is encrypted with a public key to be decrypted by the corresponding private key in the Android application? Is the standard for padding the same in Java libraries and .Net libraries? Can I send a message without padding?

  • 8
    Use a TLS connection. Designing your own protocol from low level primitives like RSA is difficult and prone to subtle mistakes that compromise security. Even experts make those mistakes, and your question about padding shows that you're far from being one. – CodesInChaos Oct 4 '14 at 8:13
  • TLS is not always acceptable. Actually, it's only acceptable if you want to create a real-time communication system. If you want to store an encrypted data on some [untrusted] server to download it later, TLS won't help. – Strigo May 15 at 17:13
2
  1. Do not use RSA without padding (textbook RSA): padding fixes undesirable properties of textbook RSA like malleability and semantical security.
  2. It is possible to decrypt the message in the Android application if you use the same padding in each implementation.
  3. In C#, you can specify the padding you want to use by creating an RSAEncryptionPadding object and using it as a parameter of the encrypt method from the RSACryptoServiceProvider class.
  4. In Java, you can pass a standard cipher transformations string like RSA/ECB/OAEPWithSHA-256AndMGF1Padding as parameter of the Cipher.getInstance method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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