1. AC Question's Avatar
    I have an error with decryption with RSA.
    The code works on android 4.4 kitkat, but the same app doesn't work on android 5.0 lollipop.

    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(new BigInteger(modulusBytes), new BigInteger(exponentBytes));
    RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec);

    byte[] decrypted = null;
    try {
    // get an RSA cipher object and print the provider
    final Cipher cipher = Cipher.getInstance("RSA/None/NoPadding");

    // decrypt the text using the public key
    cipher.init(Cipher.DECRYPT_MODE, publicKey);
    decrypted = cipher.doFinal(area_fissa_byte);

    } catch (Exception ex) {
    ex.printStackTrace();
    Log.d("error","error");
    }

    The error is: java.security.SignatureException: error:04067084:rsa routines:RSA_EAY_PUBLIC_DECRYPT:data too large for modulus

    My sdk target is:
    `<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />` for android 4.4

    Do you know what is the problem?

    I notice that i have 2 different public keys with different lengths!!!
    Android 5: i have 382/383 bit (too small)
    Android 4.4: i have 384 bit (ok)
    05-28-2015 08:39 AM

Similar Threads

  1. How can I sharing a calendar on a Note 3s?
    By AC Question in forum Samsung Galaxy Note 3
    Replies: 1
    Last Post: 05-29-2015, 10:19 AM
  2. Why is Verizon forcing the lollipop update on users??
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 05-28-2015, 10:34 AM
  3. Replies: 1
    Last Post: 05-28-2015, 08:25 AM
  4. How do I know if the SD card is present or not through Android code/API?
    By AC Question in forum General Help and How To
    Replies: 0
    Last Post: 05-28-2015, 06:56 AM
  5. Why can I get wifi connected to my Android mobile but not have internet?
    By AC Question in forum General Help and How To
    Replies: 0
    Last Post: 05-28-2015, 06:51 AM
LINK TO POST COPIED TO CLIPBOARD