Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: key.length == 0 #22

Open
AlvaroBro opened this issue Nov 10, 2017 · 6 comments
Open

java.lang.IllegalArgumentException: key.length == 0 #22

AlvaroBro opened this issue Nov 10, 2017 · 6 comments
Assignees

Comments

@AlvaroBro
Copy link

AlvaroBro commented Nov 10, 2017

When initializing the library I got this situation: it will fail to init due to IllegalArgumentException.
I was doing some tests regarding recovery after a keystore deletion due to unlock pattern/pin/password changes. Usually the recovery was as expected, but one of the times it got stuck in this situation, and only reinstalling the app would fix it.

11-10 09:30:32.331: E/OpenSSLKeyMaster(195): OpenSSL error in openssl_sign_rsa 67526788: error:04066084:rsa routines:RSA_EAY_PRIVATE_ENCRYPT:data too large for modulus
11-10 09:30:32.331: W/keystore(195): device couldn't sign data
11-10 09:30:32.331: W/OpenSSL-keystore-rsa(6391): No valid signature returned
11-10 09:30:32.335: E/OpenSSLKeyMaster(195): OpenSSL error in openssl_sign_rsa 67547258: error:0406B07A:rsa routines:RSA_padding_add_none:data too small for key size
11-10 09:30:32.335: W/keystore(195): device couldn't sign data
11-10 09:30:32.335: W/OpenSSL-keystore-rsa(6391): No valid signature returned
11-10 09:30:32.335: W/System.err(6391): java.lang.IllegalArgumentException: key.length == 0
11-10 09:30:32.335: W/System.err(6391): 	at javax.crypto.spec.SecretKeySpec.<init>(SecretKeySpec.java:62)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.EncryptionManager.getFallbackAESKey(EncryptionManager.java:555)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.EncryptionManager.loadKey(EncryptionManager.java:465)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:146)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.EncryptionManager.<init>(EncryptionManager.java:124)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.SecuredPreferenceStore.<init>(SecuredPreferenceStore.java:42)
11-10 09:30:32.335: W/System.err(6391): 	at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:87)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.MultiprocessPreferencesProvider.init(MultiprocessPreferencesProvider.java:69)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.MultiprocessPreferencesProvider.getContentUri(MultiprocessPreferencesProvider.java:522)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.MultiprocessPreferencesProvider.access$0(MultiprocessPreferencesProvider.java:520)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.MultiprocessPreferencesProvider$MultiprocessSharedPreferences.getString(MultiprocessPreferencesProvider.java:488)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.SpotBrosProvider$SpotbrosDatabaseHelper.getDBEncryptionPassword(SpotBrosProvider.java:2414)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.SpotBrosProvider$SpotbrosDatabaseHelper.access$0(SpotBrosProvider.java:2407)
11-10 09:30:32.335: W/System.err(6391): 	at com.spotbros.database.SpotBrosProvider.onCreate(SpotBrosProvider.java:2667)
11-10 09:30:32.335: W/System.err(6391): 	at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
11-10 09:30:32.339: W/System.err(6391): 	at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread.access$1500(ActivityThread.java:135)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-10 09:30:32.339: W/System.err(6391): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 09:30:32.339: W/System.err(6391): 	at android.os.Looper.loop(Looper.java:136)
11-10 09:30:32.339: W/System.err(6391): 	at android.app.ActivityThread.main(ActivityThread.java:5001)
11-10 09:30:32.339: W/System.err(6391): 	at java.lang.reflect.Method.invokeNative(Native Method)
11-10 09:30:32.339: W/System.err(6391): 	at java.lang.reflect.Method.invoke(Method.java:515)
11-10 09:30:32.339: W/System.err(6391): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-10 09:30:32.339: W/System.err(6391): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-10 09:30:32.339: W/System.err(6391): 	at dalvik.system.NativeStart.main(Native Method)
11-10 09:30:32.343: W/dalvikvm(6391): threadid=1: thread exiting with uncaught exception (group=0xa4d87b20)
11-10 09:30:32.347: E/AndroidRuntime(6391): FATAL EXCEPTION: main
11-10 09:30:32.347: E/AndroidRuntime(6391): Process: com.spotbros.enterprise, PID: 6391
11-10 09:30:32.347: E/AndroidRuntime(6391): java.lang.RuntimeException: Unable to get provider com.imbox.database.ImboxProvider: java.lang.IllegalStateException: Must call init() before using the store
11-10 09:30:32.347: E/AndroidRuntime(6391): 	at android.app.ActivityThread.installProvider(ActivityThread.java:4777)
11-10 09:30:32.347: E/AndroidRuntime(6391): 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
11-10 09:30:32.347: E/AndroidRuntime(6391): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)

@AlvaroBro
Copy link
Author

Android 4.4.4 in genymotion emulator.

@iamMehedi iamMehedi self-assigned this Nov 12, 2017
@iamMehedi
Copy link
Owner

Hey @AlvaroBro can you please provide details of how I might try to reproduce this?

@AlvaroBro
Copy link
Author

Hi, yes sure I will do so eventually when I have some extra time. Thanks!

@matthew-niemann
Copy link

I had an incoming crash report showing the same, only from one user so far. Since it this report was sent in via an SDK, I unfortunately have no reproduction steps.

Device: Samsung SM-G313HN
Version: 4.4.2

@ghost
Copy link

ghost commented Jul 5, 2018

@matthew-niemann , basically I could reproduce this using some unit tests in API 21. During debug I noticed that the prefs contained the hash of the ALIAS therefore one could not generate the AESKey and next time when it was needed it was not there. Therefore, the problem. I fixed it by just changing to a new prefs name.

@iamMehedi
Copy link
Owner

@RobartGmbH so it happens when you change the device security (PIN/Password) and open the app after that? I am trying to understand if it's happening coz the recovery is failing to generate new keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants