diff options
author | Christopher Baines <mail@cbaines.net> | 2016-02-07 21:19:28 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2016-02-07 21:19:28 +0000 |
commit | 8a563e44d42731143f4356edcad0d7469a56ea24 (patch) | |
tree | 4641e9608e76b130ea6afe467a30202494ef0eeb /paramiko/kex_gex.py | |
parent | bbf74c0dbf66c463bd68bd30abcd338796152354 (diff) | |
parent | 31b2fd0709f259961253b9cdc875ce7827abaa68 (diff) | |
download | python-paramiko-8a563e44d42731143f4356edcad0d7469a56ea24.tar python-paramiko-8a563e44d42731143f4356edcad0d7469a56ea24.tar.gz |
Merge tag 'upstream/1.16.0'
Upstream version 1.16.0
Diffstat (limited to 'paramiko/kex_gex.py')
-rw-r--r-- | paramiko/kex_gex.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/paramiko/kex_gex.py b/paramiko/kex_gex.py index cb548f3..c980b69 100644 --- a/paramiko/kex_gex.py +++ b/paramiko/kex_gex.py @@ -23,7 +23,7 @@ client side, and a **lot** more on the server side. """ import os -from hashlib import sha1 +from hashlib import sha1, sha256 from paramiko import util from paramiko.common import DEBUG @@ -44,6 +44,7 @@ class KexGex (object): min_bits = 1024 max_bits = 8192 preferred_bits = 2048 + hash_algo = sha1 def __init__(self, transport): self.transport = transport @@ -87,7 +88,7 @@ class KexGex (object): return self._parse_kexdh_gex_reply(m) elif ptype == _MSG_KEXDH_GEX_REQUEST_OLD: return self._parse_kexdh_gex_request_old(m) - raise SSHException('KexGex asked to handle packet type %d' % ptype) + raise SSHException('KexGex %s asked to handle packet type %d' % self.name, ptype) ### internals... @@ -204,7 +205,7 @@ class KexGex (object): hm.add_mpint(self.e) hm.add_mpint(self.f) hm.add_mpint(K) - H = sha1(hm.asbytes()).digest() + H = self.hash_algo(hm.asbytes()).digest() self.transport._set_K_H(K, H) # sign it sig = self.transport.get_server_key().sign_ssh_data(H) @@ -239,6 +240,10 @@ class KexGex (object): hm.add_mpint(self.e) hm.add_mpint(self.f) hm.add_mpint(K) - self.transport._set_K_H(K, sha1(hm.asbytes()).digest()) + self.transport._set_K_H(K, self.hash_algo(hm.asbytes()).digest()) self.transport._verify_key(host_key, sig) self.transport._activate_outbound() + +class KexGexSHA256(KexGex): + name = 'diffie-hellman-group-exchange-sha256' + hash_algo = sha256 |