scapy.layers.tls.handshake
TLS handshake fields & logic.
This module covers the handshake TLS subprotocol, except for the key exchange mechanisms which are addressed with keyexchange.py.
- class scapy.layers.tls.handshake.SupDataEntry(_pkt, /, *, sdtype=None, len=None, data=b'')[source]
Bases:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SDTYPE | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. SupDataEntry
sdtype
None
len
None
data
b''
- class scapy.layers.tls.handshake.SupDataEntryUM(_pkt, /, *, sdtype=None, len=None, dlen=None, data=[])[source]
Bases:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SDTYPE | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DLEN | DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. SupDataEntryUM
sdtype
None
len
None
dlen
None
data
[]
- class scapy.layers.tls.handshake.TLS13Certificate(_pkt, /, *, msgtype=11, msglen=None, cert_req_ctxt_len=None, cert_req_ctxt=b'', certslen=None, certs=[])[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |CERT REQ CTXT L| CERT REQ CTXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CERTSLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CERTS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13Certificate
msgtype
11
msglen
None
cert_req_ctxt_len
None
cert_req_ctxt
b''
certslen
_ASN1CertLenField
None
certs
_ASN1CertAndExtListField
[]
- class scapy.layers.tls.handshake.TLS13CertificateRequest(_pkt, /, *, msgtype=13, msglen=None, cert_req_ctxt_len=None, cert_req_ctxt=b'', extlen=None, ext=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |CERT REQ CTXT L| CERT REQ CTXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXTLEN | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13CertificateRequest
msgtype
13
msglen
None
cert_req_ctxt_len
None
cert_req_ctxt
b''
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLS13ClientHello(_pkt, /, *, msgtype=1, msglen=None, version=None, random_bytes=None, sidlen=None, sid=b'', cipherslen=None, ciphers=None, complen=None, comp=[0], extlen=None, ext=None)[source]
Bases:
_TLSHandshake
TLS 1.3 ClientHello, with abilities to handle extensions.
The Random structure is 32 random bytes without any GMT time
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VERSION | RANDOM BYTES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + + | | + +-+-+-+-+-+-+-+-+ | | SIDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SID | CIPHERSLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CIPHERS | COMPLEN | COMP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | EXTLEN | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLS13ClientHello
msgtype
1
msglen
None
version
_TLSClientVersionField
None
random_bytes
_TLSRandomBytesField
None
sidlen
None
sid
_SessionIDField
b''
cipherslen
None
ciphers
_CipherSuitesField
None
complen
None
comp
_CompressionMethodsField
[0]
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLS13EndOfEarlyData(_pkt, /, *, msgtype=5, msglen=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLS13EndOfEarlyData
msgtype
5
msglen
None
- class scapy.layers.tls.handshake.TLS13HelloRetryRequest(_pkt, /, *, msgtype=2, msglen=None, version=771, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VERSION | RANDOM BYTES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + + | | + +-+-+-+-+-+-+-+-+ | | SIDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SID | CIPHER | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COMP | EXTLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13HelloRetryRequest
msgtype
2
msglen
None
version
_TLSVersionField
771
random_bytes
_TLSRandomBytesField
None
sidlen
None
sid
_SessionIDField
b''
cipher
None
comp
_CompressionMethodsField
[0]
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLS13KeyUpdate(_pkt, /, *, msgtype=24, msglen=None, request_update=0)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | REQUEST UPDATE| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13KeyUpdate
msgtype
24
msglen
None
request_update
0
- class scapy.layers.tls.handshake.TLS13NewSessionTicket(_pkt, /, *, msgtype=4, msglen=None, ticket_lifetime=4294967295, ticket_age_add=0, noncelen=None, ticket_nonce=b'', ticketlen=None, ticket=b'', extlen=None, ext=None)[source]
Bases:
_TLSHandshake
Uncomment the TicketField line for parsing a RFC 5077 ticket.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | TICKET LIFETIME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | TICKET AGE ADD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | NONCELEN | TICKET NONCE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TICKETLEN | TICKET | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXTLEN | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13NewSessionTicket
msgtype
4
msglen
None
ticket_lifetime
4294967295
ticket_age_add
0
noncelen
None
ticket_nonce
b''
ticketlen
None
ticket
b''
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLS13ServerHello(_pkt, /, *, msgtype=2, msglen=None, version=771, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[source]
Bases:
TLSServerHello
TLS 1.3 ServerHello
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VERSION | RANDOM BYTES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + + | | + +-+-+-+-+-+-+-+-+ | | SIDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SID | CIPHER | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COMP | EXTLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLS13ServerHello
msgtype
2
msglen
None
version
_TLSVersionField
771
random_bytes
_TLSRandomBytesField
None
sidlen
None
sid
_SessionIDField
b''
cipher
None
comp
_CompressionMethodsField
[0]
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLSCertificate(_pkt, /, *, msgtype=11, msglen=None, certslen=None, certs=[])[source]
Bases:
_TLSHandshake
XXX We do not support RFC 5081, i.e. OpenPGP certificates.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | CERTSLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | CERTS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSCertificate
msgtype
11
msglen
None
certslen
_ASN1CertLenField
None
certs
_ASN1CertListField
[]
- class scapy.layers.tls.handshake.TLSCertificateRequest(_pkt, /, *, msgtype=13, msglen=None, ctypeslen=None, ctypes=[1, 64], sig_algs_len=None, sig_algs=[1027, 1025, 513], certauthlen=None, certauth=[])[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | CTYPESLEN | CTYPES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SIG ALGS LEN | SIG ALGS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CERTAUTHLEN | CERTAUTH | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSCertificateRequest
msgtype
13
msglen
None
ctypeslen
None
ctypes
_CertTypesField
[1, 64]
sig_algs_len
None
sig_algs
[1027, 1025, 513]
certauthlen
None
certauth
_CertAuthoritiesField
[]
- class scapy.layers.tls.handshake.TLSCertificateStatus(_pkt, /, *, msgtype=22, msglen=None, status_type=1, responselen=None, response=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | STATUS TYPE | RESPONSELEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RESPONSE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSCertificateStatus
msgtype
22
msglen
None
status_type
1
responselen
None
response
_StatusField
None
- class scapy.layers.tls.handshake.TLSCertificateURL(_pkt, /, *, msgtype=21, msglen=None, certchaintype=None, uahlen=None, uah=[])[source]
Bases:
_TLSHandshake
Defined in RFC 4366. PkiPath structure of section 8 is not implemented yet.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | CERTCHAINTYPE | UAHLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | UAH | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSCertificateURL
msgtype
21
msglen
None
certchaintype
None
uahlen
None
uah
[]
- class scapy.layers.tls.handshake.TLSCertificateVerify(_pkt, /, *, msgtype=15, msglen=None, sig=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | SIG | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSCertificateVerify
msgtype
15
msglen
None
sig
_TLSSignatureField
None
- class scapy.layers.tls.handshake.TLSClientHello(_pkt, /, *, msgtype=1, msglen=None, version=None, gmt_unix_time=None, random_bytes=None, sidlen=None, sid=b'', cipherslen=None, ciphers=None, complen=None, comp=[0], extlen=None, ext=None)[source]
Bases:
_TLSHandshake
TLS ClientHello, with abilities to handle extensions.
The Random structure follows the RFC 5246: while it is 32-byte long, many implementations use the first 4 bytes as a gmt_unix_time, and then the remaining 28 byts should be completely random. This was designed in order to (sort of) mitigate broken RNGs. If you prefer to show the full 32 random bytes without any GMT time, just comment in/out the lines below.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VERSION | GMT UNIX TIME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RANDOM BYTES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + +-+-+-+-+-+-+-+-+ | | SIDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SID | CIPHERSLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CIPHERS | COMPLEN | COMP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | EXTLEN | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSClientHello
msgtype
1
msglen
None
version
_TLSClientVersionField
None
gmt_unix_time
_GMTUnixTimeField
None
random_bytes
_TLSRandomBytesField
None
sidlen
None
sid
_SessionIDField
b''
cipherslen
None
ciphers
_CipherSuitesField
None
complen
None
comp
_CompressionMethodsField
[0]
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLSClientKeyExchange(_pkt, /, *, msgtype=16, msglen=None, exchkeys=None)[source]
Bases:
_TLSHandshake
This class mostly works like TLSServerKeyExchange and its ‘params’ field.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | EXCHKEYS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSClientKeyExchange
msgtype
16
msglen
None
exchkeys
_TLSCKExchKeysField
None
- class scapy.layers.tls.handshake.TLSEncryptedExtensions(_pkt, /, *, msgtype=8, msglen=None, extlen=None, ext=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | EXTLEN | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSEncryptedExtensions
msgtype
8
msglen
None
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- class scapy.layers.tls.handshake.TLSFinished(_pkt, /, *, msgtype=20, msglen=None, vdata=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VDATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSFinished
msgtype
20
msglen
None
vdata
_VerifyDataField
None
- class scapy.layers.tls.handshake.TLSHelloRequest(_pkt, /, *, msgtype=0, msglen=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSHelloRequest
msgtype
0
msglen
None
- class scapy.layers.tls.handshake.TLSHelloVerifyRequest(_pkt, /, *, msgtype=21, msglen=None, cookielen=None, cookie=b'')[source]
Bases:
_TLSHandshake
Defined for DTLS, see RFC 6347.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | COOKIELEN | COOKIE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSHelloVerifyRequest
msgtype
21
msglen
None
cookielen
None
cookie
b''
- class scapy.layers.tls.handshake.TLSNewSessionTicket(_pkt, /, *, msgtype=4, msglen=None, lifetime=4294967295, ticketlen=None, ticket=b'')[source]
Bases:
_TLSHandshake
XXX When knowing the right secret, we should be able to read the ticket.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | LIFETIME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | TICKETLEN | TICKET | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSNewSessionTicket
msgtype
4
msglen
None
lifetime
4294967295
ticketlen
None
ticket
b''
- class scapy.layers.tls.handshake.TLSServerHello(_pkt, /, *, msgtype=2, msglen=None, version=None, gmt_unix_time=None, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[source]
Bases:
_TLSHandshake
TLS ServerHello, with abilities to handle extensions.
The Random structure follows the RFC 5246: while it is 32-byte long, many implementations use the first 4 bytes as a gmt_unix_time, and then the remaining 28 byts should be completely random. This was designed in order to (sort of) mitigate broken RNGs. If you prefer to show the full 32 random bytes without any GMT time, just comment in/out the lines below.
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | VERSION | GMT UNIX TIME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RANDOM BYTES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + +-+-+-+-+-+-+-+-+ | | SIDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SID | CIPHER | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COMP | EXTLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSServerHello
msgtype
2
msglen
None
version
_TLSVersionField
None
gmt_unix_time
_GMTUnixTimeField
None
random_bytes
_TLSRandomBytesField
None
sidlen
None
sid
_SessionIDField
b''
cipher
None
comp
_CompressionMethodsField
[0]
extlen
_ExtensionsLenField
None
ext
_ExtensionsField
None
- tls_session_update(msg_str)[source]
Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate the pending write and read connection states. Usually they get updated later on in the negotiation when we learn the session keys, and eventually they are committed once a ChangeCipherSpec has been sent/received.
- class scapy.layers.tls.handshake.TLSServerHelloDone(_pkt, /, *, msgtype=14, msglen=None)[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSServerHelloDone
msgtype
14
msglen
None
- class scapy.layers.tls.handshake.TLSServerKeyExchange(_pkt, /, *, msgtype=12, msglen=None, params=None, sig=None)[source]
Bases:
_TLSHandshake
- aliastypes
- build(*args, **kargs)[source]
We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet.
The ‘params’ field is built according to key_exchange.server_kx_msg_cls which should have been set after receiving a cipher suite in a previous ServerHello. Usual cases are:
None: for RSA encryption or fixed FF/ECDH. This should never happen, as no ServerKeyExchange should be generated in the first place.
ServerDHParams: for ephemeral FFDH. In that case, the parameter to server_kx_msg_cls does not matter.
ServerECDH*Params: for ephemeral ECDH. There are actually three classes, which are dispatched by _tls_server_ecdh_cls_guess on the first byte retrieved. The default here is b”03”, which corresponds to ServerECDHNamedCurveParams (implicit curves).
When the Server*DHParams are built via .fill_missing(), the session server_kx_privkey will be updated accordingly.
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | PARAMS | SIG | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. TLSServerKeyExchange
msgtype
12
msglen
None
params
_TLSServerParamsField
None
sig
_TLSSignatureField
None
- class scapy.layers.tls.handshake.TLSSupplementalData(_pkt, /, *, msgtype=23, msglen=None, sdatalen=None, sdata=[])[source]
Bases:
_TLSHandshake
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MSGTYPE | MSGLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | SDATALEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | SDATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TLSSupplementalData
msgtype
23
msglen
None
sdatalen
None
sdata
[]
- class scapy.layers.tls.handshake.ThreeBytesLenField(name, default, length_of=None, adjust=<function ThreeBytesLenField.<lambda>>)[source]
Bases:
FieldLenField
- class scapy.layers.tls.handshake.URLAndOptionalHash(_pkt, /, *, urllen=None, url=b'', hash_present=None, hash=b'')[source]
Bases:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | URLLEN | URL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HASH PRESENT | HASH | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. URLAndOptionalHash
urllen
None
url
b''
hash_present
None
hash
b''
- class scapy.layers.tls.handshake.UserMappingData(_pkt, /, *, version=None, len=None, data=b'')[source]
Bases:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VERSION | LEN | DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. UserMappingData
version
None
len
None
data
b''