Index: source/gnu/crypto/jce/cipher/CipherAdapter.java =================================================================== RCS file: /cvsroot/gnu-crypto/gnu-crypto/source/gnu/crypto/jce/cipher/CipherAdapter.java,v retrieving revision 1.3 diff -u -B -b -r1.3 CipherAdapter.java --- source/gnu/crypto/jce/cipher/CipherAdapter.java 28 Sep 2003 00:10:35 -0000 1.3 +++ source/gnu/crypto/jce/cipher/CipherAdapter.java 2 Oct 2005 20:33:29 -0000 @@ -243,14 +243,7 @@ System.arraycopy(kbb, 0, kb, 0, keyLen); } attributes.put(IBlockCipher.KEY_MATERIAL, kb); - mode.reset(); - mode.init(attributes); - if (pad != null) { - pad.reset(); - pad.init(blockLen); - } - partBlock = new byte[blockLen]; - partLen = 0; + reset (); } protected void @@ -409,6 +402,17 @@ } result = buf; } + + try + { + reset (); + } + catch (InvalidKeyException ike) + { + // Should not happen; if we initialized it with the current + // parameters before, we should be able to do it again. + throw new Error (ike); + } return result; } @@ -422,5 +426,17 @@ } System.arraycopy(buf, 0, out, outOff, buf.length); return buf.length; + } + + private void reset () throws InvalidKeyException + { + mode.reset(); + mode.init(attributes); + if (pad != null) { + pad.reset(); + pad.init(blockLen); + } + partBlock = new byte[blockLen]; + partLen = 0; } }