Mercurial > hg > release > icedtea6-1.3
changeset 108:39b17e8405ee
2007-07-19 Lillian Angel <langel@redhat.com>
* jce/gnu/javax/crypto/jce/cipher/CipherAdapter.java: Fixed incorrect
buffer sizes.
author | Lillian Angel <langel@redhat.com> |
---|---|
date | Thu, 19 Jul 2007 15:17:41 -0400 |
parents | f592eaa339a0 |
children | bb5121aaaffc |
files | ChangeLog jce/gnu/javax/crypto/jce/cipher/CipherAdapter.java |
diffstat | 2 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Jul 19 14:01:35 2007 -0400 +++ b/ChangeLog Thu Jul 19 15:17:41 2007 -0400 @@ -1,3 +1,8 @@ +2007-07-19 Lillian Angel <langel@redhat.com> + + * jce/gnu/javax/crypto/jce/cipher/CipherAdapter.java: Fixed incorrect + buffer sizes. + 2007-07-19 Lillian Angel <langel@redhat.com> * .hgignore: Ignore .* directories/files.
--- a/jce/gnu/javax/crypto/jce/cipher/CipherAdapter.java Thu Jul 19 14:01:35 2007 -0400 +++ b/jce/gnu/javax/crypto/jce/cipher/CipherAdapter.java Thu Jul 19 15:17:41 2007 -0400 @@ -378,7 +378,7 @@ if (inLen == 0) // nothing to process return new byte[0]; final int blockSize = mode.currentBlockSize(); - int blockCount = (int) (Math.ceil((double) (partLen + inLen) / (double) blockSize)); + int blockCount = (partLen + inLen) / blockSize; // always keep data for unpadding in padded decryption mode; // might even be a complete block @@ -405,7 +405,7 @@ if (inLen == 0) // nothing to process return 0; final int blockSize = mode.currentBlockSize(); - int blockCount = (int) (Math.ceil((double) (partLen + inLen) / (double) blockSize)); + int blockCount = (partLen + inLen) / blockSize; // always keep data for unpadding in padded decryption mode; // might even be a complete block if (pad != null @@ -415,19 +415,18 @@ final int result = blockCount * blockSize; if (result > out.length - outOff) throw new ShortBufferException(); + if (blockCount == 0) // not enough bytes for even 1 block { System.arraycopy(in, inOff, partBlock, partLen, inLen); partLen += inLen; return 0; } + final byte[] buf; // we have enough bytes for at least 1 block if (partLen == 0) // if no cached bytes use input - { - buf = new byte[result]; - System.arraycopy(in, 0, buf, 0, in.length); - } + buf = in; else // prefix input with cached bytes { buf = new byte[partLen + inLen]; @@ -436,12 +435,14 @@ System.arraycopy(in, inOff, buf, partLen, inLen); inOff = 0; } + for (int i = 0; i < blockCount; i++) // update blockCount * blockSize { mode.update(buf, inOff, out, outOff); inOff += blockSize; outOff += blockSize; } + partLen += inLen - result; if (partLen > 0) // cache remaining bytes from buf System.arraycopy(buf, inOff, partBlock, 0, partLen);