#NEWLINE# @ staticmethod #NEWLINE# def from_stream( body ) : #NEWLINE# #INDENT# ( msg_type , length ) = struct . unpack ( '!BI' , ( ( body [ 0 ] + '\x00' ) + body [ 1 : 4 ] ) ) #NEWLINE# if ( msg_type not in name_map ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Unknown HanshakeMessage type %d' % msg_type ) ) #NEWLINE# #UNINDENT# body = body [ 4 : ( 4 + length ) ] #NEWLINE# if ( length != len ( body ) ) : #NEWLINE# #INDENT# raise TlsNotEnoughDataError ( ) #NEWLINE# #UNINDENT# type = HandshakeMessage . type_map . get ( msg_type , OpaqueMessage ) #NEWLINE# ( obj , size ) = type . from_stream ( body ) #NEWLINE# if ( len ( body ) != size ) : #NEWLINE# #INDENT# raise ValueError ( 'Read mismatch' ) #NEWLINE# #UNINDENT# return ( HandshakeMessage ( msg_type , obj ) , ( length + 4 ) )