Hello OpenSSL users,

I'm doing Diffie-Hellman key agreement between Java's built-in crypto
and C++ using OpenSSL latest version 0.9.8g.
The key agreement works and the generated shared secret bytes are the
same on the Java and OpenSSL side.

The problem is when I try to use the bytes of the DH shared secret as
the secret key to a symmetric cipher (say 3DES or Blowfish in CBC
mode with PKCS5Padding) and encrypt some data from OpenSSL and send it
to Java for decryption, I get a BadPaddingException.

Now OpenSSL's default padding is the "standard/PKCS5" padding
(verified by looking at the code) which is what I've specified on the
Java side.
So this might indicate a key and/or IV mismatch issue - I've set the
IV to all zeroes to test.

I believe I have specified for the Java side symmetric cipher to use
the shared secret bytes directly as the key - I know 3DES needs odd
parity (it uses the
bytes by toggling the LSB of each byte to get odd parity) so I'm
testing with Blowfish.

But looking at the OpenSSL code for the "set key" functions for the
various symmetric ciphers, it looks like we don't use the bytes
directly, rather
we are performing some operations on the bytes before setting it as the key?

Is there any way I can get OpenSSL to directly use the bytes I provide
(as the "key" param in EVP_EncryptInit) without modifying it so that I
might avoid the BadPaddingException on the Java side?

Or is there a different issue going on and my suspicion about the key
being mismatched is incorrect?

Thanks,
Vishal
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to