Logo Search packages:      
Sourcecode: paramiko version File versions  Download package

def paramiko::packet::Packetizer::send_message (   self,
  data 
)

Write a block of data using the current cipher, as an SSH block.

Definition at line 240 of file packet.py.

00240                                 :
        """
        Write a block of data using the current cipher, as an SSH block.
        """
        # encrypt this sucka
        randpool.stir()
        data = str(data)
        cmd = ord(data[0])
        if cmd in MSG_NAMES:
            cmd_name = MSG_NAMES[cmd]
        else:
            cmd_name = '$%x' % cmd
        self._log(DEBUG, 'Write packet <%s>, length %d' % (cmd_name, len(data)))
        if self.__compress_engine_out is not None:
            data = self.__compress_engine_out(data)
        packet = self._build_packet(data)
        if self.__dump_packets:
            self._log(DEBUG, util.format_binary(packet, 'OUT: '))
        self.__write_lock.acquire()
        try:
            if self.__block_engine_out != None:
                out = self.__block_engine_out.encrypt(packet)
            else:
                out = packet
            # + mac
            if self.__block_engine_out != None:
                payload = struct.pack('>I', self.__sequence_number_out) + packet
                out += HMAC.HMAC(self.__mac_key_out, payload, self.__mac_engine_out).digest()[:self.__mac_size_out]
            self.__sequence_number_out = (self.__sequence_number_out + 1) & 0xffffffffL
            self.write_all(out)

            self.__sent_bytes += len(out)
            self.__sent_packets += 1
            if ((self.__sent_packets >= self.REKEY_PACKETS) or (self.__sent_bytes >= self.REKEY_BYTES)) \
                   and not self.__need_rekey:
                # only ask once for rekeying
                self._log(DEBUG, 'Rekeying (hit %d packets, %d bytes sent)' %
                          (self.__sent_packets, self.__sent_bytes))
                self.__received_packets_overflow = 0
                self._trigger_rekey()
        finally:
            self.__write_lock.release()

    def read_message(self):


Generated by  Doxygen 1.6.0   Back to index