

@staticmethod
def from_stream(body, previous_fragment_data=''):
    (content_type, version_major, version_minor, length) = struct.unpack_from('!BBBH', body, 0)
    if ((version_major != 3) or (version_minor > 3)):
        raise ValueError('Bad TLS Version for SSL3-TLS1.2 parsing')
    if (content_type not in name_map):
        raise ValueError(('Unknown content type %d' % content_type))
    fragment = body[5:(5 + length)]
    original_fragment = fragment
    fragment = (previous_fragment_data + fragment)
    if (len(fragment) < length):
        raise TlsRecordIncompleteError(len(fragment), length)
    type = TlsRecord.type_map.get(content_type, OpaqueFragment)
    objs = []
    try:
        if (fragment == ''):
            (obj, size) = type.from_stream(fragment)
            objs.append(obj)
        while (fragment != ''):
            (obj, size) = type.from_stream(fragment)
            objs.append(obj)
            fragment = fragment[size:]
    except TlsNotEnoughDataError:
        raise TlsMessageFragmentedError(original_fragment, (5 + length))
    return (TlsRecord(content_type, Version(version_major, version_minor), objs), (5 + length))

dataset/ETHPy150Open google/nogotofail/nogotofail/mitm/util/tls/types/record.py TlsRecord.from_stream/original