| 34 | |
| 35 | |
| 36 | class TLSInnerPlaintext(_GenericTLSSessionInheritance): |
| 37 | name = "TLS Inner Plaintext" |
| 38 | fields_desc = [_TLSMsgListField("msg", []), |
| 39 | ByteEnumField("type", None, _tls_type), |
| 40 | XStrField("pad", "")] |
| 41 | |
| 42 | def pre_dissect(self, s): |
| 43 | """ |
| 44 | We need to parse the padding and type as soon as possible, |
| 45 | else we won't be able to parse the message list... |
| 46 | """ |
| 47 | if len(s) < 1: |
| 48 | raise Exception("Invalid InnerPlaintext (too short).") |
| 49 | |
| 50 | tmp_len = len(s) - 1 |
| 51 | if s[-1] != b"\x00": |
| 52 | msg_len = tmp_len |
| 53 | else: |
| 54 | n = 1 |
| 55 | while s[-n] != b"\x00" and n < tmp_len: |
| 56 | n += 1 |
| 57 | msg_len = tmp_len - n |
| 58 | self.fields_desc[0].length_from = lambda pkt: msg_len |
| 59 | |
| 60 | self.type = struct.unpack("B", s[msg_len:msg_len + 1])[0] |
| 61 | |
| 62 | return s |
| 63 | |
| 64 | |
| 65 | class _TLSInnerPlaintextField(PacketField): |
no test coverage detected
searching dependent graphs…