private void nextChunk() throws GeneralSecurityException, IOException { if (chunkSize != -1) { int index = (int)(pos >> chunkBits); initCipherForBlock(cipher, index); if (lastIndex != index) { long skipN = (index - lastIndex) << chunkBits; if (super.skip(skipN) < skipN) { throw new EOFException("buffer underrun"); } } lastIndex = index + 1; } final int todo = (int)Math.min(size, chunk.length); int readBytes, totalBytes = 0; do { readBytes = super.read(plain, totalBytes, todo-totalBytes); totalBytes += Math.max(0, readBytes); } while (readBytes != -1 && totalBytes < todo); if (readBytes == -1 && pos+totalBytes < size && size < Integer.MAX_VALUE) { throw new EOFException("buffer underrun"); } System.arraycopy(plain, 0, chunk, 0, totalBytes); invokeCipher(totalBytes, totalBytes == chunkSize); }
private void nextChunk() throws GeneralSecurityException, IOException { if (chunkSize != -1) { int index = (int)(pos >> chunkBits); initCipherForBlock(cipher, index); if (lastIndex != index) { long skipN = (index - lastIndex) << chunkBits; if (super.skip(skipN) < skipN) { throw new EOFException("buffer underrun"); } } lastIndex = index + 1; } final int todo = (int)Math.min(size, chunk.length); int readBytes, totalBytes = 0; do { readBytes = super.read(plain, totalBytes, todo-totalBytes); totalBytes += Math.max(0, readBytes); } while (readBytes != -1 && totalBytes < todo); if (readBytes == -1 && pos+totalBytes < size && size < Integer.MAX_VALUE) { throw new EOFException("buffer underrun"); } System.arraycopy(plain, 0, chunk, 0, totalBytes); invokeCipher(totalBytes, totalBytes == chunkSize); }