diff options
author | Robey Pointer <robey@lag.net> | 2005-06-28 03:42:57 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2005-06-28 03:42:57 +0000 |
commit | c0b22a3aec9f2a4868bbed23dc6e2542097a18f9 (patch) | |
tree | 8d6d2838b6610dd5da0db5fce1f55c4a04e83ed0 | |
parent | c5d2e9904aa830874e835b2f35a6d97cc72ba0b7 (diff) |
[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
-rw-r--r-- | paramiko/packet.py | 9 |
1 files 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 <robey@lag.net> # # 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): |