|  |  | 
TLSRecordLayer
 
 
| class TLSRecordLayer
 |  |  | This class handles data transmission for a TLS connection. 
 Its only subclass is L{tlslite.TLSConnection.TLSConnection}.  We've
 separated the code in this class from TLSConnection to make things
 more readable.
 
 
 @type sock: socket.socket
 @ivar sock: The underlying socket object.
 
 @type session: L{tlslite.Session.Session}
 @ivar session: The session corresponding to this connection.
 
 Due to TLS session resumption, multiple connections can correspond
 to the same underlying session.
 
 @type version: tuple
 @ivar version: The TLS version being used for this connection.
 
 (3,0) means SSL 3.0, and (3,1) means TLS 1.0.
 
 @type closed: bool
 @ivar closed: If this connection is closed.
 
 @type resumed: bool
 @ivar resumed: If this connection is based on a resumed session.
 
 @type allegedSharedKeyUsername: str or None
 @ivar 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 allegedSrpUsername: str or None
 @ivar 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 closeSocket: bool
 @ivar 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 ignoreAbruptClose: bool
 @ivar 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
 L{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.
 
 @sort: __init__, read, readAsync, write, writeAsync, close, closeAsync,
 getCipherImplementation, getCipherName
 
 |  |  | Methods defined here: 
 __init__(self, sock)
 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.
 
 @raise socket.error: If a socket error occurs.
 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed
 without a preceding alert.
 @raise 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.
 
 @rtype: iterable
 @return: A generator; see above for details.
 getCipherImplementation(self)Get the name of the cipher implementation used withthis connection.
 
 @rtype: str
 @return: The name of the cipher implementation used with
 this connection.  Either 'python', 'cryptlib', 'openssl',
 or 'pycrypto'.
 getCipherName(self)Get the name of the cipher used with this connection.
 @rtype: str
 @return: The name of the cipher used with this connection.
 Either 'aes128', 'aes256', 'rc4', or '3des'.
 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 (socketemulation).
 makefile(self, mode='r', bufsize=-1)Create a file object for the TLS connection (socket emulation).
 @rtype: L{tlslite.FileObject.FileObject}
 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.
 
 @type max: int
 @param max: The maximum number of bytes to return.
 
 @type min: int
 @param min: The minimum number of bytes to return
 
 @rtype: str
 @return: 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).
 
 @raise socket.error: If a socket error occurs.
 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed
 without a preceding alert.
 @raise 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.
 
 @rtype: iterable
 @return: A generator; see above for details.
 recv(self, bufsize)Get some data from the TLS connection (socket emulation).
 @raise socket.error: If a socket error occurs.
 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed
 without a preceding alert.
 @raise tlslite.errors.TLSAlert: If a TLS alert is signalled.
 send(self, s)Send data to the TLS connection (socket emulation).
 @raise socket.error: If a socket error occurs.
 sendall(self, s)Send data to the TLS connection (socket emulation).
 @raise 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).
 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.
 
 @type s: str
 @param s: The data to transmit to the other party.
 
 @raise 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.
 
 @rtype: iterable
 @return: A generator; see above for details.
 |  |