1
2
3
4
5
6 """Class with various handshake helpers."""
7
8 from .extensions import PaddingExtension
12 """
13 This class encapsulates helper functions to be used with a TLS handshake.
14
15 @sort: alignUsingPaddingExtension
16 """
17
18 @staticmethod
20 """
21 Align ClientHello using the Padding extension to 512 bytes at least.
22
23 @type clientHello: ClientHello
24 @param clientHello: ClientHello to be aligned
25 """
26
27
28
29 clientHelloLength = len(clientHello.write()) - 4
30 if 256 <= clientHelloLength <= 511:
31 if clientHello.extensions is None:
32 clientHello.extensions = []
33
34
35
36 clientHelloLength += 2
37
38
39 paddingExtensionInstance = PaddingExtension().create(
40 max(512 - clientHelloLength - 4, 0))
41 clientHello.extensions.append(paddingExtensionInstance)
42