'Test that the KEXDH_INIT packet causes the server to send a
KEXDH_REPLY with the server\'s public key and a signature.
@param kexAlgorithm: The key exchange algorithm to use.
@type kexAlgorithm: L{str}'

def assertKexDHInitResponse(self, kexAlgorithm):

    self.proto.supportedKeyExchanges = [kexAlgorithm]
    self.proto.supportedPublicKeys = ['ssh-rsa']
    self.proto.dataReceived(self.transport.value())
    (g, p) = _kex.getDHGeneratorAndPrime(kexAlgorithm)
    e = pow(g, 5000, p)
    self.proto.ssh_KEX_DH_GEX_REQUEST_OLD(common.MP(e))
    y = common.getMP(('\x00\x00\x00@' + ('\x99' * 64)))[0]
    f = common._MPpow(self.proto.g, y, self.proto.p)
    sharedSecret = common._MPpow(e, y, self.proto.p)
    h = sha1()
    h.update((common.NS(self.proto.ourVersionString) * 2))
    h.update((common.NS(self.proto.ourKexInitPayload) * 2))
    h.update(common.NS(self.proto.factory.publicKeys['ssh-rsa'].blob()))
    h.update(common.MP(e))
    h.update(f)
    h.update(sharedSecret)
    exchangeHash = h.digest()
    signature = self.proto.factory.privateKeys['ssh-rsa'].sign(exchangeHash)
    self.assertEqual(self.packets, [(transport.MSG_KEXDH_REPLY, ((common.NS(self.proto.factory.publicKeys['ssh-rsa'].blob()) + f) + common.NS(signature))), (transport.MSG_NEWKEYS, '')])
