I have a decryption error with RSA. The code works with the Android 4.4 Android kit, but the same application does not work on the Android 5 Android lottery.
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"); }
Error: java.security.SignatureException: error: 04067084: rsa routines: RSA_EAY_PUBLIC_DECRYPT: the data is too large for the module .
My sdk goal:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> for Android 4.4
Do you know what the problem is?
EDIT: I notice that I have two different public keys with different lengths !!! Android 5: I have 382/383 bits (too small) Android 4.4: I have 384 bits (normal)
EDIT2: I found that there are differences with android 5.0 for TLS / SSL: https://developer.android.com/about/versions/android-5.0-changes.html But I do not know how to fix this problem.
android-5.0-lollipop ssl rsa public-key android-4.4-kitkat
invisibleProgrammer
source share