Is is possible to encrypt message in java and decrypt the message using openssl (DES_ede2_cbc_encrypt) and the key is our own private key, vice versa
Has any one implemented the same
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
0
What do you mean by "in java"? OpenSSL is not written in Java. Are you asking whether OpenSSL can be run through Java code? If so, check out the Runtime.exec method and the ProcessBuilder class. if you meant something else, please provide more detail.
actually, I think I understand the first part of the question but I am not certain about the second part. Private key means something very specific in cryptography, namely the private component of an asymmetric keypair. Perhaps you mean secret key, which is the key for a symmetric algorithm like DES_ede2.
The general answer is yes, of course, people have implemented cryptography in Java that is interoperable with OpenSSL-based cryptography. The devil is in the details, as always.
Nice to meet you.
Ashok Kumar Segu
Greenhorn
Joined: Feb 18, 2010
Posts: 2
posted
0
greg stark wrote:actually, I think I understand the first part of the question but I am not certain about the second part. Private key means something very specific in cryptography, namely the private component of an asymmetric keypair. Perhaps you mean secret key, which is the key for a symmetric algorithm like DES_ede2.
The general answer is yes, of course, people have implemented cryptography in Java that is interoperable with OpenSSL-based cryptography. The devil is in the details, as always.
If am able to encrypt and decrypt using open ssl DES_ede2_cbc_encrypt (key1, key2 i.e. 2DES) and it works fine, my requirement I need to encrypt the message using Java Cipher or any other compatible crypto toll to encrypt the message (2DES key) , the other end uses openssl to decrypt the same (using the same 2DES key)
Ashok Kumar Segu wrote: my requirement I need to encrypt the message using Java Cipher or any other compatible crypto toll to encrypt the message (2DES key)
Is this to inter-operate with some ancient software? Otherwise, I can't think of any reasons to write code today using DES (or 2DES). DES has been obsolete for over a decade. For new software projects, use something more current.
Ashok Kumar Segu wrote:If am able to encrypt and decrypt using open ssl DES_ede2_cbc_encrypt (key1, key2 i.e. 2DES) and it works fine, my requirement I need to encrypt the message using Java Cipher or any other compatible crypto toll to encrypt the message (2DES key) , the other end uses openssl to decrypt the same (using the same 2DES key)
I believe what you are describing is still triple DES (3DES) -- basically, it does an encrypt with key 1, a decrypt with key 2, and an encrypt with key 1. The "triple" in the triple DES is referring to the number of DES operations, and not the number of keys.
I believe the Java version of triple DES (included in the core), is also ede, but uses three DES keys. So... if you try having the first and last third part of the 3 DES key being equal, it may work. You won't know til you try it though.