/usr/lib/python2.7/dist-packages/tlslite/handshakehelpers.py is in python-tlslite-ng 0.7.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # Authors:
# Karel Srot
#
# See the LICENSE file for legal information regarding use of this file.
"""Class with various handshake helpers."""
from .extensions import PaddingExtension
class HandshakeHelpers(object):
"""
This class encapsulates helper functions to be used with a TLS handshake.
"""
@staticmethod
def alignClientHelloPadding(clientHello):
"""
Align ClientHello using the Padding extension to 512 bytes at least.
:param ClientHello clientHello: ClientHello to be aligned
"""
# Check clientHello size if padding extension should be added
# we want to add the extension even when using just SSLv3
# cut-off 4 bytes with the Hello header (ClientHello type + Length)
clientHelloLength = len(clientHello.write()) - 4
if 256 <= clientHelloLength <= 511:
if clientHello.extensions is None:
clientHello.extensions = []
# we need to recalculate the size after extension list addition
# results in extra 2 bytes, equals to
# clientHelloLength = len(clientHello.write()) - 4
clientHelloLength += 2
# we want to get 512 bytes in total, including the padding
# extension header (4B)
paddingExtensionInstance = PaddingExtension().create(
max(512 - clientHelloLength - 4, 0))
clientHello.extensions.append(paddingExtensionInstance)
|