aspose file tools*
The moose likes Security and the fly likes  Java Encrypt and decrypt using Open SSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark " Java Encrypt and decrypt using Open SSL" Watch " Java Encrypt and decrypt using Open SSL" New topic
Author

Java Encrypt and decrypt using Open SSL

Ashok Kumar Segu
Greenhorn

Joined: Feb 18, 2010
Posts: 2


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: 42266
    
  64
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.


Ping & DNS - my free Android networking tools app
greg stark
Ranch Hand

Joined: Aug 10, 2006
Posts: 220
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
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)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42266
    
  64
You may want to work through this thread, which explains a number DES details, including how to use 112-bit DES (which I assume is what you mean by 2-DES) in Java: http://www.coderanch.com/t/447399/Security/bit-DES-encryption-decryption
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

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.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Encrypt and decrypt using Open SSL