Secure Renegotiation extension RFC 5746.
| 15 | |
| 16 | |
| 17 | class RenegotiationExtension(tlslite.extensions.TLSExtension): |
| 18 | """Secure Renegotiation extension RFC 5746.""" |
| 19 | |
| 20 | def __init__(self): |
| 21 | """Initialize secure renegotiation extension.""" |
| 22 | super(RenegotiationExtension, self).__init__( |
| 23 | extType=ExtensionType.renegotiation_info) |
| 24 | self.renegotiated_connection = None |
| 25 | |
| 26 | def create(self, data): |
| 27 | """Set the value of the Finished message.""" |
| 28 | self.renegotiated_connection = data |
| 29 | |
| 30 | @property |
| 31 | def extData(self): |
| 32 | """Serialise the extension.""" |
| 33 | if self.renegotiated_connection is None: |
| 34 | return bytearray(0) |
| 35 | |
| 36 | writer = Writer() |
| 37 | writer.addVarSeq(self.renegotiated_connection, 1, 1) |
| 38 | return writer.bytes |
| 39 | |
| 40 | def parse(self, parser): |
| 41 | """Deserialise the extension from binary data.""" |
| 42 | if parser.getRemainingLength() == 0: |
| 43 | self.renegotiated_connection = None |
| 44 | return |
| 45 | |
| 46 | self.renegotiated_connection = parser.getVarBytes(1) |
| 47 | return self |
| 48 | |
| 49 | def __repr__(self): |
| 50 | """Human readable representation of extension.""" |
| 51 | return "RenegotiationExtension(renegotiated_connection={0!r})"\ |
| 52 | .format(self.renegotiated_connection) |
| 53 | |
| 54 | def __format__(self, formatstr): |
| 55 | """Formatted representation of extension.""" |
| 56 | data = messages.format_bytearray(self.renegotiated_connection, |
| 57 | formatstr) |
| 58 | return "RenegotiationExtension(renegotiated_connection={0})"\ |
| 59 | .format(data) |
| 60 | |
| 61 | tlslite.extensions.TLSExtension._universalExtensions[ |
| 62 | ExtensionType.renegotiation_info] = RenegotiationExtension |
nothing calls this directly
no outgoing calls
no test coverage detected