'Called from L{ssh_KEX_DH_GEX_REQUEST_OLD} to handle
elliptic curve key exchanges.
Payload::
string client Elliptic Curve Diffie-Hellman public key
Just like L{_ssh_KEXDH_INIT} this message type is also not dispatched
directly. Extra check to determine if this is really KEX_ECDH_INIT
is required.
First we load the host\'s public/private keys.
Then we generate the ECDH public/private keypair for the given curve.
With that we generate the shared secret key.
Then we compute the hash to sign and send back to the client
Along with the server\'s public key and the ECDH public key.
@type packet: L{bytes}
@param packet: The message data.
@return: None.'

def _ssh_KEX_ECDH_INIT(self, packet):

    (pktPub, packet) = getNS(packet)
    pubHostKey = self.factory.publicKeys[self.keyAlg]
    privHostKey = self.factory.privateKeys[self.keyAlg]
    try:
        curve = keys._curveTable[('ecdsa' + self.kexAlg[4:])]
    except KeyError:
        raise UnsupportedAlgorithm('unused-key')
    ecPriv = ec.generate_private_key(curve, default_backend())
    ecPub = ecPriv.public_key()
    encPub = ecPub.public_numbers().encode_point()
    theirECPub = ec.EllipticCurvePublicNumbers.from_encoded_point(curve, pktPub).public_key(default_backend())
    sharedSecret = MP(int(binascii.hexlify(ecPriv.exchange(ec.ECDH(), theirECPub)), 16))
    h = _kex.getHashProcessor(self.kexAlg)()
    h.update(NS(self.otherVersionString))
    h.update(NS(self.ourVersionString))
    h.update(NS(self.otherKexInitPayload))
    h.update(NS(self.ourKexInitPayload))
    h.update(NS(pubHostKey.blob()))
    h.update(NS(pktPub))
    h.update(NS(encPub))
    h.update(sharedSecret)
    exchangeHash = h.digest()
    self.sendPacket(MSG_KEXDH_REPLY, ((NS(pubHostKey.blob()) + NS(encPub)) + NS(privHostKey.sign(exchangeHash))))
    self._keySetup(sharedSecret, exchangeHash)
