From 44239ae077358a40f58c46449cfb929a3061bb67 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sat, 21 May 2005 20:35:29 +0000 Subject: [PATCH] [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 --- paramiko/kex_group1.py | 16 ++++++++++------ paramiko/pkey.py | 4 ++-- tests/test_kex.py | 4 ++-- tests/test_pkey.py | 2 -- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/paramiko/kex_group1.py b/paramiko/kex_group1.py index 263cf8a..12255aa 100644 --- a/paramiko/kex_group1.py +++ b/paramiko/kex_group1.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer # # 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) hm = Message() hm.add(self.transport.local_version, self.transport.remote_version, - self.transport.local_kex_init, self.transport.remote_kex_init, - host_key, self.e, self.f, K) + self.transport.local_kex_init, self.transport.remote_kex_init) + 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._verify_key(host_key, sig) 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) hm = Message() hm.add(self.transport.remote_version, self.transport.local_version, - self.transport.remote_kex_init, self.transport.local_kex_init, - key, self.e, self.f, K) + self.transport.remote_kex_init, self.transport.local_kex_init) + hm.add_string(key) + hm.add_mpint(self.e) + hm.add_mpint(self.f) + hm.add_mpint(K) H = SHA.new(str(hm)).digest() self.transport._set_K_H(K, H) # sign it diff --git a/paramiko/pkey.py b/paramiko/pkey.py index 4938127..315879e 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -232,14 +232,14 @@ class PKey (object): @param filename: name of the file to read. @type filename: str @param password: an optional password to use to decrypt the key file, - if it's encrypted. + if it's encrypted. @type password: str @return: data blob that makes up the private key. @rtype: str @raise IOError: if there was an error reading the file. @raise PasswordRequiredException: if the private key file is - encrypted, and C{password} is C{None}. + encrypted, and C{password} is C{None}. @raise SSHException: if the key file is invalid. """ f = open(filename, 'r') diff --git a/tests/test_kex.py b/tests/test_kex.py index f4e9193..536c386 100644 --- a/tests/test_kex.py +++ b/tests/test_kex.py @@ -98,7 +98,7 @@ class KexTest (unittest.TestCase): msg.add_mpint(69) msg.add_string('fake-sig') kex.parse_next(paramiko.kex_group1._MSG_KEXDH_REPLY, msg) - H = '0C39EDB98E9853B85D4527DA940EB03301925329' + H = '03079780F3D3AD0B3C6DB30C8D21685F367A86D2' self.assertEquals(self.K, transport._K) self.assertEquals(H, paramiko.util.hexify(transport._H)) self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify) @@ -114,7 +114,7 @@ class KexTest (unittest.TestCase): msg = Message() msg.add_mpint(69) kex.parse_next(paramiko.kex_group1._MSG_KEXDH_INIT, msg) - H = '77FE6F0094FB8DB3270106A77F88D66E09EEF8AF' + H = 'B16BF34DD10945EDE84E9C1EF24A14BFDC843389' x = '1F0000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967' self.assertEquals(self.K, transport._K) self.assertEquals(H, paramiko.util.hexify(transport._H)) diff --git a/tests/test_pkey.py b/tests/test_pkey.py index 3fe4861..338ed20 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer # # This file is part of paramiko.