Re: AES runs on crypto++ and on Java Framework JCE with bouncy castle, but i can exchange the encrypted text
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


sci.crypt archive

Re: AES runs on crypto++ and on Java Framework JCE with bouncy castle, but i can exchange the encrypted text

From: Gregory G Rose <ggr@qualcomm.com>
Date: Thu Dec 22 2005 - 21:42:43 CET

In article <1135270732.928320.3430@g49g2000cwa.googlegroups.com>,
Jo <josef.pointner@art-of-quality.de> wrote:
>If i use in my Java-application the secrete key with the assoziated
>encrypted text generated in my C++-application, my Java-application
>crashes with the Exception "BadPaddingException: pad block corrupted".
>If i use in my C++-application the secrete key with the assoziated
>encrypted text generated in my Java-application, my C++-application
>crashes with the Exception "StreamTransformationFilter invalid PKCS#7
>block padding found"

There is no real chance that the actual encryption
algorithms in these two reputable modules don't
work. I'm just guessing, but it sounds like they
are using different block padding schemes for the
final partial blocks.

The problem is that when the data isn't a multiple
of the block size, you can't put it into the
cipher unless you somehow fill up the block first.
There are a couple of different ways to do this.
One is to fill each of the empty bytes witha byte
giving the number of padding bytes required.
Another is to fill with zeros except for the last
byte, which again tells the number of padding
bytes added.

My guess from the errors that you are seeing is
that they are doing it differently, and checking
after decryption that they get what they expected.

Anyway, you can get the source code for both, and
go looking at how they are doing the padding.

Greg.

-- 
Greg Rose
232B EC8F 44C6 C853 D68F  E107 E6BF CD2F 1081 A37C
Qualcomm Australia: http://www.qualcomm.com.au
Received on Fri Dec 23 20:11:32 2005