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

crash during decoding #10

Open
tprochazka opened this issue Oct 16, 2013 · 5 comments
Open

crash during decoding #10

tprochazka opened this issue Oct 16, 2013 · 5 comments

Comments

@tprochazka
Copy link
Contributor

I have now found this crash in my app

java.lang.ArrayIndexOutOfBoundsException: src.length=16 srcPos=0 dst.length=32 dstPos=32 length=5
            at java.lang.System.arraycopy(Native Method)
            at com.android.org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(PaddedBufferedBlockCipher.java:288)
            at com.android.org.bouncycastle.jce.provider.JCEBlockCipher$BufferedGenericBlockCipher.doFinal(JCEBlockCipher.java:1045)
            at com.android.org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(JCEBlockCipher.java:693)
            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)
            at cz.idc.letenky.service.AppSettingsService.getUserLogin(AppSettingsService.java:50)
            at cz.idc.letenky.service.AppSettingsService.isUserLoggedIn(AppSettingsService.java:46)

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.

@tprochazka
Copy link
Contributor Author

So data is not corrupted, if I run application again everything works correctly. It was only some accidental problem, but try ... catch should help.

@tprochazka
Copy link
Contributor Author

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)

@DanielNovak
Copy link

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)

@tprochazka
Copy link
Contributor Author

I think the problem is that encoding/decoding are not thread safe.

@tprochazka
Copy link
Contributor Author

I fixed it here
tprochazka@fb073e8

This small changes fixed all the problems. Now I'm using my fork on several project without any problems.

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

2 participants