iamMehedi / Secured-Preference-Store

A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
563 stars 97 forks source link

IllegalBlocksizeException Huawei p8 lite ALE-L21 #20

Open fermedina opened 6 years ago

fermedina commented 6 years ago

Hi. I have an issue similar to 18. When I try store an string in Huawei p8 lite ALE-L21 I get this error:

10-24 14:49:24.216 10624-10721/com.twogetherbank.app W/System.err: javax.crypto.IllegalBlockSizeException
10-24 14:49:24.221 10624-10721/com.twogetherbank.app W/System.err:     at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:486)
10-24 14:49:24.221 10624-10721/com.twogetherbank.app W/System.err:     at javax.crypto.Cipher.doFinal(Cipher.java:1505)
10-24 14:49:24.221 10624-10721/com.twogetherbank.app W/System.err:     at devliving.online.securedpreferencestore.EncryptionManager.encryptAES(EncryptionManager.java:401)
10-24 14:49:24.221 10624-10721/com.twogetherbank.app W/System.err:     at devliving.online.securedpreferencestore.EncryptionManager.encrypt(EncryptionManager.java:242)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at devliving.online.securedpreferencestore.EncryptionManager.tryEncrypt(EncryptionManager.java:175)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at devliving.online.securedpreferencestore.EncryptionManager.encrypt(EncryptionManager.java:287)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at devliving.online.securedpreferencestore.SecuredPreferenceStore$Editor.putString(SecuredPreferenceStore.java:232)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at com.twogetherbank.app.utils.managers.CategoryManager$loadCategoriesFromServer$1.invoke(CategoryManager.kt:64)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at com.twogetherbank.app.utils.managers.CategoryManager$loadCategoriesFromServer$1.invoke(CategoryManager.kt:18)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at org.jetbrains.anko.AsyncKt$doAsync$1.invoke(Async.kt:140)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at org.jetbrains.anko.AsyncKt$doAsync$1.invoke(Async.kt)
10-24 14:49:24.222 10624-10721/com.twogetherbank.app W/System.err:     at org.jetbrains.anko.AsyncKt$sam$Callable$761a5578.call(Async.kt)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err:     at java.lang.Thread.run(Thread.java:833)
10-24 14:49:24.224 10624-10721/com.twogetherbank.app W/System.err: Caused by: android.security.KeyStoreException: -65536
10-24 14:49:24.225 10624-10721/com.twogetherbank.app W/System.err:     at android.security.KeyStore.getKeyStoreException(KeyStore.java:632)
10-24 14:49:24.225 10624-10721/com.twogetherbank.app W/System.err:     at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.update(KeyStoreCryptoOperationChunkedStreamer.java:132)
10-24 14:49:24.225 10624-10721/com.twogetherbank.app W/System.err:     at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:217)
10-24 14:49:24.225 10624-10721/com.twogetherbank.app W/System.err:     at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:473)
10-24 14:49:24.225 10624-10721/com.twogetherbank.app W/System.err:  ... 17 more

In others devices the library works fine.

Can you help me?

fermedina commented 6 years ago

Hi! I have the same problems in all Huawei devices. What is the problem?

iamMehedi commented 6 years ago

So the library is not working at all on those devices? Or does this happen after you've changed PIN/Password/Fingerprint of the device? And please share the OS version and the type of screen security you had in place.

Gaetano-Dati commented 6 years ago

Hi, same problem here.. Android O is the OS and the device is a Nexus6 Emulator. Trying to put a jsonString from GSon library. GSon.toJson(string)

iamMehedi commented 6 years ago

@Gaetano-Dati thanks for the info. I'll see if I can reproduce it and find out the reason behind it.

Gaetano-Dati commented 6 years ago

So did you come out and find the solution? Thanks

iamMehedi commented 6 years ago

@Gaetano-Dati Tried the sample app on A Nexus 6 emulator with Android O (with google APIs) but couldn't reproduce the issue.

Gaetano-Dati commented 6 years ago

The issue was reproduced on a physical device during a robo test by firebase. The error is at the moment the Application class gets called. I didn't experience this error on one of my devices but I don't have a Huawei. I emulated the Application on a Nexus 6 with Android O and It didn't give me the error. Have you got a Huawei physical devices in order to test it?

Gaetano-Dati commented 6 years ago

I'm talking about this issue: KeyStoreService.del null object reference on HUAWEI device 7.0 #25

I pasted this because we are in another thread. I found a solution to my first issue which is at the starting point of this list.

iamMehedi commented 6 years ago

@Gaetano-Dati No, unfortunately don't have a Huawei device for testing.