bug discovered while porting to jaramiko: old-style gex wasn't creating
the proper hash. fixed.
This commit is contained in:
Robey Pointer 2007-10-28 20:05:20 -07:00
parent e3d9b90ea1
commit 758c18a28b
3 changed files with 7 additions and 3 deletions

View File

@ -65,3 +65,4 @@ test:
# transport.py # transport.py
# #
# POST md5sum on website! # POST md5sum on website!
# RUN setup.py

View File

@ -64,6 +64,7 @@ class KexGex (object):
# only used for unit tests: we shouldn't ever send this # only used for unit tests: we shouldn't ever send this
m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST_OLD)) m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST_OLD))
m.add_int(self.preferred_bits) m.add_int(self.preferred_bits)
self.old_style = True
else: else:
m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST)) m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST))
m.add_int(self.min_bits) m.add_int(self.min_bits)
@ -228,9 +229,11 @@ class KexGex (object):
hm.add(self.transport.local_version, self.transport.remote_version, hm.add(self.transport.local_version, self.transport.remote_version,
self.transport.local_kex_init, self.transport.remote_kex_init, self.transport.local_kex_init, self.transport.remote_kex_init,
host_key) 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.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.p)
hm.add_mpint(self.g) hm.add_mpint(self.g)
hm.add_mpint(self.e) hm.add_mpint(self.e)

View File

@ -179,7 +179,7 @@ class KexTest (unittest.TestCase):
msg.add_string('fake-sig') msg.add_string('fake-sig')
msg.rewind() msg.rewind()
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REPLY, msg) kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REPLY, msg)
H = 'A265563F2FA87F1A89BF007EE90D58BE2E4A4BD0' H = '807F87B269EF7AC5EC7E75676808776A27D5864C'
self.assertEquals(self.K, transport._K) self.assertEquals(self.K, transport._K)
self.assertEquals(H, hexlify(transport._H).upper()) self.assertEquals(H, hexlify(transport._H).upper())
self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify) self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)