scapy.layers.tls.keyexchange
TLS key exchange logic.
- class scapy.layers.tls.keyexchange.ClientDiffieHellmanPublic(_pkt, /, *, dh_Yclen=None, dh_Yc=b'')[源代码]
基类:
_GenericTLSSessionInheritanceIf the user provides a value for dh_Yc attribute, we assume he will set the pms and ms accordingly and trigger the key derivation on his own.
XXX As specified in 7.4.7.2. of RFC 4346, we should distinguish the needs for implicit or explicit value depending on availability of DH parameters in client certificate. For now we can only do ephemeral/explicit DH.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH YCLEN | DH YC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ClientDiffieHellmanPublicClientDiffieHellmanPublic fields dh_Yclen
Nonedh_Yc
b''
- class scapy.layers.tls.keyexchange.ClientECDiffieHellmanPublic(_pkt, /, *, ecdh_Yclen=None, ecdh_Yc=b'')[源代码]
基类:
_GenericTLSSessionInheritanceNote that the 'len' field is 1 byte longer than with the previous class.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ECDH YCLEN | ECDH YC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ClientECDiffieHellmanPublicClientECDiffieHellmanPublic fields ecdh_Yclen
Noneecdh_Yc
b''
- class scapy.layers.tls.keyexchange.ClientPSKIdentity(_pkt, /, *, psk_identity_len=None, psk_identity=b'')[源代码]
基类:
PacketXXX We provide parsing abilities for ServerPSKParams, but the context operations have not been implemented yet. See RFC 4279. Note that we do not cover the (EC)DHE_PSK nor the RSA_PSK key exchange, which should contain either an EncryptedPMS or a ClientDiffieHellmanPublic.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PSK IDENTITY LEN | PSK IDENTITY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ClientPSKIdentityClientPSKIdentity fields psk_identity_len
Nonepsk_identity
b''
- class scapy.layers.tls.keyexchange.ECCurvePkt(_pkt, /, *, alen=None, a=b'', blen=None, b=b'')[源代码]
基类:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ALEN | A | BLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | B | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ECCurvePktECCurvePkt fields alen
Nonea
b''blen
Noneb
b''
- class scapy.layers.tls.keyexchange.ECPentanomialBasis(_pkt, /, *, k1len=None, k1=b'', k2len=None, k2=b'', k3len=None, k3=b'')[源代码]
基类:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | K1LEN | K1 | K2LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | K2 | K3LEN | K3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. ECPentanomialBasisECPentanomialBasis fields k1len
Nonek1
b''k2len
Nonek2
b''k3len
Nonek3
b''
- val = 1
- class scapy.layers.tls.keyexchange.ECTrinomialBasis(_pkt, /, *, klen=None, k=b'')[源代码]
基类:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KLEN | K | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ECTrinomialBasisECTrinomialBasis fields klen
Nonek
b''
- val = 0
- class scapy.layers.tls.keyexchange.EncryptedPreMasterSecret(_pkt, /, *, client_version=None, random=None)[源代码]
基类:
_GenericTLSSessionInheritancePay attention to implementation notes in section 7.4.7.1 of RFC 5246.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CLIENT VERSION | RANDOM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EncryptedPreMasterSecretEncryptedPreMasterSecret fields client_version
_TLSClientVersionFieldNonerandom
None
- post_build(pkt, pay)[源代码]
We encrypt the premaster secret (the 48 bytes) with either the server certificate or the temporary RSA key provided in a server key exchange message. After that step, we add the 2 bytes to provide the length, as described in implementation notes at the end of section 7.4.7.1.
- class scapy.layers.tls.keyexchange.ServerDHParams(_pkt, /, *, dh_plen=None, dh_p=b'', dh_glen=None, dh_g=b'', dh_Yslen=None, dh_Ys=b'')[源代码]
基类:
_GenericTLSSessionInheritanceServerDHParams for FFDH-based key exchanges, as defined in RFC 5246/7.4.3.
Either with .fill_missing() or .post_dissection(), the server_kx_privkey or server_kx_pubkey of the TLS context are updated according to the parsed/assembled values. It is the user's responsibility to store and restore the original values if he wants to keep them. For instance, this could be done between the writing of a ServerKeyExchange and the receiving of a ClientKeyExchange (which includes secret generation).
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH PLEN | DH P | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH GLEN | DH G | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH YSLEN | DH YS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerDHParamsServerDHParams fields dh_plen
Nonedh_p
b''dh_glen
Nonedh_g
b''dh_Yslen
Nonedh_Ys
b''
- class scapy.layers.tls.keyexchange.ServerECDHExplicitChar2Params(_pkt, /, *, curve_type=2, m=None, basis_type=None, basis=<ECTrinomialBasis |>, curve=<ECCurvePkt |>, baselen=None, base=b'', order=None, cofactor=None, pointlen=None, point=b'')[源代码]
基类:
_GenericTLSSessionInheritanceWe provide parsing abilities for Char2Params, but there is no support from the cryptography library, hence no context operations.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CURVE TYPE | M | BASIS TYPE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | BASIS | CURVE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | BASELEN | BASE | ORDER | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COFACTOR | POINTLEN | POINT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerECDHExplicitChar2ParamsServerECDHExplicitChar2Params fields curve_type
2m
Nonebasis_type
_ECBasisTypeFieldNonebasis
_ECBasisField<ECTrinomialBasis |>curve
<ECCurvePkt |>baselen
Nonebase
b''order
Nonecofactor
Nonepointlen
Nonepoint
b''
- class scapy.layers.tls.keyexchange.ServerECDHExplicitPrimeParams(_pkt, /, *, curve_type=1, plen=None, p=b'', curve=None, baselen=None, base=b'', orderlen=None, order=b'', cofactorlen=None, cofactor=b'', pointlen=None, point=b'')[源代码]
基类:
_GenericTLSSessionInheritanceWe provide parsing abilities for ExplicitPrimeParams, but there is no support from the cryptography library, hence no context operations.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CURVE TYPE | PLEN | P | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CURVE | BASELEN | BASE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | ORDERLEN | ORDER | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COFACTORLEN | COFACTOR | POINTLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | POINT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerECDHExplicitPrimeParamsServerECDHExplicitPrimeParams fields curve_type
1plen
Nonep
b''curve
Nonebaselen
Nonebase
b''orderlen
Noneorder
b''cofactorlen
Nonecofactor
b''pointlen
Nonepoint
b''
- class scapy.layers.tls.keyexchange.ServerECDHNamedCurveParams(_pkt, /, *, curve_type=3, named_curve=None, pointlen=None, point=None)[源代码]
基类:
_GenericTLSSessionInheritance- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CURVE TYPE | NAMED CURVE | POINTLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | POINT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerECDHNamedCurveParamsServerECDHNamedCurveParams fields curve_type
3named_curve
Nonepointlen
Nonepoint
None
- class scapy.layers.tls.keyexchange.ServerPSKParams(_pkt, /, *, psk_identity_hint_len=None, psk_identity_hint=b'')[源代码]
基类:
PacketXXX We provide some parsing abilities for ServerPSKParams, but the context operations have not been implemented yet. See RFC 4279. Note that we do not cover the (EC)DHE_PSK key exchange, which should contain a Server*DHParams after 'psk_identity_hint'.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PSK IDENTITY HINT LEN | PSK IDENTITY HINT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerPSKParamsServerPSKParams fields psk_identity_hint_len
Nonepsk_identity_hint
b''
- class scapy.layers.tls.keyexchange.ServerRSAParams(_pkt, /, *, rsamodlen=None, rsamod=b'', rsaexplen=None, rsaexp=b'')[源代码]
基类:
_GenericTLSSessionInheritanceDefined for RSA_EXPORT kx : it enables servers to share RSA keys shorter than their principal {>512}-bit key, when it is not allowed for kx.
This should not appear in standard RSA kx negotiation, as the key has already been advertised in the Certificate message.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | RSAMODLEN | RSAMOD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | RSAEXPLEN | RSAEXP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. ServerRSAParamsServerRSAParams fields rsamodlen
Nonersamod
b''rsaexplen
Nonersaexp
b''
- class scapy.layers.tls.keyexchange.SigAndHashAlgField(name: str, default: I | None, enum: Dict[I, str] | Dict[str, I] | List[str] | DADict[I, str] | Type[Enum] | Tuple[Callable[[I], str], Callable[[str], I]], fmt: str = 'H')[源代码]
基类:
EnumFieldUsed in _TLSSignature.
- phantom_value = None
- class scapy.layers.tls.keyexchange.SigAndHashAlgsField(name: str, default: List[AnyField] | None, field: AnyField, length_from: Callable[[Packet], int] | None = None, count_from: Callable[[Packet], int] | None = None, max_count: int | None = None)[源代码]
-
Used in TLS_Ext_SignatureAlgorithms and TLSCertificateResquest.
- phantom_value = []
- class scapy.layers.tls.keyexchange.SigAndHashAlgsLenField(name: str, default: Optional[Any], length_of: Optional[str] = None, fmt: str = 'H', count_of: Optional[str] = None, adjust: Callable[[Packet, int], int] = <function FieldLenField.<lambda>>)[源代码]
-
Used in TLS_Ext_SignatureAlgorithms and TLSCertificateResquest.
- phantom_value = 0
- class scapy.layers.tls.keyexchange.SigLenField(name: str, default: Optional[Any], length_of: Optional[str] = None, fmt: str = 'H', count_of: Optional[str] = None, adjust: Callable[[Packet, int], int] = <function FieldLenField.<lambda>>)[源代码]
-
There is a trick for SSLv2, which uses implicit lengths...
- class scapy.layers.tls.keyexchange.SigValField(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[源代码]
基类:
StrLenFieldThere is a trick for SSLv2, which uses implicit lengths...
- scapy.layers.tls.keyexchange.phantom_decorate(f, get_or_add)[源代码]
Decorator for version-dependent fields. If get_or_add is True (means get), we return s, self.phantom_value. If it is False (means add), we return s.
- scapy.layers.tls.keyexchange.phantom_mode(pkt)[源代码]
We expect this. If tls_version is not set, this means we did not process any complete ClientHello, so we're most probably reading/building a signature_algorithms extension, hence we cannot be in phantom_mode. However, if the tls_version has been set, we test for TLS 1.2.