summaryrefslogtreecommitdiff
path: root/paramiko/pkey.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-03-29 16:55:01 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-03-29 16:55:01 -0700
commit4d3e0b711a98c440810004cb599a00d0f72978d7 (patch)
treec3d0f0912f496a53dc2fd74e06c69da936b5d8e3 /paramiko/pkey.py
parent5a430def22aa5cbd755f347c8714e4140d6cdcab (diff)
downloadparamiko-4d3e0b711a98c440810004cb599a00d0f72978d7.tar.gz
Switched hash functions from PyCrypto to hashlib.
There's a few advantages to this: 1) It's probably fast, OpenSSL, which typically backs hashlib, receives far more attention for optimizaitons than PyCrypto. 2) It's the first step to supporting PyPy, where PyCrypto doesn't run.
Diffstat (limited to 'paramiko/pkey.py')
-rw-r--r--paramiko/pkey.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/paramiko/pkey.py b/paramiko/pkey.py
index c8f84e0a..7d5da409 100644
--- a/paramiko/pkey.py
+++ b/paramiko/pkey.py
@@ -23,8 +23,8 @@ Common API for all public keys.
import base64
from binascii import hexlify, unhexlify
import os
+from hashlib import md5
-from Crypto.Hash import MD5
from Crypto.Cipher import DES3, AES
from paramiko import util
@@ -126,7 +126,7 @@ class PKey (object):
a 16-byte `string <str>` (binary) of the MD5 fingerprint, in SSH
format.
"""
- return MD5.new(self.asbytes()).digest()
+ return md5(self.asbytes()).digest()
def get_base64(self):
"""
@@ -300,7 +300,7 @@ class PKey (object):
keysize = self._CIPHER_TABLE[encryption_type]['keysize']
mode = self._CIPHER_TABLE[encryption_type]['mode']
salt = unhexlify(b(saltstr))
- key = util.generate_key_bytes(MD5, salt, password, keysize)
+ key = util.generate_key_bytes(md5, salt, password, keysize)
return cipher.new(key, mode, salt).decrypt(data)
def _write_private_key_file(self, tag, filename, data, password=None):
@@ -332,7 +332,7 @@ class PKey (object):
blocksize = self._CIPHER_TABLE[cipher_name]['blocksize']
mode = self._CIPHER_TABLE[cipher_name]['mode']
salt = rng.read(16)
- key = util.generate_key_bytes(MD5, salt, password, keysize)
+ key = util.generate_key_bytes(md5, salt, password, keysize)
if len(data) % blocksize != 0:
n = blocksize - len(data) % blocksize
#data += rng.read(n)