Crypto++ encryption/JCE decryption

Hi,

Has anyone had any luck integrating crypto++ with java? I need to decrypt a string encrypted by the crypto++ code. It is using the DefaultEncryptorWithMAC which says it is a Password-Based Encryptor using DES-EDE2 (a triple des pass twice) and HMAC/SHA-1. Being a relative newbie to encryption, I assumed I'd use PBEWithHmacSHA1AndDESede with the SecretKeyFactory and Cipher. I assume I'll have to use BouncyCastle for that as I didn't see it as an option in what is provided out of the box.

Has anyone done this before or can provide some insight as to which direction I should head?

[610 byte] By [jarza] at [2007-11-27 10:59:10]
# 1

I have used DES encryption in crypto++. I have been able to encrypt data using crypto++ and decrypted using the JCE and decrypt using crypto++ data that was encrypted using the JCE. BUT, I used explicit keys and not PBE.

If you solve the problem then please post the code here.

sabre150a at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...
# 2

I've made no further progress to this point. Can you post an example of what you did get working? We're early enough in the process to change both sides to finds some sort of mutual compatibility. I did find this sample which is what I may end up going with, http://osdir.com/ml/encryption.cryptopp/2003-09/msg00047.html.

jarza at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...
# 3

> I've made no further progress to this point. Can you

> post an example of what you did get working?

Sorry, but I would have to get permission from the company I did the work for. I might at some point try to create a nice simple example but not a this point. If you are a competent C++ programmer then it should take you no more than a day to get a prototype working.

If you are early in the design process then consider AES rather than DES ede.

sabre150a at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...
# 4

> I might at some point try

> to create a nice simple example but not a this point.

> If you are a competent C++ programmer then it should

> take you no more than a day to get a prototype

> working.

It has just taken me less than an hour to create a working Cryptip++ <> Java string encryption/decryption based on the examples in http://www.cryptopp.com/fom-serve/cache/79.html and the standard JCE examples I have posted. The code I produced this time is much more general than I produced for my client a couple of years ago.

Some of the code in http://www.cryptopp.com/fom-serve/cache/79.html is faulty because of missing includes and bad C++ to HTML conversion but easy enough to fix.

sabre150a at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...
# 5

I'm not much of a C++ programmer, I can read enough to understand the basics of whats going on. I'm working with another programmer who is working on the C++ end. We resolved our issues and have 3DES working. I appreciate the tip on AES. Being relatively new to cryptography, I didn't realize it was the current standard, so I went forward with what was suggested. I'll definitely look into it.

jarza at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...
# 6

I need to Decrypt a file generated using BlowFish C++ from Java. the C++ implementation uses a literal string to generate key. I have followed the same mechanism in java but I am not able to successfully decrypt the file. Any suggestions.

cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");

byte[] raw = "TestKey...".getBytes();

skeySpec = new SecretKeySpec(raw, "Blowfish");

sundarlalcha at 2007-7-29 12:21:14 > top of Java-index,Security,Cryptography...