Skip to content

Commit 69d5c85

Browse files
committed
tls: Remove Python TLSWrappedBuffer
The pure-Python implementation of TLSWrappedBuffer now only forwards everything to MbedTLSBuffer. It is therefore not useful anymore and we keep MbedTLSBuffer only.
1 parent ffe092d commit 69d5c85

File tree

2 files changed

+6
-77
lines changed

2 files changed

+6
-77
lines changed

src/mbedtls/_tls.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,9 @@ cdef class MbedTLSBuffer:
11721172
# We could make this pickable by copying the buffers.
11731173
raise TypeError(f"cannot pickle {self.__class__.__name__!r} object")
11741174

1175+
def __repr__(self):
1176+
return "%s(%r)" % (type(self).__name__, self.context)
1177+
11751178
@property
11761179
def context(self):
11771180
return self._context

src/mbedtls/tls.py

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
DTLSVersion,
1515
HandshakeStep,
1616
HelloVerifyRequest,
17-
MbedTLSBuffer,
17+
)
18+
from ._tls import MbedTLSBuffer as TLSWrappedBuffer
19+
from ._tls import (
1820
NextProtocol,
1921
Purpose,
2022
RaggedEOF,
@@ -162,82 +164,6 @@ def wrap_buffers(self):
162164
return TLSWrappedBuffer(self)
163165

164166

165-
class TLSWrappedBuffer:
166-
# _pep543.TLSWrappedBuffer
167-
def __init__(self, context, server_hostname=None):
168-
self._tlsbuf = MbedTLSBuffer(context, server_hostname)
169-
170-
def __repr__(self):
171-
return "%s(%r)" % (type(self).__name__, self.context)
172-
173-
def __getstate__(self):
174-
raise TypeError(f"cannot pickle {self.__class__.__name__!r} object")
175-
176-
@property
177-
def _server_hostname(self):
178-
return self._tlsbuf._server_hostname
179-
180-
@property
181-
def _handshake_state(self):
182-
return self._tlsbuf._handshake_state
183-
184-
def read(self, amt):
185-
# PEP 543
186-
return self._tlsbuf.read(amt)
187-
188-
def readinto(self, buffer, amt):
189-
# PEP 543
190-
return self._tlsbuf.readinto(buffer, amt)
191-
192-
def write(self, buffer):
193-
# PEP 543
194-
return self._tlsbuf.write(buffer)
195-
196-
def do_handshake(self):
197-
# PEP 543
198-
self._tlsbuf.do_handshake()
199-
200-
def setcookieparam(self, param):
201-
self._tlsbuf.setcookieparam(param)
202-
203-
def cipher(self):
204-
# PEP 543
205-
return self._tlsbuf.cipher()
206-
207-
def negotiated_protocol(self):
208-
# PEP 543
209-
return self._tlsbuf.negotiated_protocol()
210-
211-
@property
212-
def context(self):
213-
# PEP 543
214-
"""The ``Context`` object this buffer is tied to."""
215-
return self._tlsbuf.context
216-
217-
def negotiated_tls_version(self):
218-
# PEP 543
219-
return self._tlsbuf.negotiated_tls_version()
220-
221-
def shutdown(self):
222-
# PEP 543
223-
self._tlsbuf.shutdown()
224-
225-
def receive_from_network(self, data):
226-
# PEP 543
227-
# Append data to input buffer.
228-
self._tlsbuf.receive_from_network(data)
229-
230-
def peek_outgoing(self, amt):
231-
# PEP 543
232-
# Read from output buffer.
233-
return self._tlsbuf.peek_outgoing(amt)
234-
235-
def consume_outgoing(self, amt):
236-
"""Consume `amt` bytes from the output buffer."""
237-
# PEP 543
238-
self._tlsbuf.consume_outgoing(amt)
239-
240-
241167
class TLSWrappedSocket:
242168
# _pep543.TLSWrappedSocket
243169
def __init__(self, socket, buffer):

0 commit comments

Comments
 (0)