summaryrefslogtreecommitdiff
path: root/paramiko/rsakey.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/rsakey.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/rsakey.py')
-rw-r--r--paramiko/rsakey.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py
index c93f3218..fc09b5cb 100644
--- a/paramiko/rsakey.py
+++ b/paramiko/rsakey.py
@@ -20,8 +20,9 @@
RSA keys.
"""
+from hashlib import sha1
+
from Crypto.PublicKey import RSA
-from Crypto.Hash import SHA
from paramiko import util
from paramiko.common import rng, max_byte, zero_byte, one_byte
@@ -91,7 +92,7 @@ class RSAKey (PKey):
return self.d is not None
def sign_ssh_data(self, rpool, data):
- digest = SHA.new(data).digest()
+ digest = sha1(data).digest()
rsa = RSA.construct((long(self.n), long(self.e), long(self.d)))
sig = util.deflate_long(rsa.sign(self._pkcs1imify(digest), bytes())[0], 0)
m = Message()
@@ -106,7 +107,7 @@ class RSAKey (PKey):
# verify the signature by SHA'ing the data and encrypting it using the
# public key. some wackiness ensues where we "pkcs1imify" the 20-byte
# hash into a string as long as the RSA key.
- hash_obj = util.inflate_long(self._pkcs1imify(SHA.new(data).digest()), True)
+ hash_obj = util.inflate_long(self._pkcs1imify(sha1(data).digest()), True)
rsa = RSA.construct((long(self.n), long(self.e)))
return rsa.verify(hash_obj, (sig,))