Question

I'm using AndroidPDFViewer library from https://github.com/jblough/Android-Pdf-Viewer-Library which I've implemented as a library on Android version 4.03. All other files work okay, I'm only having a problem trying to read a password encrypted file with a known password and using AES encryption with a 128 bit key length. I even tried hard coding the password and following it through to StandardDecrypter.java which gives me an illegal argument exception at md5.update in this loop

    if (revision >= 3) {
        for (int i = 0; i < 50; ++i) {
            md5.update(hash, 0, key.length);
            digestTo(md5, hash);    
        }
    }

What am I missing?

Was it helpful?

Solution

The error is because key.length returns a value of 128. It should be 16 because the AES 128 key is 16 bytes long.I changed this value

     final int keyLen =revision == 2 ? 5 : (keyBitLength / 8);

to

     final int keyLen =16;

it will only work for AES 128

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top