Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _process_group(self, _pkttype, _pktid, packet):
"""Process a DH gex group message"""
if self._conn.is_server():
raise ProtocolError('Unexpected kex group msg')
p = packet.get_mpint()
g = packet.get_mpint()
packet.check_end()
self._init_group(g, p)
self._gex_data += MPInt(p) + MPInt(g)
self._perform_init()
def encode_ssh_private(self):
"""Encode an SSH format DSA private key"""
if not self._key.x:
raise KeyExportError('Key is not private')
return b''.join((MPInt(self._key.p), MPInt(self._key.q),
MPInt(self._key.g), MPInt(self._key.y),
MPInt(self._key.x)))
packet.check_end()
g, p = _group1_g, _group1_p
for gex_size, gex_g, gex_p in _dh_gex_groups:
if gex_size > max_size:
break
else:
g, p = gex_g, gex_p
if gex_size >= preferred_size:
break
self._init_group(g, p)
self._gex_data += MPInt(p) + MPInt(g)
self.send_packet(self._group_type, MPInt(p), MPInt(g))
def encode_agent_cert_private(self):
"""Encode RSA certificate private key data for agent"""
if not self._key.d:
raise KeyExportError('Key is not private')
return b''.join((MPInt(self._key.d), MPInt(self._key.iqmp),
MPInt(self._key.p), MPInt(self._key.q)))
def encode_ssh_private(self):
"""Encode an SSH format RSA private key"""
if not self._key.d:
raise KeyExportError('Key is not private')
return b''.join((MPInt(self._key.n), MPInt(self._key.e),
MPInt(self._key.d), MPInt(self._key.iqmp),
MPInt(self._key.p), MPInt(self._key.q)))
def encode_agent_cert_private(self):
"""Encode RSA certificate private key data for agent"""
if not self._key.d:
raise KeyExportError('Key is not private')
return b''.join((MPInt(self._key.d), MPInt(self._key.iqmp),
MPInt(self._key.p), MPInt(self._key.q)))
def _format_server_key(self):
"""Format a DH server key"""
return MPInt(self._f)
def encode_ssh_public(self):
"""Encode an SSH format DSA public key"""
return b''.join((MPInt(self._key.p), MPInt(self._key.q),
MPInt(self._key.g), MPInt(self._key.y)))
def _compute_hash(self):
"""Compute a hash of key information associated with the connection"""
hash_obj = self._hash_alg()
hash_obj.update(self._conn.get_hash_prefix())
hash_obj.update(String(self._host_key_data))
hash_obj.update(String(self._trans_key_data))
hash_obj.update(String(self._encrypted_k))
hash_obj.update(MPInt(self._k))
return hash_obj.digest()
packet.check_end()
g, p = _group1_g, _group1_p
for gex_size, gex_g, gex_p in _dh_gex_groups:
if gex_size > max_size:
break
else:
g, p = gex_g, gex_p
if gex_size >= preferred_size:
break
self._init_group(g, p)
self._gex_data += MPInt(p) + MPInt(g)
self.send_packet(self._group_type, MPInt(p), MPInt(g))