Diff

Differences From Artifact [f1992e0130]:

To Artifact [17f0f0782f]:


4992
4993
4994
4995
4996
4997
4998
4999

5000
5001
5002
5003
5004
5005
5006
4992
4993
4994
4995
4996
4997
4998

4999
5000
5001
5002
5003
5004
5005
5006







-
+







	const struct ssh_compress *cscomp_tobe;
	const struct ssh_compress *sccomp_tobe;
	char *hostkeydata, *sigdata, *keystr, *fingerprint;
	int hostkeylen, siglen;
	void *hkey;		       /* actual host key */
	unsigned char exchange_hash[20];
	int n_preferred_kex;
	const struct ssh_kex *preferred_kex[KEX_MAX];
	const struct ssh_kexes *preferred_kex[KEX_MAX];
	int n_preferred_ciphers;
	const struct ssh2_ciphers *preferred_ciphers[CIPHER_MAX];
	const struct ssh_compress *preferred_comp;
	int got_session_id, activated_authconn;
	struct Packet *pktout;
        int dlgret;
	int guessok;
5115
5116
5117
5118
5119
5120
5121
5122

5123

5124
5125
5126
5127





5128
5129
5130
5131
5132
5133
5134
5115
5116
5117
5118
5119
5120
5121

5122
5123
5124




5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136







-
+

+
-
-
-
-
+
+
+
+
+







	s->pktout = ssh2_pkt_init(SSH2_MSG_KEXINIT);
	for (i = 0; i < 16; i++)
	    ssh2_pkt_addbyte(s->pktout, (unsigned char) random_byte());
	/* List key exchange algorithms. */
	ssh2_pkt_addstring_start(s->pktout);
	commalist_started = 0;
	for (i = 0; i < s->n_preferred_kex; i++) {
	    const struct ssh_kex *k = s->preferred_kex[i];
	    const struct ssh_kexes *k = s->preferred_kex[i];
	    if (!k) continue;	       /* warning flag */
	    for (j = 0; j < k->nkexes; j++) {
	    if (commalist_started)
		ssh2_pkt_addstring_str(s->pktout, ",");
	    ssh2_pkt_addstring_str(s->pktout, s->preferred_kex[i]->name);
	    commalist_started = 1;
		if (commalist_started)
		    ssh2_pkt_addstring_str(s->pktout, ",");
		ssh2_pkt_addstring_str(s->pktout, k->list[j]->name);
		commalist_started = 1;
	    }
	}
	/* List server host key algorithms. */
	ssh2_pkt_addstring_start(s->pktout);
	for (i = 0; i < lenof(hostkey_algs); i++) {
	    ssh2_pkt_addstring_str(s->pktout, hostkey_algs[i]->name);
	    if (i < lenof(hostkey_algs) - 1)
		ssh2_pkt_addstring_str(s->pktout, ",");
5237
5238
5239
5240
5241
5242
5243
5244

5245
5246
5247

5248
5249
5250






5251
5252
5253
5254
5255
5256
5257
5239
5240
5241
5242
5243
5244
5245

5246
5247
5248
5249
5250



5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263







-
+



+
-
-
-
+
+
+
+
+
+







	s->warn_kex = s->warn_cscipher = s->warn_sccipher = FALSE;

	pktin->savedpos += 16;	        /* skip garbage cookie */
	ssh_pkt_getstring(pktin, &str, &len);    /* key exchange algorithms */

	preferred = NULL;
	for (i = 0; i < s->n_preferred_kex; i++) {
	    const struct ssh_kex *k = s->preferred_kex[i];
	    const struct ssh_kexes *k = s->preferred_kex[i];
	    if (!k) {
		s->warn_kex = TRUE;
	    } else {
		for (j = 0; j < k->nkexes; j++) {
		if (!preferred) preferred = k->name;
		if (in_commasep_string(k->name, str, len))
		    ssh->kex = k;
		    if (!preferred) preferred = k->list[j]->name;
		    if (in_commasep_string(k->list[j]->name, str, len)) {
			ssh->kex = k->list[j];
			break;
		    }
		}
	    }
	    if (ssh->kex)
		break;
	}
	if (!ssh->kex) {
	    bombout(("Couldn't agree a key exchange algorithm (available: %s)",
		     str ? str : "(null)"));
5524
5525
5526
5527
5528
5529
5530
5531

5532
5533
5534
5535
5536
5537
5538
5530
5531
5532
5533
5534
5535
5536

5537
5538
5539
5540
5541
5542
5543
5544







-
+







    s->K = dh_find_K(ssh->kex_ctx, s->f);

    /* We assume everything from now on will be quick, and it might
     * involve user interaction. */
    set_busy_status(ssh->frontend, BUSY_NOT);

    hash_string(ssh->kex->hash, ssh->exhash, s->hostkeydata, s->hostkeylen);
    if (ssh->kex == &ssh_diffiehellman_gex) {
    if (!ssh->kex->pdata) {
	hash_uint32(ssh->kex->hash, ssh->exhash, s->pbits);
	hash_mpint(ssh->kex->hash, ssh->exhash, s->p);
	hash_mpint(ssh->kex->hash, ssh->exhash, s->g);
    }
    hash_mpint(ssh->kex->hash, ssh->exhash, s->e);
    hash_mpint(ssh->kex->hash, ssh->exhash, s->f);
    hash_mpint(ssh->kex->hash, ssh->exhash, s->K);
5713
5714
5715
5716
5717
5718
5719
5720

5721
5722
5723
5724
5725
5726
5727
5719
5720
5721
5722
5723
5724
5725

5726
5727
5728
5729
5730
5731
5732
5733







-
+







		  ssh->sccomp->text_name);

    /*
     * Free key exchange data.
     */
    freebn(s->f);
    freebn(s->K);
    if (ssh->kex == &ssh_diffiehellman_gex) {
    if (!ssh->kex->pdata) {
	freebn(s->g);
	freebn(s->p);
    }

    /*
     * Key exchange is over. Loop straight back round if we have a
     * deferred rekey reason.