Skip to content Skip to sidebar Skip to footer

Cipher Pad Block Corrupted On Gingerbread

I believe this is a snippet from androidsnippets.org - why this isn't funcioning on Android 2.3? How to fix it? Error 03-05 23:19:17.479: WARN/System.err(3598): javax.crypto.BadPad

Solution 1:

Two points:

1) The toByte() method isn't clear what it's trying to do, but I'll bet it's wrong, as the line

intlen = hexString.length()/2;

is going to give the same result of 3 for strings of length 6 and 7 (say)

2) You can't rely on converting stings to byte arrays without specifying the Charset to use. Different locales and different run machines may have different default Charsets. You should probably use str.getBytes("UTF8") in the algorithm.

Solution 2:

NickT says: "is going to give the same result of 3 for strings of length 6 and 7 (say)" I suppose that length of HEX string in that case is always EVEN number (see function appendHex)

Solution 3:

It's problem with BouncyCastle (BouncyCastle AES error when upgrading to 1.45).

What I have found is that this results in two different values for BC 1.34 vs 1.45.

I couldn't find the solution, yet...

Post a Comment for "Cipher Pad Block Corrupted On Gingerbread"