@Override
	protected boolean readNextChunk() throws IOException {
		byte[] readBuffer = new byte[DEFAULT_BUFFER_SIZE];

		// Reset the current chunk and offset
		currentChunk = null;
		chunkPos = 0;

		if (cipher == null) {
			return false;
		}

		int bytesRead = delegate.read(readBuffer);

		if (bytesRead <= 0) {
			// No more bytes available finalize the decryption
			try {
				currentChunk = cipher.doFinal();
			}
			catch (IllegalBlockSizeException | BadPaddingException e) {
				throw new IOException(e);
			}
			finally {
				// prevents trying to call doFinal() again
				cipher = null;
			}
		}
		else {
			currentChunk = cipher.update(readBuffer, 0, bytesRead);
		}

		return currentChunk != null && currentChunk.length > 0;
	}
Read the next chunk in the stream and decrypt

@return True if more data is now available, False otherwise.
@throws IOException If there is a read failure of the data
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/cart/CartV1StreamDecryptor.java