Test cases for better handling of SSH key comments
sshd man page says: "The optional comment field continues to the end of the line, and is not used." http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8?query=sshd&sec=8 This bug has been fixed in upstream https://github.com/pyca/cryptography/issues/2199 Closes-Bug: #1481084 Depends-On: I28b7ab2e49ef4063a33c6122ea8355a16c3105a5 Change-Id: Ic157961a4282f0d54d4682d9374c170a66ddde5c
This commit is contained in:

committed by
Davanum Srinivas (dims)

parent
9f9802eebd
commit
42debc4cfd
@@ -241,6 +241,12 @@ e6fCXWECgYEAqgpGvva5kJ1ISgNwnJbwiNw0sOT9BMOsdNZBElf0kJIIy6FMPvap
|
||||
raise exception.DecryptionFailure(reason=exc.stderr)
|
||||
|
||||
def test_ssh_encrypt_decrypt_text(self):
|
||||
self._test_ssh_encrypt_decrypt_text(self.pubkey)
|
||||
key_with_spaces_in_comment = self.pubkey.replace('test@test',
|
||||
'Generated by Nova')
|
||||
self._test_ssh_encrypt_decrypt_text(key_with_spaces_in_comment)
|
||||
|
||||
def _test_ssh_encrypt_decrypt_text(self, key):
|
||||
enc = crypto.ssh_encrypt_text(self.pubkey, self.text)
|
||||
self.assertIsInstance(enc, bytes)
|
||||
# Comparison between bytes and str raises a TypeError
|
||||
@@ -322,6 +328,12 @@ class KeyPairTest(test.TestCase):
|
||||
"uYREz7iLRCP7BwUt8R+ZWzFZDeOLIWU= Generated-by-Nova"
|
||||
)
|
||||
|
||||
ecdsa_pub_with_spaces = (
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy"
|
||||
"NTYAAABBBG1r4wzPTIjSo78POCq+u/czb8gYK0KvqlmCvcRPrnDWxgLw7y6BX51t"
|
||||
"uYREz7iLRCP7BwUt8R+ZWzFZDeOLIWU= Generated by Nova"
|
||||
)
|
||||
|
||||
ecdsa_fp = "16:6a:c9:ec:80:4d:17:3e:d5:3b:6f:c0:d7:15:04:40"
|
||||
|
||||
def test_generate_fingerprint(self):
|
||||
@@ -334,6 +346,9 @@ class KeyPairTest(test.TestCase):
|
||||
fingerprint = crypto.generate_fingerprint(self.ecdsa_pub)
|
||||
self.assertEqual(self.ecdsa_fp, fingerprint)
|
||||
|
||||
fingerprint = crypto.generate_fingerprint(self.ecdsa_pub_with_spaces)
|
||||
self.assertEqual(self.ecdsa_fp, fingerprint)
|
||||
|
||||
def test_generate_key_pair_2048_bits(self):
|
||||
(private_key, public_key, fingerprint) = crypto.generate_key_pair()
|
||||
pub_bytes = public_key.encode('utf-8')
|
||||
|
Reference in New Issue
Block a user