Hi,
I have a Java server that generates a RSA public/private key (
KeyPairGenerator.getInstance("RSA")
), the public key is sent to a C# client and it uses it to encrypt some data to be sent back to the server.
However, the decryption on the server-wise fails because it appeared that the same data generated random outputs (from C#).
Then I came across: http://blogs.msdn.com/shawnfa/archive/2006/01/05/509444.aspx
Basically, RSA uses random padding on the input bytes.
In C#, i am using
rsaCryptoServiceProvider.Encrypt(clearData, false)
(therefore PKCS #1 v1.5)
In Java, I tried to use
Cipher.getInstance("RSA/ECB/PKCS1PADDING")
but it fails with the following exception:
javax.crypto.IllegalBlockSizeException: Data must not be longer than 128 bytes.
Any idea how to fix the Java-side (or C# side)
Thx