Check if the supplied bytes contain a full ClientHello message, and if so, parse it. Returns: - A ClientHello object on success - None, if the TLS record is not complete Raises: - A ValueError, if the passed ClientHello is invalid
(data: bytes)
| 137 | |
| 138 | |
| 139 | def dtls_parse_client_hello(data: bytes) -> ClientHello | None: |
| 140 | """ |
| 141 | Check if the supplied bytes contain a full ClientHello message, |
| 142 | and if so, parse it. |
| 143 | |
| 144 | Returns: |
| 145 | - A ClientHello object on success |
| 146 | - None, if the TLS record is not complete |
| 147 | |
| 148 | Raises: |
| 149 | - A ValueError, if the passed ClientHello is invalid |
| 150 | """ |
| 151 | # Check if ClientHello is complete |
| 152 | client_hello = get_dtls_client_hello(data) |
| 153 | if client_hello: |
| 154 | try: |
| 155 | return ClientHello(client_hello[12:], dtls=True) |
| 156 | except EOFError as e: |
| 157 | raise ValueError("Invalid ClientHello") from e |
| 158 | return None |
| 159 | |
| 160 | |
| 161 | HTTP1_ALPNS = (b"http/1.1", b"http/1.0", b"http/0.9") |
no test coverage detected
searching dependent graphs…