TLS 1.3 ClientHello, with abilities to handle extensions. The Random structure is 32 random bytes without any GMT time
| 350 | |
| 351 | |
| 352 | class TLS13ClientHello(_TLSHandshake): |
| 353 | """ |
| 354 | TLS 1.3 ClientHello, with abilities to handle extensions. |
| 355 | |
| 356 | The Random structure is 32 random bytes without any GMT time |
| 357 | """ |
| 358 | name = "TLS 1.3 Handshake - Client Hello" |
| 359 | fields_desc = [ByteEnumField("msgtype", 1, _tls_handshake_type), |
| 360 | ThreeBytesField("msglen", None), |
| 361 | _TLSClientVersionField("version", None, _tls_version), |
| 362 | |
| 363 | _TLSRandomBytesField("random_bytes", None, 32), |
| 364 | |
| 365 | FieldLenField("sidlen", None, fmt="B", length_of="sid"), |
| 366 | _SessionIDField("sid", "", |
| 367 | length_from=lambda pkt: pkt.sidlen), |
| 368 | |
| 369 | FieldLenField("cipherslen", None, fmt="!H", |
| 370 | length_of="ciphers"), |
| 371 | _CipherSuitesField("ciphers", None, |
| 372 | _tls_cipher_suites, itemfmt="!H", |
| 373 | length_from=lambda pkt: pkt.cipherslen), |
| 374 | |
| 375 | FieldLenField("complen", None, fmt="B", length_of="comp"), |
| 376 | _CompressionMethodsField("comp", [0], |
| 377 | _tls_compression_algs, |
| 378 | itemfmt="B", |
| 379 | length_from=lambda pkt: pkt.complen), # noqa: E501 |
| 380 | |
| 381 | _ExtensionsLenField("extlen", None, length_of="ext"), |
| 382 | _ExtensionsField("ext", None, |
| 383 | length_from=lambda pkt: (pkt.msglen - |
| 384 | (pkt.sidlen or 0) - # noqa: E501 |
| 385 | (pkt.cipherslen or 0) - # noqa: E501 |
| 386 | (pkt.complen or 0) - # noqa: E501 |
| 387 | 40))] |
| 388 | |
| 389 | def post_build(self, p, pay): |
| 390 | if self.random_bytes is None: |
| 391 | p = p[:6] + randstring(32) + p[6 + 32:] |
| 392 | # We don't call the post_build function from class _TLSHandshake |
| 393 | # to compute the message length because we need that value now |
| 394 | # for the HMAC in binder |
| 395 | tmp_len = len(p) |
| 396 | if self.msglen is None: |
| 397 | sz = tmp_len - 4 |
| 398 | p = struct.pack("!I", (orb(p[0]) << 24) | sz) + p[4:] |
| 399 | s = self.tls_session |
| 400 | if self.ext: |
| 401 | for e in self.ext: |
| 402 | if isinstance(e, TLS_Ext_PreSharedKey_CH): |
| 403 | if s.client_session_ticket: |
| 404 | # For a resumed PSK, the hash function use |
| 405 | # to compute the binder must be the same |
| 406 | # as the one used to establish the original |
| 407 | # connection. For that, we assume that |
| 408 | # the ciphersuite associate with the ticket |
| 409 | # is given as argument to tlsSession |
no test coverage detected
searching dependent graphs…