def from_stream(body):
        """Parse a Client Hello record from body.

        Body should start with the byte representation of an RFC 5246
        struct ClientHello
        Returns a ClientHello and the number of bytes read from body

        Throws a struct.error or IndexError if there is not enough data to parse
        properly.
        """
        version, index = Version.from_stream(body)

        random, read_amt = Random.from_stream(body[index:])
        index += read_amt

        sessionid_length = struct.unpack_from("B", body, index)[0]
        index += 1
        session_id, read_amt = (
            parse.parse_tls_list(
                body[index:], sessionid_length,
                parse.parse_opaque))
        index += read_amt

        cipher_length = struct.unpack_from("!H", body, index)[0]
        index += 2
        ciphers, read_amt = (
            parse.parse_tls_list(
                body[index:], cipher_length,
                Cipher.from_stream))
        index += read_amt

        compression_length = struct.unpack_from("B", body, index)[0]
        index += 1
        compression_methods, read_amt = (
            parse.parse_tls_list(
                body[index:], compression_length,
                CompressionMethod.from_stream))
        index += read_amt

        extensions = []
        # Check if there are extensions present
        if index != len(body):
            extensions_length = struct.unpack_from("!H", body, index)[0]
            index += 2
            extensions, read_amt = (
                parse.parse_tls_list(
                    body[index:], extensions_length,
                    Extension.from_stream))
            index += read_amt

        return ClientHello(
            version, random, session_id, ciphers, compression_methods,
            extensions), index
Parse a Client Hello record from body.

        Body should start with the byte representation of an RFC 5246
        struct ClientHello
        Returns a ClientHello and the number of bytes read from body

        Throws a struct.error or IndexError if there is not enough data to parse
        properly.
        
nogotofail/mitm/util/tls/types/handshake.py