Open tprochazka opened 11 years ago
So data is not corrupted, if I run application again everything works correctly. It was only some accidental problem, but try ... catch should help.
And another accident crash
java.lang.RuntimeException: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.EVP_CipherFinal_ex(Native Method)
at org.apache.harmony.xnet.provider.jsse.OpenSSLCipher.doFinalInternal(OpenSSLCipher.java:398)
at org.apache.harmony.xnet.provider.jsse.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:434)
at javax.crypto.Cipher.doFinal(Cipher.java:1111)
at edu.gmu.tec.scout.utilities.Encryption.decrypt(Encryption.java:94)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.createDecodedObjectStream(EncryptionHelper.java:101)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.readDecoded(EncryptionHelper.java:88)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.readAndDecodeTemplate(EncryptionHelper.java:44)
at com.github.kovmarci86.android.secure.preferences.SecureSharedPreferences.getString(SecureSharedPreferences.java:74)
Here is another one, crashed during getting a string
Unhandled exception java.lang.RuntimeException: error:0607B083:digital envelope routines:EVP_CipherInit_ex:no cipher set
java.lang.RuntimeException: error:0607B083:digital envelope routines:EVP_CipherInit_ex:no cipher set
at com.android.org.conscrypt.NativeCrypto.EVP_CipherInit_ex(Native Method)
at com.android.org.conscrypt.OpenSSLCipher.reset(OpenSSLCipher.java:391)
at com.android.org.conscrypt.OpenSSLCipher.doFinalInternal(OpenSSLCipher.java:434)
at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:456)
at javax.crypto.Cipher.doFinal(Cipher.java:1204)
at edu.gmu.tec.scout.utilities.Encryption.decrypt(Encryption.java:94)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.createDecodedObjectStream(EncryptionHelper.java:101)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.readDecoded(EncryptionHelper.java:88)
at com.github.kovmarci86.android.secure.preferences.encryption.EncryptionHelper.readAndDecodeTemplate(EncryptionHelper.java:44)
at com.github.kovmarci86.android.secure.preferences.SecureSharedPreferences.getString(SecureSharedPreferences.java:74)
I think the problem is that encoding/decoding are not thread safe.
I fixed it here https://github.com/tprochazka/android-secure-preferences/commit/fb073e8c61c0a78d3afece4e4731fbd23bfccec0
This small changes fixed all the problems. Now I'm using my fork on several project without any problems.
I have now found this crash in my app
Maybe encrypted data was corrupted accidently and now is not possible decrypt them, but it should by handled and better would be return default value in this situation than app crash. And log error to the logcat.