javax.crypto.IllegalBlockSizeException: Input length must be multiple
of 8 when decrypting with padded cipher
at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)
If *de*crypting fails, mentioning a wrongly-sized input, then
something went wrong with gathering the crypted data or passing
it to the decrypter.
If you read in the data from a file, perhaps some kind of
conversion was applied to it (e.g. CrLf->Lf) or some extra
encoding that was applied on the crpto-text (e.g. base64)
wasn't undone before decrypting.
An "sscce" (<http://sscce.org/>) would surely help *you* (by
allowing us to spot the error in your code). But even just
an excerpt of your code may suffice, if you happen to post
the right excerpt (the one that actually contains the bug).
>javax.crypto.IllegalBlockSizeException: Input length must be multiple
>of 8 when decrypting with padded cipher
see:
http://mindprod.com/jgloss/runerrormessages.html#ILLEGALBLOCKSIZEEXCEPTION
--
Roedy Green Canadian Mind Products
http://mindprod.com
"If you think it�s expensive to hire a professional to do the job, wait until you hire an amateur."
~ Red Adair (born: 1915-06-18 died: 2004-08-07 at age: 89)
Assuming that you are using a block cypher in CBC mode, then your
input plaintext will be padded to a whole number of blocks. This
means that your cyphertext will be longer than the original plaintext.
If you leave off the extra cyphertext then you will get the error you
are seeing. I suggest you check that a) you are getting all of the
cyphertext from the encrypt method and b) you are passing all of the
cyphertext to the decrypt method. It is a mistake to assume that the
cyphertext is the same length as the plaintext.
I note that you are using a 64 bit (=8 byte) block cypher, probably
DES or 3DES. Unless you absolutely need to use these for backwards
compatibility then you should use AES (32 bit/16 byte) instead. Both
DES and 3DES are obsolete.
rossum
I would say that the padding depends on padding not on mode.
Arne
The amount of padding may depend on the mode. CBC mode requires one
whole block or less of padding. CTR mode requires no padding at all.
The padding spec determines the content of the padding.
rossum