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?

3
  • 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. Oct 4, 2014 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, 2019 at 17:13
  • Were you able to solve this problem? I am having the same issues
    – viper
    May 7, 2021 at 3:58

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .