MCPcopy Create free account
hub / github.com/secdev/scapy / TLSInnerPlaintext

Class TLSInnerPlaintext

scapy/layers/tls/record_tls13.py:36–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class 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
65class _TLSInnerPlaintextField(PacketField):

Callers 1

TLS13Class · 0.85

Calls 3

_TLSMsgListFieldClass · 0.90
ByteEnumFieldClass · 0.90
XStrFieldClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…