[project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-10]

fix stupid bug in kex_group1 which luckily only affected unit tests
This commit is contained in:
Robey Pointer 2005-05-21 20:35:29 +00:00
parent cb5aa0671b
commit 44239ae077
4 changed files with 14 additions and 12 deletions

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
# Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -96,8 +94,11 @@ class KexGroup1(object):
# okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K) # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
hm = Message() hm = Message()
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, self.e, self.f, K) hm.add_string(host_key)
hm.add_mpint(self.e)
hm.add_mpint(self.f)
hm.add_mpint(K)
self.transport._set_K_H(K, SHA.new(str(hm)).digest()) self.transport._set_K_H(K, SHA.new(str(hm)).digest())
self.transport._verify_key(host_key, sig) self.transport._verify_key(host_key, sig)
self.transport._activate_outbound() self.transport._activate_outbound()
@ -112,8 +113,11 @@ class KexGroup1(object):
# okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K) # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
hm = Message() hm = Message()
hm.add(self.transport.remote_version, self.transport.local_version, hm.add(self.transport.remote_version, self.transport.local_version,
self.transport.remote_kex_init, self.transport.local_kex_init, self.transport.remote_kex_init, self.transport.local_kex_init)
key, self.e, self.f, K) hm.add_string(key)
hm.add_mpint(self.e)
hm.add_mpint(self.f)
hm.add_mpint(K)
H = SHA.new(str(hm)).digest() H = SHA.new(str(hm)).digest()
self.transport._set_K_H(K, H) self.transport._set_K_H(K, H)
# sign it # sign it

View File

@ -98,7 +98,7 @@ class KexTest (unittest.TestCase):
msg.add_mpint(69) msg.add_mpint(69)
msg.add_string('fake-sig') msg.add_string('fake-sig')
kex.parse_next(paramiko.kex_group1._MSG_KEXDH_REPLY, msg) kex.parse_next(paramiko.kex_group1._MSG_KEXDH_REPLY, msg)
H = '0C39EDB98E9853B85D4527DA940EB03301925329' H = '03079780F3D3AD0B3C6DB30C8D21685F367A86D2'
self.assertEquals(self.K, transport._K) self.assertEquals(self.K, transport._K)
self.assertEquals(H, paramiko.util.hexify(transport._H)) self.assertEquals(H, paramiko.util.hexify(transport._H))
self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify) self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)
@ -114,7 +114,7 @@ class KexTest (unittest.TestCase):
msg = Message() msg = Message()
msg.add_mpint(69) msg.add_mpint(69)
kex.parse_next(paramiko.kex_group1._MSG_KEXDH_INIT, msg) kex.parse_next(paramiko.kex_group1._MSG_KEXDH_INIT, msg)
H = '77FE6F0094FB8DB3270106A77F88D66E09EEF8AF' H = 'B16BF34DD10945EDE84E9C1EF24A14BFDC843389'
x = '1F0000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967' x = '1F0000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
self.assertEquals(self.K, transport._K) self.assertEquals(self.K, transport._K)
self.assertEquals(H, paramiko.util.hexify(transport._H)) self.assertEquals(H, paramiko.util.hexify(transport._H))

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
# Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.