#NEWLINE# @ staticmethod #NEWLINE# def from_stream( body ) : #NEWLINE# #INDENT# 'Parse a Client Hello record from body.\n\n        Body should start with the byte representation of an RFC 5246\n        struct ClientHello\n        Returns a ClientHello and the number of bytes read from body\n\n        Throws a struct.error or IndexError if there is not enough data to parse\n        properly.\n        ' #NEWLINE# ( version , index ) = Version . from_stream ( body ) #NEWLINE# ( random , read_amt ) = Random . from_stream ( body [ index : ] ) #NEWLINE# index += read_amt #NEWLINE# sessionid_length = struct . unpack_from ( 'B' , body , index ) [ 0 ] #NEWLINE# index += 1 #NEWLINE# ( session_id , read_amt ) = parse . parse_tls_list ( body [ index : ] , sessionid_length , parse . parse_opaque ) #NEWLINE# index += read_amt #NEWLINE# cipher_length = struct . unpack_from ( '!H' , body , index ) [ 0 ] #NEWLINE# index += 2 #NEWLINE# ( ciphers , read_amt ) = parse . parse_tls_list ( body [ index : ] , cipher_length , Cipher . from_stream ) #NEWLINE# index += read_amt #NEWLINE# compression_length = struct . unpack_from ( 'B' , body , index ) [ 0 ] #NEWLINE# index += 1 #NEWLINE# ( compression_methods , read_amt ) = parse . parse_tls_list ( body [ index : ] , compression_length , CompressionMethod . from_stream ) #NEWLINE# index += read_amt #NEWLINE# extensions = [ ] #NEWLINE# if ( index != len ( body ) ) : #NEWLINE# #INDENT# extensions_length = struct . unpack_from ( '!H' , body , index ) [ 0 ] #NEWLINE# index += 2 #NEWLINE# ( extensions , read_amt ) = parse . parse_tls_list ( body [ index : ] , extensions_length , Extension . from_stream ) #NEWLINE# index += read_amt #NEWLINE# #UNINDENT# return ( ClientHello ( version , random , session_id , read_amt , compression_methods , extensions ) , index )