0 Replies Latest reply on Dec 7, 2010 9:07 PM by 821962

    Decryption problems  when using RSA provided in JSR 177

      I am using the crypto package in the jsr 177 package in my midlet. In particular I am using RSA encryption with public key, by using Cipher.getInstance("RSA").
      The encryption seem to happen without problems, but it seems impossible to then decrypt this information!
      First of all, it cannot be done in the midlet itself since there is no object to store a private key to use for decryption, but apart from that, I am using this to communicate in a secure way
      with a Server, so it is the server that needs to decrypt the data.
      The problem is that when using Cipher.getInstance("RSA") on the server (and therefore sdk not j2me), in decryption mode and the private key on the data encrypted on the mobile,
      i get the following exception:

      javax.crypto.BadPaddingException: Data must start with zero

      If I do both encryption and decryption on the server, it works fine, so there must be something with the RSA algorithm in the jsr 177 package.
      By default Cipher.getInstance("RSA") seems to be equivalent to Cipher.getInstance("RSA/NONE/PKCS1Padding") in j2me, and there does not seem a way to change this parameters.
      Unfortunatly it is not possible to use Cipher.getInstance("RSA/NONE/PKCS1Padding") on the server as you get the folowing exception:

      java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/PKCS1Padding

      So, what's left (if I only want to use standard libraries and not external ones like Bouncy Castle)? How is it possible that there is no standard way to decrypt something encrypted with the javax.crypto package provided with j2me?

      Hope someone cna help, I am getting crazy with this problem!