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

How to avoid IllegalBlockSizeException? #20

Open
r0boto opened this issue Mar 5, 2018 · 1 comment
Open

How to avoid IllegalBlockSizeException? #20

r0boto opened this issue Mar 5, 2018 · 1 comment
Assignees
Labels

Comments

@r0boto
Copy link

r0boto commented Mar 5, 2018

Hello,
I still obtaining following Exception randomly during the sync (encrypt/decrypt) of the values.
I have no idea how to avoid the following Exception, what I'm doing wrong? Encryption/Decryption is processed in async services. Many thanks for any hint.

03-05 10:29:28.624 2633-2835/? W/System.err: javax.crypto.IllegalBlockSizeException: error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH
03-05 10:29:28.624 2633-2835/? W/System.err: at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
03-05 10:29:28.624 2633-2835/? W/System.err: at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:570)
03-05 10:29:28.624 2633-2835/? W/System.err: at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:351)
03-05 10:29:28.624 2633-2835/? W/System.err: at javax.crypto.Cipher.doFinal(Cipher.java:1736)
03-05 10:29:28.624 2633-2835/? W/System.err: at se.simbio.encryption.Encryption.decrypt(Encryption.java:179)
03-05 10:29:28.624 2633-2835/? W/System.err: at com.mypackage.security.Security.decryptString(Security.java:127)
03-05 10:29:28.624 2633-2835/? W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
03-05 10:29:28.624 2633-2835/? W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03-05 10:29:28.624 2633-2835/? W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
03-05 10:29:28.624 2633-2835/? W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
03-05 10:29:28.624 2633-2835/? W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
03-05 10:29:28.624 2633-2835/? W/System.err: at java.lang.Thread.run(Thread.java:764)

My Encrypt, Decrypt methods are following:

public String decryptString(final String string, Context context) {
        String decryptedString;
        if (Constants.Global.ENCRYPTION_ENABLED) {
            //Logger.d("decrypting " + string);
            if (string != null) {
                try {
                    decryptedString = encryptionInstance.decrypt(string);
                } catch (Exception e) {
                    decryptedString = "";
                    e.printStackTrace();
                }
            } else {
                decryptedString = "";
            }
        } else {
            decryptedString = string;
        }
        return decryptedString;
    }

public String encryptString(final String string, Context context) {
        String encryptedString;
        if(Constants.Global.ENCRYPTION_ENABLED) {
            //Logger.d("encrypting " + string);
            if(string != null) {
                try {
                    encryptedString = encryptionInstance.encrypt(string);
                } catch (Exception e) {
                    encryptedString = "";
                    e.printStackTrace();
                }
            } else {
                encryptedString = "";
            }
        } else {
            encryptedString  = string;
        }
        return encryptedString;
    }
@ademar111190 ademar111190 self-assigned this Mar 5, 2018
@rkpattanaik
Copy link

Is this bug fixed?
I am also getting IllegalBlockSizeException.

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

No branches or pull requests

3 participants