On Mon, Dec 04, 2006, Marc Saegesser wrote:

> I have an existing application (which I don't control) that sends me files
> that were encrypted using an openssl comand like:
> 
> openssl enc -e -des -pass pass:<passphrase>
> 
> I would like to decrypt these files inside a Java application and generate
> response files that the client can decrypt using a similar openssl command.
> 
> I've been trying to figure out how to do this using the javax.crypto API but
> so far I haven't had any luck.  I know the passphrase used to encrypt the
> data but I haven't figured out the right way to use it to generate a key
> using javax.crypto that is valid to decrypt the data.
> 
> I'd appreciate any help or pointers

Well you have to first implement EVP_BytesToKey() then use that to derive the
appropriate DES key and IV based on the salt and passphrase. You are in luck
because that function is compatible with PKCS#5 v1.5 when the key size is small
enough which it is for DES.

You can use the enc debugging options to make sure you get the right key and
IV.

Then finally use that key and IV to decrypt the data.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to