Closed hearsilent closed 8 years ago
Hey will look into this,
Can you tell us about the android version and the device used?
cc @ragdroid @vickyturtle
LG Nexus 5X Android 6.0.1
Thx :)
@hearsilent Please share the whole stacktrace.
Right now I think maybe the exception is related to key policy settings in your jdk.
Oops, the whole stacktrace has disappear. If I get the exception next time, I'll share the whole stacktrace for you.
Thanks for your help.
@vashisthg I got the exception again.
05-13 11:41:46.757 20434-20434/com.hearsilent.example W/System.err: Caused by: java.security.InvalidKeyException: Failed to unwrap key
05-13 11:41:46.758 20434-20434/com.hearsilent.example W/System.err: at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:618)
05-13 11:41:46.758 20434-20434/com.hearsilent.example W/System.err: at javax.crypto.Cipher.unwrap(Cipher.java:1707)
05-13 11:41:46.758 20434-20434/com.hearsilent.example W/System.err: at in.co.ophio.secure.vault.SecretKeyWrapper.unwrap(SecretKeyWrapper.java:112)
05-13 11:41:46.759 20434-20434/com.hearsilent.example W/System.err: at in.co.ophio.secure.core.KeyStoreKeyGenerator.loadOrGenerateKeys(KeyStoreKeyGenerator.java:78)
05-13 11:41:46.759 20434-20434/com.hearsilent.example W/System.err: at in.co.ophio.secure.core.KeyStoreKeyGenerator.<init>(KeyStoreKeyGenerator.java:46)
05-13 11:41:46.760 20434-20434/com.hearsilent.example W/System.err: ... 74 more
05-13 11:41:46.760 20434-20434/com.hearsilent.example W/System.err: Caused by: javax.crypto.IllegalBlockSizeException
05-13 11:41:46.761 20434-20434/com.hearsilent.example W/System.err: at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:486)
05-13 11:41:46.761 20434-20434/com.hearsilent.example W/System.err: at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:616)
05-13 11:41:46.762 20434-20434/com.hearsilent.example W/System.err: ... 78 more
05-13 11:41:46.762 20434-20434/com.hearsilent.example W/System.err: Caused by: android.security.KeyStoreException: Unknown error
05-13 11:41:46.763 20434-20434/com.hearsilent.example W/System.err: at android.security.KeyStore.getKeyStoreException(KeyStore.java:632)
05-13 11:41:46.763 20434-20434/com.hearsilent.example W/System.err: at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
05-13 11:41:46.764 20434-20434/com.hearsilent.example W/System.err: at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:473)
05-13 11:41:46.764 20434-20434/com.hearsilent.example W/System.err: ... 79 more
@ragdroid @hearsilent I think the issue is due to key policy settings in the jdk as I too had it year back. A quick google search gives me http://stackoverflow.com/questions/6765240/rsa-aes-decryption-fails-invalidkeyexception .
Hi. I'm using this in an Android app and have users crashing on this problem. I read the Stackoverflow link you posted, however I am not 100% clear on what it means. Is there a fix for this issue or is it completely unavoidable?
@adrientruong @hearsilent @vashisthg I have exactly same issue (with same stack trace), that happens only on some Android devices... have you managed to find the reason of the problem or a way to fix it?
@vashisthg @ragdroid Any updates on this one?
@marcinbak / @adrientruong Have you maybe managed to solve the issue?
The same bug appears randomly on some Android devices in my app, however, after cleaning the app data the issue is gone. Could it be connected with writing/reading a key file from storage?
Could we reopen this ticket again? I have same issue in my app.
@AlexanderKovalchuk definitely. I'll try to reproduce it and will open another issue & PR once I'm sure where the problem is.
@mjurekov @vashisthg @ragdroid I have found a workaround for this issue. The cause is https://issuetracker.google.com/issues/37137351
Created pull request with the workaround https://github.com/ophio/secure-preferences/pull/26 but Travis seems not able to create emulator and failed check.
I am also having this issue. Seems to be happening only when I minify my code, at least based on my observations. I am seeing it happen on my Xiaomi A1 with the latest /as of writing this comment/ Android Oreo update. No problems on my Xiaomi Redmi Note 4x, running MIUI9. That is just about all useful information I can provide.
Did anyone try to set "android:allowBackup="false" in manifest? This helped me
I init the KeyGenerator by this code:
But I got the IllegalStateException:
How can I resolve this problem?