static int getEncryptedPacketLength(ByteBuffer[] buffers, int offset) {
        ByteBuffer buffer = buffers[offset];

        // Check if everything we need is in one ByteBuffer. If so we can make use of the fast-path.
        if (buffer.remaining() >= SSL3_RT_HEADER_LENGTH) {
            return getEncryptedPacketLength(buffer);
        }

        // We need to copy 5 bytes into a temporary buffer so we can parse out the packet length
        // easily.
        ByteBuffer tmp = ByteBuffer.allocate(SSL3_RT_HEADER_LENGTH);
        do {
            buffer = buffers[offset++];
            int pos = buffer.position();
            int limit = buffer.limit();
            if (buffer.remaining() > tmp.remaining()) {
                buffer.limit(pos + tmp.remaining());
            }
            try {
                tmp.put(buffer);
            } finally {
                // Restore the original indices.
                buffer.limit(limit);
                buffer.position(pos);
            }
        } while (tmp.hasRemaining());

        // Done, flip the buffer so we can read from it.
        tmp.flip();
        return getEncryptedPacketLength(tmp);
    }
Return how many bytes can be read out of the encrypted data. Be aware that this method will
not increase the readerIndex of the given {@link ByteBuffer}.

@param buffers The {@link ByteBuffer}s to read from. Be aware that they must have at least
{@link org.conscrypt.NativeConstants#SSL3_RT_HEADER_LENGTH} bytes to read, otherwise it will
throw an {@link IllegalArgumentException}.
@return length The length of the encrypted packet that is included in the buffer. This will
return {@code -1} if the given {@link ByteBuffer} is not encrypted at all.
@throws IllegalArgumentException Is thrown if the given {@link ByteBuffer} has not at least
{@link org.conscrypt.NativeConstants#SSL3_RT_HEADER_LENGTH} bytes to read.
common/src/main/java/org/conscrypt/SSLUtils.java