tlslite.TLSRecordLayer.TLSRecordLayer

Package tlslite :: Module TLSRecordLayer :: Class TLSRecordLayer |
[show private | hide private]
[frames | no frames]

## Class TLSRecordLayer

Known Subclasses:
  `TLSConnection`

This class handles data transmission for a TLS connection.

Its only subclass is `tlslite.TLSConnection.TLSConnection`. We've separated the code in this class from TLSConnection to make things more readable.

Method Summary
| `__init__(self, sock)`
str | ``read`(self, max, min)` Read some data from the TLS connection.
iterable | ``readAsync`(self, max, min)` Start a read operation on the TLS connection.
| ``write`(self, s)` Write some data to the TLS connection.
iterable | ``writeAsync`(self, s)` Start a write operation on the TLS connection.
| ``close`(self)` Close the TLS connection.
iterable | ``closeAsync`(self)` Start a close operation on the TLS connection.
str | ``getCipherImplementation`(self)` Get the name of the cipher implementation used with this connection.
str | ``getCipherName`(self)` Get the name of the cipher used with this connection.
| ``getpeername`(self)` Return the remote address to which the socket is connected (socket emulation).
| ``getsockname`(self)` Return the socket's own address (socket emulation).
| ``gettimeout`(self)` Return the timeout associated with socket operations (socket emulation).
`tlslite.FileObject.FileObject` | ``makefile`(self, mode, bufsize)` Create a file object for the TLS connection (socket emulation).
| ``recv`(self, bufsize)` Get some data from the TLS connection (socket emulation).
| ``send`(self, s)` Send data to the TLS connection (socket emulation).
| ``sendall`(self, s)` Send data to the TLS connection (socket emulation).
| ``setsockopt`(self, level, optname, value)` Set the value of the given socket option (socket emulation).
| ``settimeout`(self, value)` Set a timeout on blocking socket operations (socket emulation).
| `_calcFinished(self, send)`
| `_calcPendingStates(self, clientRandom, serverRandom, implementations)`
| `_calcSSLHandshakeHash(self, masterSecret, label)`
| `_changeReadState(self)`
| `_changeWriteState(self)`
| `_decrefAsync(self)`
| `_decryptRecord(self, recordType, bytes)`
| `_getFinished(self)`
| `_getMsg(self, expectedType, secondaryType, constructorType)`
| `_getNextRecord(self)`
| `_handshakeDone(self, resumed)`
| `_handshakeStart(self, client)`
| `_sendError(self, alertDescription, errorStr)`
| `_sendFinished(self)`
| `_sendMsg(self, msg, skipEmptyFrag)`
| `_sendMsgs(self, msgs)`
| `_shutdown(self, resumable)`

Instance Variable Summary
str or None | `allegedSharedKeyUsername`: This is set to the shared-key username asserted by the client, whether the handshake succeeded or not.
str or None | `allegedSrpUsername`: This is set to the SRP username asserted by the client, whether the handshake succeeded or not.
bool | `closed`: If this connection is closed.
bool | `closeSocket`: If the socket should be closed when the connection is closed (writable).
bool | `ignoreAbruptClose`: If an abrupt close of the socket should raise an error (writable).
bool | `resumed`: If this connection is based on a resumed session.
`tlslite.Session.Session` | `session`: The session corresponding to this connection.
socket.socket | `sock`: The underlying socket object.
tuple | `version`: The TLS version being used for this connection.

Method Details

### read(self, max=None, min=1) Read some data from the TLS connection. This function will block until at least 'min' bytes are available (or the connection is closed). If an exception is raised, the connection will have been automatically closed. Parameters: `max` - The maximum number of bytes to return. (type=int) `min` - The minimum number of bytes to return (type=int) Returns: A string of no more than 'max' bytes, and no fewer than 'min' (unless the connection has been closed, in which case fewer than 'min' bytes may be returned). (type=str) Raises: `socket.error` - If a socket error occurs. `tlslite.errors.TLSAbruptCloseError` - If the socket is closed without a preceding alert. `tlslite.errors.TLSAlert` - If a TLS alert is signalled.

### readAsync(self, max=None, min=1) Start a read operation on the TLS connection. This function returns a generator which behaves similarly to read(). Successive invocations of the generator will return 0 if it is waiting to read from the socket, 1 if it is waiting to write to the socket, or a string if the read operation has completed. Returns: A generator; see above for details. (type=iterable)

### write(self, s) Write some data to the TLS connection. This function will block until all the data has been sent. If an exception is raised, the connection will have been automatically closed. Parameters: `s` - The data to transmit to the other party. (type=str) Raises: `socket.error` - If a socket error occurs.

### writeAsync(self, s) Start a write operation on the TLS connection. This function returns a generator which behaves similarly to write(). Successive invocations of the generator will return 1 if it is waiting to write to the socket, or will raise StopIteration if the write operation has completed. Returns: A generator; see above for details. (type=iterable)

### close(self) Close the TLS connection. This function will block until it has exchanged close_notify alerts with the other party. After doing so, it will shut down the TLS connection. Further attempts to read through this connection will return "". Further attempts to write through this connection will raise ValueError. If makefile() has been called on this connection, the connection will be not be closed until the connection object and all file objects have been closed. Even if an exception is raised, the connection will have been closed. Raises: `socket.error` - If a socket error occurs. `tlslite.errors.TLSAbruptCloseError` - If the socket is closed without a preceding alert. `tlslite.errors.TLSAlert` - If a TLS alert is signalled.

### closeAsync(self) Start a close operation on the TLS connection. This function returns a generator which behaves similarly to close(). Successive invocations of the generator will return 0 if it is waiting to read from the socket, 1 if it is waiting to write to the socket, or will raise StopIteration if the close operation has completed. Returns: A generator; see above for details. (type=iterable)

### getCipherImplementation(self) Get the name of the cipher implementation used with this connection. Returns: The name of the cipher implementation used with this connection. Either 'python', 'cryptlib', 'openssl', or 'pycrypto'. (type=str)

### getCipherName(self) Get the name of the cipher used with this connection. Returns: The name of the cipher used with this connection. Either 'aes128', 'aes256', 'rc4', or '3des'. (type=str)

### getpeername(self) Return the remote address to which the socket is connected (socket emulation).

### getsockname(self) Return the socket's own address (socket emulation).

### gettimeout(self) Return the timeout associated with socket operations (socket emulation).

### makefile(self, mode='r', bufsize=-1) Create a file object for the TLS connection (socket emulation). Returns: `tlslite.FileObject.FileObject`

### recv(self, bufsize) Get some data from the TLS connection (socket emulation). Raises: `socket.error` - If a socket error occurs. `tlslite.errors.TLSAbruptCloseError` - If the socket is closed without a preceding alert. `tlslite.errors.TLSAlert` - If a TLS alert is signalled.

### send(self, s) Send data to the TLS connection (socket emulation). Raises: `socket.error` - If a socket error occurs.

### sendall(self, s) Send data to the TLS connection (socket emulation). Raises: `socket.error` - If a socket error occurs.

### setsockopt(self, level, optname, value) Set the value of the given socket option (socket emulation).

### settimeout(self, value) Set a timeout on blocking socket operations (socket emulation).

Instance Variable Details

### allegedSharedKeyUsername This is set to the shared-key username asserted by the client, whether the handshake succeeded or not. If the handshake fails, this can be inspected to determine if a guessing attack is in progress against a particular user account. Type: str or None

### allegedSrpUsername This is set to the SRP username asserted by the client, whether the handshake succeeded or not. If the handshake fails, this can be inspected to determine if a guessing attack is in progress against a particular user account. Type: str or None

### closed If this connection is closed. Type: bool

### closeSocket If the socket should be closed when the connection is closed (writable). If you set this to True, TLS Lite will assume the responsibility of closing the socket when the TLS Connection is shutdown (either through an error or through the user calling close()). The default is False. Type: bool

### ignoreAbruptClose If an abrupt close of the socket should raise an error (writable). If you set this to True, TLS Lite will not raise a `tlslite.errors.TLSAbruptCloseError` exception if the underlying socket is unexpectedly closed. Such an unexpected closure could be caused by an attacker. However, it also occurs with some incorrect TLS implementations. You should set this to True only if you're not worried about an attacker truncating the connection, and only if necessary to avoid spurious errors. The default is False. Type: bool

### resumed If this connection is based on a resumed session. Type: bool

### session The session corresponding to this connection. Due to TLS session resumption, multiple connections can correspond to the same underlying session. Type: `tlslite.Session.Session`

### sock The underlying socket object. Type: socket.socket

### version The TLS version being used for this connection. (3,0) means SSL 3.0, and (3,1) means TLS 1.0. Type: tuple

Generated by Epydoc 2.0 on Mon Feb 21 21:56:55 2005 | http://epydoc.sf.net