Ejemplo n.º 1
0
 def m2i(self, pkt, m):
     res = []
     while len(m) >= 4:
         t = struct.unpack("!H", m[:2])[0]
         tmp_len = struct.unpack("!H", m[2:4])[0]
         cls = _tls_ext_cls.get(t, TLS_Ext_Unknown)
         if cls is TLS_Ext_KeyShare:
             # TLS_Ext_KeyShare can be :
             #  - TLS_Ext_KeyShare_CH if the message is a ClientHello
             #  - TLS_Ext_KeyShare_SH if the message is a ServerHello
             #    and all parameters are accepted by the serveur
             #  - TLS_Ext_KeyShare_HRR if message is a ServerHello and
             #    the client has not provided a sufficient "key_share"
             #    extension
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_keyshare_cls  # noqa: E501
             cls = _tls_ext_keyshare_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         elif cls is TLS_Ext_PreSharedKey:
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_presharedkey_cls  # noqa: E501
             cls = _tls_ext_presharedkey_cls.get(pkt.msgtype, TLS_Ext_Unknown)  # noqa: E501
         elif cls is TLS_Ext_SupportedVersions:
             cls = _tls_ext_supported_version_cls.get(pkt.msgtype, TLS_Ext_Unknown)  # noqa: E501
         elif cls is TLS_Ext_EarlyDataIndication:
             cls = _tls_ext_early_data_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         res.append(cls(m[:tmp_len + 4], tls_session=pkt.tls_session))
         m = m[tmp_len + 4:]
     return res
Ejemplo n.º 2
0
 def m2i(self, pkt, m):
     res = []
     while m:
         t = struct.unpack("!H", m[:2])[0]
         l = struct.unpack("!H", m[2:4])[0]
         cls = _tls_ext_cls.get(t, TLS_Ext_Unknown)
         if cls is TLS_Ext_KeyShare:
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_keyshare_cls
             cls = _tls_ext_keyshare_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         elif cls is TLS_Ext_PreSharedKey:
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_presharedkey_cls
             cls = _tls_ext_presharedkey_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         res.append(cls(m[:l + 4], tls_session=pkt.tls_session))
         m = m[l + 4:]
     return res
Ejemplo n.º 3
0
 def m2i(self, pkt, m):
     res = []
     while m:
         t = struct.unpack("!H", m[:2])[0]
         l = struct.unpack("!H", m[2:4])[0]
         cls = _tls_ext_cls.get(t, TLS_Ext_Unknown)
         if cls is TLS_Ext_KeyShare:
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_keyshare_cls
             cls = _tls_ext_keyshare_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         elif cls is TLS_Ext_PreSharedKey:
             from scapy.layers.tls.keyexchange_tls13 import _tls_ext_presharedkey_cls
             cls = _tls_ext_presharedkey_cls.get(pkt.msgtype, TLS_Ext_Unknown)
         res.append(cls(m[:l+4], tls_session=pkt.tls_session))
         m = m[l+4:]
     return res