diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-29 16:55:01 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-29 16:55:01 -0700 |
commit | 4d3e0b711a98c440810004cb599a00d0f72978d7 (patch) | |
tree | c3d0f0912f496a53dc2fd74e06c69da936b5d8e3 /paramiko/rsakey.py | |
parent | 5a430def22aa5cbd755f347c8714e4140d6cdcab (diff) | |
download | paramiko-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.py | 7 |
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,)) |