diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2017-06-13 12:59:42 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-06-13 12:59:42 -0700 |
commit | e5645e5ad874adfcb2970fc17b880fbb5ea131aa (patch) | |
tree | 23d4d4d39e0cca3885fd6a8619146954f7d4b52a | |
parent | 772d493aa329f6086e73b43a11505741984cffad (diff) | |
parent | 47f904837f72bb6a5355e139854a17f5875f8928 (diff) |
Merge branch '2.2'
-rw-r--r-- | paramiko/ed25519key.py | 7 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | sites/www/changelog.rst | 6 | ||||
-rw-r--r-- | tests/test_pkey.py | 10 |
4 files changed, 23 insertions, 2 deletions
diff --git a/paramiko/ed25519key.py b/paramiko/ed25519key.py index e1a8a732..a50d68bc 100644 --- a/paramiko/ed25519key.py +++ b/paramiko/ed25519key.py @@ -167,6 +167,13 @@ class Ed25519Key(PKey): m.add_string(v.encode()) return m.asbytes() + def __hash__(self): + if self.can_sign(): + v = self._signing_key.verify_key + else: + v = self._verifying_key + return hash((self.get_name(), v)) + def get_name(self): return "ssh-ed25519" @@ -75,7 +75,7 @@ setup( 'Programming Language :: Python :: 3.6', ], install_requires=[ - 'bcrypt>=3.0.0', + 'bcrypt>=3.1.3', 'cryptography>=1.1', 'pynacl>=1.0.1', 'pyasn1>=0.1.7', diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 3c6aa609..bed4fd7f 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,12 @@ Changelog ========= +* :bug:`993` Ed25519 host keys were not comparable/hashable, causing an + exception if such a key existed in a ``known_hosts`` file. Thanks to Oleh + Prypin for the report and Pierce Lopez for the fix. +* :bug:`990` The (added in 2.2.0) ``bcrypt`` dependency should have been on + version 3.1.3 or greater (was initially set to 3.0.0 or greater.) Thanks to + Paul Howarth for the report. * :release:`2.2.0 <2017-06-09>` * :release:`2.1.3 <2017-06-09>` * :release:`2.0.6 <2017-06-09>` diff --git a/tests/test_pkey.py b/tests/test_pkey.py index 6e589915..9bb3c44c 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -455,9 +455,17 @@ class KeyTest(unittest.TestCase): key2 = Ed25519Key.from_private_key_file( test_path('test_ed25519_password.key'), b'abc123' ) - self.assertNotEqual(key1.asbytes(), key2.asbytes()) + def test_ed25519_compare(self): + # verify that the private & public keys compare equal + key = Ed25519Key.from_private_key_file(test_path('test_ed25519.key')) + self.assertEqual(key, key) + pub = Ed25519Key(data=key.asbytes()) + self.assertTrue(key.can_sign()) + self.assertTrue(not pub.can_sign()) + self.assertEqual(key, pub) + def test_keyfile_is_actually_encrypted(self): # Read an existing encrypted private key file_ = test_path('test_rsa_password.key') |