gdata.tlslite.TLSRecordLayer | index /usr/lib/python2.7/dist-packages/gdata/tlslite/TLSRecordLayer.py

`Helper class for TLSConnection.`

Modules

``

array base64 binascii | errno gdata.tlslite.utils.hmac math | md5 os sha | socket sys traceback

Classes

``

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 with
  this 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 (socket
  emulation).`

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.`

Functions

``

sha1 = openssl_sha1(...)
  `Returns a sha1 hash object; optionally initialized with a string`

Data

``

cryptlibpyLoaded = False
generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 0)
gmpyLoaded = False
goodGroupParameters = [(2, 167609434410335061...389658897350067939L), (2, 148699818592312829...022696100064262587L), (2, 217661744586174357...299250924469288819L), (2, 580960599536995806...769998514148343807L), (5, 104438888141315250...045385534758453247L), (5, 337515218214385611...109988915707117567L), (5, 109074813561941592...353154294858383359L)]
m2cryptoLoaded = False
prngName = 'os.urandom'
pycryptoLoaded = False
sieve = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ...]