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

Class tlsSession

scapy/layers/tls/session.py:347–1008  ·  view source on GitHub ↗

This is our TLS context, which gathers information from both sides of the TLS connection. These sides are represented by a readConnState instance and a writeConnState instance. Along with overarching network attributes, a tlsSession object also holds negotiated, shared information,

Source from the content-addressed store, hash-verified

345###############################################################################
346
347class tlsSession(object):
348 """
349 This is our TLS context, which gathers information from both sides of the
350 TLS connection. These sides are represented by a readConnState instance and
351 a writeConnState instance. Along with overarching network attributes, a
352 tlsSession object also holds negotiated, shared information, such as the
353 key exchange parameters and the master secret (when available).
354
355 The default connection_end is "server". This corresponds to the expected
356 behaviour for static exchange analysis (with a ClientHello parsed first).
357 """
358
359 def __init__(self,
360 ipsrc=None, ipdst=None,
361 sport=None, dport=None, sid=None,
362 connection_end="server",
363 wcs=None, rcs=None):
364
365 # Use this switch to prevent additions to the 'handshake_messages'.
366 self.frozen = False
367
368 # Network settings
369 self.ipsrc = ipsrc
370 self.ipdst = ipdst
371 self.sport = sport
372 self.dport = dport
373 self.sid = sid
374
375 # Identify duplicate sessions
376 self.firsttcp = None
377
378 # Our TCP socket. None until we send (or receive) a packet.
379 self.sock = None
380
381 # Connection states
382 self.connection_end = connection_end
383
384 if wcs is None:
385 # Instantiate wcs with dummy values.
386 self.wcs = writeConnState(connection_end=connection_end)
387 self.wcs.derive_keys()
388 else:
389 self.wcs = wcs
390
391 if rcs is None:
392 # Instantiate rcs with dummy values.
393 self.rcs = readConnState(connection_end=connection_end)
394 self.rcs.derive_keys()
395 else:
396 self.rcs = rcs
397
398 # The pending write/read states are updated by the building/parsing
399 # of various TLS packets. They get committed to self.wcs/self.rcs
400 # once Scapy builds/parses a ChangeCipherSpec message, or for certain
401 # other messages in case of TLS 1.3.
402 self.pwcs = None
403 self.triggered_pwcs_commit = False
404 self.prcs = None

Callers 4

INIT_TLS_SESSIONMethod · 0.90
INIT_TLS_SESSIONMethod · 0.90
__init__Method · 0.85
tcp_reassembleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…