Package tlslite :: Module extensions :: Class TLSExtension
[hide private]
[frames] | no frames]

Class TLSExtension

source code


This class handles the generic information about TLS extensions used by both sides of connection in Client Hello and Server Hello messages. See RFC 4366 for more info.

It is used as a base class for specific users and as a way to store extensions that are not implemented in library.

Instance Methods [hide private]
 
__eq__(self, that)
Test if two TLS extensions will result in the same on the wire representation.
source code
 
__init__(self, server=False)
Creates a generic TLS extension that can be used either for client hello or server hello message parsing or creation.
source code
str
__repr__(self)
Output human readable representation of object
source code
TLSExtension
create(self, extType, data)
Initializes a generic TLS extension that can later be used in client hello or server hello messages
source code
TLSExtension
parse(self, p)
Parses extension from the wire format
source code
bytearray
write(self)
Returns encoded extension, as encoded on the wire
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
dict _serverExtensions = {9: <class 'tlslite.extensions.ServerCertT...
dictionary with concrete implementations of specific TLS extensions where key is the numeric value of the extension ID.
dict _universalExtensions = {0: <class 'tlslite.extensions.SNIExten...
dictionary with concrete implementations of specific TLS extensions where key is the numeric value of the extension ID.
Instance Variables [hide private]
bytearray extData
a byte array containing the value of the extension as to be written on the wire
int extType
a 2^16-1 limited integer specifying the type of the extension that it contains, e.g.
boolean serverType
indicates that the extension was parsed with ServerHello specific parser, otherwise it used universal or ClientHello specific parser
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__eq__(self, that)
(Equality operator)

source code 

Test if two TLS extensions will result in the same on the wire representation.

Will return False for every object that's not an extension.

__init__(self, server=False)
(Constructor)

source code 

Creates a generic TLS extension that can be used either for client hello or server hello message parsing or creation.

You'll need to use create or parse methods to create an extension that is actually usable.

Parameters:
  • server (boolean) - whatever to select ClientHello or ServerHello version for parsing
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

Output human readable representation of object

Returns: str
Overrides: object.__repr__

create(self, extType, data)

source code 

Initializes a generic TLS extension that can later be used in client hello or server hello messages

Parameters:
  • extType (int) - type of the extension encoded as an integer between 0 and 2^16-1
  • data (bytearray) - raw data representing extension on the wire
Returns: TLSExtension

parse(self, p)

source code 

Parses extension from the wire format

Parameters:
Returns: TLSExtension
Raises:
  • SyntaxError - when the size of the passed element doesn't match the internal representation

write(self)

source code 

Returns encoded extension, as encoded on the wire

Returns: bytearray
An array of bytes formatted as is supposed to be written on the wire, including the extension_type, length and the extension data
Raises:
  • AssertionError - when the object was not initialized

Class Variable Details [hide private]

_serverExtensions

dictionary with concrete implementations of specific TLS extensions where key is the numeric value of the extension ID. Includes only those extensions that require special handlers for ServerHello versions.
Type:
dict
Value:
{9: <class 'tlslite.extensions.ServerCertTypeExtension'>,
 62208: <class 'tlslite.extensions.TACKExtension'>}

_universalExtensions

dictionary with concrete implementations of specific TLS extensions where key is the numeric value of the extension ID. Contains ClientHello version of extensions or universal implementations
Type:
dict
Value:
{0: <class 'tlslite.extensions.SNIExtension'>,
 9: <class 'tlslite.extensions.ClientCertTypeExtension'>,
 10: <class 'tlslite.extensions.SupportedGroupsExtension'>,
 11: <class 'tlslite.extensions.ECPointFormatsExtension'>,
 12: <class 'tlslite.extensions.SRPExtension'>,
 13: <class 'tlslite.extensions.SignatureAlgorithmsExtension'>,
 13172: <class 'tlslite.extensions.NPNExtension'>}

Instance Variable Details [hide private]

extType

a 2^16-1 limited integer specifying the type of the extension that it contains, e.g. 0 indicates server name extension
Type:
int