@Override
	protected int fill() throws IOException {
		// test if it was the last package
		if (packetLen == 0 && partial == false) {
			// stream ends here
			if (len == 0)
				len = -1;
			return -1;
		}

		fillInputBuf();

		if (packetLen == 0 && partial) {
			decodePacketLen();
		}

		int minlen = (int) Math.min((long) inputLen, packetLen);
		try {
			if (packetLen == minlen && partial == false) {
				len += cipher.doFinal(buf, inputPos, minlen, outBuf, len + pos);
			} else {
				len += cipher.update(buf, inputPos, minlen, outBuf, len + pos);
			}
		} catch (Exception e) {
			throw new IOException(e);
		}
		inputPos += minlen;
		inputLen -= minlen;
		packetLen -= minlen;

		return len;
	}