Thanks for replying. I have been verifying, and re-verifying that my key and IV
are in fact the same in both C and Java.  The hex printout of the key and IV
are exactly the same.

Original Text: "This is a test"

The hex print of Java cipher text is :

740A5DBD288340D7AC8F9F20587B7F4D

And trying the command you gave, here is the result:

[EMAIL PROTECTED]:~$ echo -n "This is a test" |openssl enc -aes-128-cbc -K 9d320b14da2485e6dfa1a8eb5f2bd326 -iv 0102030405060708 |od -t x2
0000000 1e8b b7de 5736 ea6f bf54 1e6f d4d4 4a53
0000020

The value for -K is the hex printout of the key I used, both in Java and C.
the value of -iv is also the hex printout.

The result looks quite different, isn't it? Am I missing something?

Thanks

uw

From: Girish Venkatachalam <[EMAIL PROTECTED]>

You should take care that the key and IV are indeed
same. What I mean by that is that in the C and Java
code you should hardcode the actual hex values and it
should have the exact length. For instance DES
requires  8 byte key and you should hardcode something
like this.

unsigned char key[8] =
{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xff};

Similarly for IV. Make sure you do the right thing for
Java also.

And the last block will not be decrypted correctly
unless you take care to do proper PKCS padding. So
don't worry about it. Typical block size is 8 bytes,
so first you have to make sure that you get the
correct encrypted output.

Verify that against the openssl enc command. Print
your encrypted output using "%02X" format and try this
on the command line.
echo -n "something"|openssl aes-128-cbc -K <> -iv
<>|od -x

od -x prints differently from your hex output as words
are reversed but you can easily see the
correspondence.

Hope this helps.

regards,
Girish


_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to