Ejemplo n.º 1
0
    def __init__(self, reactor, buf_len=4096):
        self.__reactor = reactor
        self.__buf_len = buf_len

        self.__bc_consumed = 0
        self.__bc_consume_lim = 0
        self.__bc_producer = None
        self.__bc_eod = False
        self.__bc_eod_clean = None
        self.__bc_rbuf = VByteBuffer()
        self.__bc_rbuf_len = buf_len
        self.__bc_reader = None
        self.__bc_aborted = False
        self.__bc_cond = Condition()
        self.__bc_scheduled_lim_update = False

        self.__bp_produced = 0
        self.__bp_produce_lim = 0
        self.__bp_consumer = None
        self.__bp_eod = False
        self.__bp_eod_clean = None
        self.__bp_wbuf = VByteBuffer()
        self.__bp_wbuf_len = buf_len
        self.__bp_writer = None
        self.__bp_sent_eod = False
        self.__bp_aborted = False
        self.__bp_cond = Condition()
        self.__bp_scheduled_produce = False

        self.__bc_iface = self.__bp_iface = None

        # Set up a local logger for convenience
        self.__logger = VLogger(prefix='ByteChannel')
        self.__logger.add_watcher(self.reactor.log)
Ejemplo n.º 2
0
 def __init__(self, decrypter, hash_cls, mac_secret):
     self._decrypter = decrypter
     self._hash_cls = hash_cls
     self._mac_secret = mac_secret
     self._max_plaintext_len = 0x10000  # HARDCODED 2-byte message length
     self._cipher_blocksize = decrypter.blocksize
     self._hash_len = hash_cls.digest_size()
     self._read_buf = VByteBuffer()
     self._in_buf = VByteBuffer()
     self._msg_buf = VByteBuffer()
     self._have_len = False
     self._plaintext_blocksize = None
     self._plaintext_len = None
     self._invalid = False
     self._result = None
     self._msg_num = 0
Ejemplo n.º 3
0
    def __init__(self, *args, **kargs):
        super(VOPServerBridge, self).__init__(*args, **kargs)

        self.__HSHAKE_MAXLEN = 64
        self.__have_client_hello = False
        self.__buf = VByteBuffer()
        self.__negotiated_factory = None
Ejemplo n.º 4
0
    def __init__(self,
                 reactor,
                 sock=None,
                 hc_pol=None,
                 close_cback=None,
                 connected=False,
                 max_read=0x4000,
                 max_write=0x4000,
                 wbuf_len=None):
        self._max_read = max_read
        self._max_write = max_write
        self._wbuf = VByteBuffer()
        if wbuf_len is None:
            wbuf_len = max_write
        self._wbuf_len = wbuf_len

        self._ci = None
        self._ci_eod = False
        self._ci_eod_clean = None
        self._ci_producer = None
        self._ci_consumed = 0
        self._ci_lim_sent = 0
        self._ci_aborted = False

        self._pi = None
        self._pi_closed = False
        self._pi_consumer = None
        self._pi_produced = 0
        self._pi_prod_lim = 0
        self._pi_buffer = VByteBuffer()
        self._pi_aborted = False

        # Parent __init__ must be called after local attributes are
        # initialized due to overloaded methods called during construction
        super_init = super(VClientSocketAgent, self).__init__
        super_init(reactor=reactor,
                   sock=sock,
                   hc_pol=hc_pol,
                   close_cback=close_cback,
                   connected=connected)
Ejemplo n.º 5
0
 def __init__(self, blocksize, start_value=None):
     if blocksize <= 0:
         raise TypeError('Blocksize must be >= 1')
     self._blocksize = blocksize
     if start_value is not None:
         if (not isinstance(start_value, bytes)
                 or len(start_value) != blocksize):
             raise TypeError('Start value must be blocksize bytes')
         self._block = start_value
     else:
         self._block = b'\x00' * blocksize
     self.__cache = VByteBuffer()
     self.__cache.append(self._block)
Ejemplo n.º 6
0
    def __init__(self,
                 reactor,
                 read_fd,
                 write_fd,
                 max_read=0x4000,
                 max_write=0x4000,
                 wbuf_len=None):
        self.__reactor = reactor

        self._reader = _VAgentReader(self, reactor, read_fd)
        self._writer = _VAgentWriter(self, reactor, write_fd)
        self._reader.set_pipe_peer(self._writer)
        self._writer.set_pipe_peer(self._reader)

        self._max_read = max_read
        self._max_write = max_write
        self._wbuf = VByteBuffer()
        if wbuf_len is None:
            wbuf_len = max_write
        self._wbuf_len = wbuf_len

        self._ci = None
        self._ci_eod = False
        self._ci_eod_clean = None
        self._ci_producer = None
        self._ci_consumed = 0
        self._ci_lim_sent = 0
        self._ci_aborted = False

        self._pi = None
        self._pi_closed = False
        self._pi_consumer = None
        self._pi_produced = 0
        self._pi_prod_lim = 0
        self._pi_buffer = VByteBuffer()
        self._pi_aborted = False
Ejemplo n.º 7
0
    def __init__(self, *args, **kargs):
        super(VOPClientBridge, self).__init__(*args, **kargs)

        self.__HSHAKE_MAXLEN = 64
        self.__sent_client_hello = False
        self.__have_server_response = False
        self.__buf = VByteBuffer()

        # Set up client hello message based on enabled protocols
        self.__buf.append(b'VOP_DRAFT-0.8 TRANSPORTS')
        if self._vts_factory:
            self.__buf.append(b':VTS')
        if self._tls_factory:
            self.__buf.append(b':TLS')
        if self._allow_insecure:
            self.__buf.append(b':PLAIN')
        self.__buf.append(b'\n')
Ejemplo n.º 8
0
 def __init__(self, hash_cls, secret, seed):
     self._hash_cls = hash_cls
     self._secret = secret
     self._seed = seed
     self._pr_data_buff = VByteBuffer()
     self._a = seed  # A_i from RFC 5246, initialized as A_0
Ejemplo n.º 9
0
 def __init__(self, in_gen, hasher, ratio):
     self.__input = in_gen
     self.__hasher = hasher
     self.__digest_size = hasher.digest_size()
     self.__ratio = ratio
     self.__cache = VByteBuffer()
Ejemplo n.º 10
0
 def __init__(self, in_gen, transform, blocksize=None):
     self.__input = in_gen
     self.__transform = transform
     self.__blocksize = blocksize
     self.__cache = VByteBuffer()
Ejemplo n.º 11
0
 def __init__(self, pattern):
     if not isinstance(pattern, bytes) or not pattern:
         raise TypeError('Pattern must be non-empty bytes object')
     self.__pattern = pattern
     self.__cache = VByteBuffer()