Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.crypto and Perl module Crypt::CBC

843811Jul 5 2006 — edited Feb 1 2010
Hi,

My problem is when I encrypt on the JAVA side with :

String inkey = "123456781234567812345678";
final byte[] ivBytes = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};

byte[] rawkey = inkey.getBytes();
DESedeKeySpec keyspec = new DESedeKeySpec(rawkey);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede");
SecretKey key = keyfactory.generateSecret(keyspec);

encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, iv);


synchronized public String encrypt(String Entry) throws Exception {
byte[] EntryBytes = Entry.getBytes(characterEncoding);
byte[] encryptedEntryBytes = this.encryptCipher.doFinal(EntryBytes);
String encodedEncryptedEntry = this.base64Encoder.encode(encryptedEntryBytes);
return encodedEncryptedEntry;
}

and try to decrypt on the Perl side with :

$cbc_encrypt_key = "123456781234567812345678";
$cbc_iv = "12345678";

$css_cipher = Crypt::CBC->new(
-cipher => DES_EDE3,
-key => $cbc_encrypt_key,
-iv => $cbc_iv,
-header => 'none'
);

$info = decode_base64($info);
$info = $css_cipher->decrypt($info);

it doesn't work at all, Perl can't decrypt. Is there any compatibilty problem ? or is my code wrong (i suppose so)

Please help me
Ed
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2010
Added on Jul 5 2006
38 comments
985 views