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

Class TLSEncryptedExtensions

scapy/layers/tls/handshake.py:752–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750
751
752class TLSEncryptedExtensions(_TLSHandshake):
753 name = "TLS 1.3 Handshake - Encrypted Extensions"
754 fields_desc = [ByteEnumField("msgtype", 8, _tls_handshake_type),
755 ThreeBytesField("msglen", None),
756 _ExtensionsLenField("extlen", None, length_of="ext"),
757 _ExtensionsField("ext", None,
758 length_from=lambda pkt: pkt.msglen - 2)]
759
760 def post_build_tls_session_update(self, msg_str):
761 self.tls_session_update(msg_str)
762
763 s = self.tls_session
764 connection_end = s.connection_end
765
766 # Check if the server early_data extension is present in
767 # EncryptedExtensions message (if so, early data was accepted by the
768 # server)
769 early_data_accepted = False
770 if self.ext:
771 for e in self.ext:
772 if isinstance(e, TLS_Ext_EarlyDataIndication):
773 early_data_accepted = True
774
775 # If the serveur did not accept early_data, we change prcs traffic
776 # encryption keys. Otherwise, the the keys will be updated after the
777 # EndOfEarlyData message
778 if connection_end == "server":
779 if not early_data_accepted:
780 s.prcs = readConnState(ciphersuite=type(s.wcs.ciphersuite),
781 connection_end=connection_end,
782 tls_version=s.tls_version)
783
784 chts = s.tls13_derived_secrets["client_handshake_traffic_secret"] # noqa: E501
785 s.prcs.tls13_derive_keys(chts)
786
787 if not s.middlebox_compatibility:
788 s.rcs = self.tls_session.prcs
789 s.triggered_prcs_commit = False
790 else:
791 s.triggered_prcs_commit = True
792
793 def post_dissection_tls_session_update(self, msg_str):
794 self.tls_session_update(msg_str)
795 s = self.tls_session
796 connection_end = s.connection_end
797
798 # Check if the server early_data extension is present in
799 # EncryptedExtensions message (if so, early data was accepted by the
800 # server)
801 early_data_accepted = False
802 if self.ext:
803 for e in self.ext:
804 if isinstance(e, TLS_Ext_EarlyDataIndication):
805 early_data_accepted = True
806
807 # If the serveur did not accept early_data, we change pwcs traffic
808 # encryption key. Otherwise, the the keys will be updated after the
809 # EndOfEarlyData message

Calls 4

ByteEnumFieldClass · 0.90
ThreeBytesFieldClass · 0.90
_ExtensionsLenFieldClass · 0.90
_ExtensionsFieldClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…