tlslite.handshakesettings module

Class for setting handshake parameters.

class tlslite.handshakesettings.HandshakeSettings

Bases: object

This class encapsulates various parameters that can be used with a TLS handshake.

Variables:
  • minKeySize (int) –

    The minimum bit length for asymmetric keys.

    If the other party tries to use SRP, RSA, or Diffie-Hellman parameters smaller than this length, an alert will be signalled. The default is 1023.

  • maxKeySize (int) –

    The maximum bit length for asymmetric keys.

    If the other party tries to use SRP, RSA, or Diffie-Hellman parameters larger than this length, an alert will be signalled. The default is 8193.

  • cipherNames (list) –

    The allowed ciphers.

    The allowed values in this list are ‘chacha20-poly1305’, ‘aes256gcm’, ‘aes128gcm’, ‘aes256’, ‘aes128’, ‘3des’, ‘chacha20-poly1305_draft00’, ‘null’ and ‘rc4’. If these settings are used with a client handshake, they determine the order of the ciphersuites offered in the ClientHello message.

    If these settings are used with a server handshake, the server will choose whichever ciphersuite matches the earliest entry in this list.

    Note

    If ‘3des’ is used in this list, but TLS Lite can’t find an add-on library that supports 3DES, then ‘3des’ will be silently removed.

    The default value is list that excludes ‘rc4’, ‘null’ and ‘chacha20-poly1305_draft00’.

  • macNames (list) –

    The allowed MAC algorithms.

    The allowed values in this list are ‘sha384’, ‘sha256’, ‘aead’, ‘sha’ and ‘md5’.

    The default value is list that excludes ‘md5’.

  • certificateTypes (list) –

    The allowed certificate types.

    The only allowed certificate type is ‘x509’. This list is only used with a client handshake. The client will advertise to the server which certificate types are supported, and will check that the server uses one of the appropriate types.

  • minVersion (tuple) –

    The minimum allowed SSL/TLS version.

    This variable can be set to (3, 0) for SSL 3.0, (3, 1) for TLS 1.0, (3, 2) for TLS 1.1, or (3, 3) for TLS 1.2. If the other party wishes to use a lower version, a protocol_version alert will be signalled. The default is (3, 1).

  • maxVersion (tuple) –

    The maximum allowed SSL/TLS version.

    This variable can be set to (3, 0) for SSL 3.0, (3, 1) for TLS 1.0, (3, 2) for TLS 1.1, or (3, 3) for TLS 1.2. If the other party wishes to use a higher version, a protocol_version alert will be signalled. The default is (3, 3).

    Warning

    Some servers may (improperly) reject clients which offer support for TLS 1.1 or higher. In this case, try lowering maxVersion to (3, 1).

  • useExperimentalTackExtension (bool) –

    Whether to enabled TACK support.

    Note that TACK support is not standardized by IETF and uses a temporary TLS Extension number, so should NOT be used in production software.

  • sendFallbackSCSV (bool) – Whether to, as a client, send FALLBACK_SCSV.
  • rsaSigHashes (list) –

    List of hashes supported (and advertised as such) for TLS 1.2 signatures over Server Key Exchange or Certificate Verify with RSA signature algorithm.

    The list is sorted from most wanted to least wanted algorithm.

    The allowed hashes are: “md5”, “sha1”, “sha224”, “sha256”, “sha384” and “sha512”. The default list does not include md5.

  • eccCurves (list) – List of named curves that are to be supported
  • useEncryptThenMAC (bool) – whether to support the encrypt then MAC extension from RFC 7366. True by default.
  • useExtendedMasterSecret (bool) – whether to support the extended master secret calculation from RFC 7627. True by default.
  • requireExtendedMasterSecret (bool) – whether to require negotiation of extended master secret calculation for successful connection. Requires useExtendedMasterSecret to be set to true. False by default.
  • defaultCurve (str) – curve that will be used by server in case the client did not advertise support for any curves. It does not have to be the first curve for eccCurves and may be distinct from curves from that list.
__init__()

Initialize self. See help(type(self)) for accurate signature.

getCertificateTypes()

Get list of certificate types as IDs

validate()

Validate the settings, filter out unsupported ciphersuites and return a copy of object. Does not modify the original object.

Return type:HandshakeSettings
Returns:a self-consistent copy of settings
Raises:ValueError – when settings are invalid, insecure or unsupported.