'Called when we receive a MSG_KEXINIT message.  For a description
of the packet, see SSHTransportBase.ssh_KEXINIT().  Additionally,
this method sends the first key exchange packet.
If the agreed-upon exchange is ECDH, generate a key pair for the
corresponding curve and send the public key.
If the agreed-upon exchange has a fixed prime/generator group,
generate a public key and send it in a MSG_KEXDH_INIT message.
Otherwise, ask for a 2048 bit group with a MSG_KEX_DH_GEX_REQUEST
message.'

def ssh_KEXINIT(self, packet):

    if (SSHTransportBase.ssh_KEXINIT(self, packet) is None):
        return
    if _kex.isEllipticCurve(self.kexAlg):
        self.curve = keys._curveTable[('ecdsa' + self.kexAlg[4:])]
        self.ecPriv = ec.generate_private_key(self.curve, default_backend())
        self.ecPub = self.ecPriv.public_key()
        self.sendPacket(MSG_KEX_DH_GEX_REQUEST_OLD, NS(self.ecPub.public_numbers().encode_point()))
    elif _kex.isFixedGroup(self.kexAlg):
        self.x = _generateX(randbytes.secureRandom, 512)
        (self.g, self.p) = _kex.getDHGeneratorAndPrime(self.kexAlg)
        self.e = _MPpow(self.g, self.x, self.p)
        self.sendPacket(MSG_KEXDH_INIT, self.e)
    else:
        self.sendPacket(MSG_KEX_DH_GEX_REQUEST, struct.pack('!LLL', self._dhMinimalGroupSize, self._dhPreferredGroupSize, self._dhMaximalGroupSize))
