From c0b22a3aec9f2a4868bbed23dc6e2542097a18f9 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 28 Jun 2005 03:42:57 +0000 Subject: [project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-14] cute trick i saw openssh do in a network trace: if we're not encrypting, don't waste random bytes for the padding in packetizing --- paramiko/packet.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/paramiko/packet.py b/paramiko/packet.py index 2fdc163d..5bd2b19a 100644 --- a/paramiko/packet.py +++ b/paramiko/packet.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer # # This file is part of paramiko. @@ -405,7 +403,12 @@ class Packetizer (object): padding = 3 + bsize - ((len(payload) + 8) % bsize) packet = struct.pack('>IB', len(payload) + padding + 1, padding) packet += payload - packet += randpool.get_bytes(padding) + if self.__block_engine_out is not None: + packet += randpool.get_bytes(padding) + else: + # cute trick i caught openssh doing: if we're not encrypting, + # don't waste random bytes for the padding + packet += (chr(0) * padding) return packet def _trigger_rekey(self): -- cgit v1.2.3