Compatibility between Java crypto and open ssl

2007-10-12 Thread Metalpalo

Hello

I have some question about compatibility between java crypto and openssl
library.

This is my case:
1.I created DESede key and stored it to file:
{code}
SecretKey key = KeyGenerator.getInstance(TripleDES).generateKey();
File f = new File(c:\\key.dat);
DataOutputStream dos =new DataOutputStream(new FileOutputStream(f));
dos.write(key.getEncoded());
dos.close();
{code}

2.I encrypt some file c:\\normal.dat through:
{code}
ecipher.init(Cipher.ENCRYPT_MODE, key);
  byte[] enc = ecipher.doFinal(normalData);//normalData- loaded file
  File f2 = new File(c:\\enc.dat);
  DataOutputStream dos2 =new DataOutputStream(new FileOutputStream(f2));
  dos2.write(enc);
  dos2.close();
{code}

3.I encrypted normal data file in openssl through:
openssl.exe enc -des3 -in c:\normal.dat -out c:\enc2.dat -pass
file:c:\key.dat -nosalt

I tried other algoritm too as(des-ede,des-ede3..) but I got not equal files
as enc.dat and enc2.dat. 
I used same key in both cases.

Does exist some compatibility between encryption algorithms in java and
openssl or not? I'm interested especially in tripledes.

These functionality(encryption,decryption) will be used by any applications
developmented in C++, JAVA and VB. I need some compatibilited  des3
algorithm.

Can somebody help me ?

Thanks






-- 
View this message in context: 
http://www.nabble.com/Compatibility-between-Java-crypto-and-open-ssl-tf4611666.html#a13169808
Sent from the OpenSSL - User mailing list archive at Nabble.com.

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: Compatibility between Java crypto and open ssl

2007-10-12 Thread Julius Davies
Hi, Metalpalo,

Have you seen this?

http://juliusdavies.ca/commons-ssl/pbe.html

It doesn't quite do 100% what you're looking for, but I could probably
do a release this weekend to help you.

yours,

Julius

On 10/11/07, Metalpalo [EMAIL PROTECTED] wrote:

 Hello

 I have some question about compatibility between java crypto and openssl
 library.

 This is my case:
 1.I created DESede key and stored it to file:
 {code}
 SecretKey key = KeyGenerator.getInstance(TripleDES).generateKey();
 File f = new File(c:\\key.dat);
 DataOutputStream dos =new DataOutputStream(new FileOutputStream(f));
 dos.write(key.getEncoded());
 dos.close();
 {code}

 2.I encrypt some file c:\\normal.dat through:
 {code}
 ecipher.init(Cipher.ENCRYPT_MODE, key);
   byte[] enc = ecipher.doFinal(normalData);//normalData- loaded file
   File f2 = new File(c:\\enc.dat);
   DataOutputStream dos2 =new DataOutputStream(new FileOutputStream(f2));
   dos2.write(enc);
   dos2.close();
 {code}

 3.I encrypted normal data file in openssl through:
 openssl.exe enc -des3 -in c:\normal.dat -out c:\enc2.dat -pass
 file:c:\key.dat -nosalt

 I tried other algoritm too as(des-ede,des-ede3..) but I got not equal files
 as enc.dat and enc2.dat.
 I used same key in both cases.

 Does exist some compatibility between encryption algorithms in java and
 openssl or not? I'm interested especially in tripledes.

 These functionality(encryption,decryption) will be used by any applications
 developmented in C++, JAVA and VB. I need some compatibilited  des3
 algorithm.

 Can somebody help me ?

 Thanks






 --
 View this message in context: 
 http://www.nabble.com/Compatibility-between-Java-crypto-and-open-ssl-tf4611666.html#a13169808
 Sent from the OpenSSL - User mailing list archive at Nabble.com.

 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   [EMAIL PROTECTED]



-- 
yours,

Julius Davies
250-592-2284
http://juliusdavies.ca/
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]