summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-09-08 15:37:23 -0700
committerJeff Forcier <jeff@bitprophet.org>2014-09-08 15:37:23 -0700
commit35fa518d8b0b9c91dbd498aa20225825c428db60 (patch)
treee6a86f4ff034926bea97b6ed336dd20de652c956
parent9c9dcaf4885653f4dcd100b2724199976a20c21e (diff)
downloadparamiko-35fa518d8b0b9c91dbd498aa20225825c428db60.tar.gz
Test proving #346
-rw-r--r--tests/test_pkey.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_pkey.py b/tests/test_pkey.py
index 1468ee27..3d5f0326 100644
--- a/tests/test_pkey.py
+++ b/tests/test_pkey.py
@@ -21,6 +21,7 @@ Some unit tests for public/private key objects.
"""
import unittest
+import os
from binascii import hexlify
from hashlib import md5
@@ -253,3 +254,20 @@ class KeyTest (unittest.TestCase):
msg.rewind()
pub = ECDSAKey(data=key.asbytes())
self.assertTrue(pub.verify_ssh_sig(b'ice weasels', msg))
+
+ def test_salt_size(self):
+ # Read an existing encrypted private key
+ file_ = test_path('test_rsa_password.key')
+ password = 'television'
+ newfile = file_ + '.new'
+ newpassword = 'radio'
+ key = RSAKey(filename=file_, password=password)
+ # Write out a newly re-encrypted copy with a new password.
+ # When the bug under test exists, this will ValueError.
+ try:
+ key.write_private_key_file(newfile, password=newpassword)
+ # Verify the inner key data still matches (when no ValueError)
+ key2 = RSAKey(newfile, password=newpassword)
+ self.assertEqual(key, key2)
+ finally:
+ os.remove(newfile)