From 758c18a28b1ff5df1a920d02ef1e9df52853a677 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sun, 28 Oct 2007 20:05:20 -0700 Subject: [PATCH] [project @ robey@lag.net-20071029030520-ozmne7y4l6037m8h] bug discovered while porting to jaramiko: old-style gex wasn't creating the proper hash. fixed. --- Makefile | 1 + paramiko/kex_gex.py | 7 +++++-- tests/test_kex.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6706f41..742a412 100644 --- a/Makefile +++ b/Makefile @@ -65,3 +65,4 @@ test: # transport.py # # POST md5sum on website! +# RUN setup.py diff --git a/paramiko/kex_gex.py b/paramiko/kex_gex.py index c29c288..63a0c99 100644 --- a/paramiko/kex_gex.py +++ b/paramiko/kex_gex.py @@ -64,6 +64,7 @@ class KexGex (object): # only used for unit tests: we shouldn't ever send this m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST_OLD)) m.add_int(self.preferred_bits) + self.old_style = True else: m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST)) m.add_int(self.min_bits) @@ -228,9 +229,11 @@ class KexGex (object): hm.add(self.transport.local_version, self.transport.remote_version, self.transport.local_kex_init, self.transport.remote_kex_init, host_key) - hm.add_int(self.min_bits) + if not self.old_style: + hm.add_int(self.min_bits) hm.add_int(self.preferred_bits) - hm.add_int(self.max_bits) + if not self.old_style: + hm.add_int(self.max_bits) hm.add_mpint(self.p) hm.add_mpint(self.g) hm.add_mpint(self.e) diff --git a/tests/test_kex.py b/tests/test_kex.py index 1989117..f304275 100644 --- a/tests/test_kex.py +++ b/tests/test_kex.py @@ -179,7 +179,7 @@ class KexTest (unittest.TestCase): msg.add_string('fake-sig') msg.rewind() kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REPLY, msg) - H = 'A265563F2FA87F1A89BF007EE90D58BE2E4A4BD0' + H = '807F87B269EF7AC5EC7E75676808776A27D5864C' self.assertEquals(self.K, transport._K) self.assertEquals(H, hexlify(transport._H).upper()) self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)