summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorXavier Nunn <xavier.nunn@gmail.com>2014-06-18 18:54:32 +0200
committerXavier Nunn <xavier.nunn@gmail.com>2014-06-18 18:54:32 +0200
commit56417507ee0fbe28b938e03909945c127c8bbde1 (patch)
tree71b8e2185189fa2d12de5210753e5590cabaee35
parente811e715833373dd2f2ba898089695eee9c882ed (diff)
Corrected the length of the salt for private key encryption
This would corrupt the private key file whenever the DES cipher would get selected.
-rw-r--r--paramiko/pkey.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/paramiko/pkey.py b/paramiko/pkey.py
index 373563f6..2daf3723 100644
--- a/paramiko/pkey.py
+++ b/paramiko/pkey.py
@@ -324,13 +324,12 @@ class PKey (object):
def _write_private_key(self, tag, f, data, password=None):
f.write('-----BEGIN %s PRIVATE KEY-----\n' % tag)
if password is not None:
- # since we only support one cipher here, use it
cipher_name = list(self._CIPHER_TABLE.keys())[0]
cipher = self._CIPHER_TABLE[cipher_name]['cipher']
keysize = self._CIPHER_TABLE[cipher_name]['keysize']
blocksize = self._CIPHER_TABLE[cipher_name]['blocksize']
mode = self._CIPHER_TABLE[cipher_name]['mode']
- salt = os.urandom(16)
+ salt = os.urandom(blocksize)
key = util.generate_key_bytes(md5, salt, password, keysize)
if len(data) % blocksize != 0:
n = blocksize - len(data) % blocksize