diff options
-rw-r--r-- | paramiko/dsskey.py | 9 | ||||
-rw-r--r-- | paramiko/ecdsakey.py | 12 | ||||
-rw-r--r-- | paramiko/rsakey.py | 15 | ||||
-rw-r--r-- | setup.py | 2 |
4 files changed, 13 insertions, 25 deletions
diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py index 9af5d0c1..99734458 100644 --- a/paramiko/dsskey.py +++ b/paramiko/dsskey.py @@ -106,9 +106,8 @@ class DSSKey(PKey): ) ) ).private_key(backend=default_backend()) - signer = key.signer(hashes.SHA1()) - signer.update(data) - r, s = decode_dss_signature(signer.finalize()) + sig = key.sign(data, hashes.SHA1()) + r, s = decode_dss_signature(sig) m = Message() m.add_string('ssh-dss') @@ -146,10 +145,8 @@ class DSSKey(PKey): g=self.g ) ).public_key(backend=default_backend()) - verifier = key.verifier(signature, hashes.SHA1()) - verifier.update(data) try: - verifier.verify() + key.verify(signature, data, hashes.SHA1()) except InvalidSignature: return False else: diff --git a/paramiko/ecdsakey.py b/paramiko/ecdsakey.py index fa850c2e..1add88bd 100644 --- a/paramiko/ecdsakey.py +++ b/paramiko/ecdsakey.py @@ -179,9 +179,7 @@ class ECDSAKey(PKey): def sign_ssh_data(self, data): ecdsa = ec.ECDSA(self.ecdsa_curve.hash_object()) - signer = self.signing_key.signer(ecdsa) - signer.update(data) - sig = signer.finalize() + sig = self.signing_key.sign(data, ecdsa) r, s = decode_dss_signature(sig) m = Message() @@ -196,12 +194,10 @@ class ECDSAKey(PKey): sigR, sigS = self._sigdecode(sig) signature = encode_dss_signature(sigR, sigS) - verifier = self.verifying_key.verifier( - signature, ec.ECDSA(self.ecdsa_curve.hash_object()) - ) - verifier.update(data) try: - verifier.verify() + self.verifying_key.verify( + signature, data, ec.ECDSA(self.ecdsa_curve.hash_object()) + ) except InvalidSignature: return False else: diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py index b5107515..a457a121 100644 --- a/paramiko/rsakey.py +++ b/paramiko/rsakey.py @@ -103,12 +103,11 @@ class RSAKey(PKey): return isinstance(self.key, rsa.RSAPrivateKey) def sign_ssh_data(self, data): - signer = self.key.signer( + sig = self.key.sign( + data, padding=padding.PKCS1v15(), algorithm=hashes.SHA1(), ) - signer.update(data) - sig = signer.finalize() m = Message() m.add_string('ssh-rsa') @@ -122,14 +121,10 @@ class RSAKey(PKey): if isinstance(key, rsa.RSAPrivateKey): key = key.public_key() - verifier = key.verifier( - signature=msg.get_binary(), - padding=padding.PKCS1v15(), - algorithm=hashes.SHA1(), - ) - verifier.update(data) try: - verifier.verify() + key.verify( + msg.get_binary(), data, padding.PKCS1v15(), hashes.SHA1() + ) except InvalidSignature: return False else: @@ -76,7 +76,7 @@ setup( ], install_requires=[ 'bcrypt>=3.1.3', - 'cryptography>=1.1', + 'cryptography>=1.5', 'pynacl>=1.0.1', 'pyasn1>=0.1.7', ], |