[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] BUG: need to re-initialize Cipher encrypt/decrypt objects after each use.



Hi,
 
I think there exist a bug with the current JCE implementation.

I have to re-initialize the Cipher encrypt/decrypt objects after each use.
This is not the behavior in the SunJCE or documented in the JCE specs.
 
So here is what I do:
Cipher cipherEncrypt;
Cipher cipherDecrypt;
 
cipherEncrypt = Cipher.getInstance( "DES/CBC/NoPadding" );
cipherEncrypt.init( Cipher.ENCRYPT_MODE, key, ivSpec );
cipherDecrypt = Cipher.getInstance( "DES/CBC/NoPadding" );
cipherDecrypt.init( Cipher.DECRYPT_MODE, key, ivSpec );
 
byte[] cipherEncryptText = cipherEncrypt.doFinal( text );
byte[] cipherDecryptText = cipherDecrypt.doFinal( cipherEncryptText );
 
If I want to use cipherEncrypt or cipherDecrypt again, I HAVE to
re-initialize both of these objects to get the same cleartext.  I do not
think that the Cipher object is saving the feedback bits correctly.

Thanks, please feel free to mail me if this is unclear.

--Gavin




_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-jce