mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +00:00
De-duplicate code in KEXINIT generation.
There's no need to have identical code generating server-to-client and client-to-server versions of the cipher and MAC lists; a couple of twice-around loops will do fine. [originally from svn r9610]
This commit is contained in:
parent
8e0ab8be59
commit
e148dd97e3
56
ssh.c
56
ssh.c
@ -5533,7 +5533,7 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
|
|||||||
begin_key_exchange:
|
begin_key_exchange:
|
||||||
ssh->pkt_kctx = SSH2_PKTCTX_NOKEX;
|
ssh->pkt_kctx = SSH2_PKTCTX_NOKEX;
|
||||||
{
|
{
|
||||||
int i, j, commalist_started;
|
int i, j, k, commalist_started;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the preferred key exchange. (NULL => warn below here)
|
* Set up the preferred key exchange. (NULL => warn below here)
|
||||||
@ -5645,46 +5645,30 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
|
|||||||
if (i < lenof(hostkey_algs) - 1)
|
if (i < lenof(hostkey_algs) - 1)
|
||||||
ssh2_pkt_addstring_str(s->pktout, ",");
|
ssh2_pkt_addstring_str(s->pktout, ",");
|
||||||
}
|
}
|
||||||
/* List client->server encryption algorithms. */
|
/* List encryption algorithms (client->server then server->client). */
|
||||||
ssh2_pkt_addstring_start(s->pktout);
|
for (k = 0; k < 2; k++) {
|
||||||
commalist_started = 0;
|
ssh2_pkt_addstring_start(s->pktout);
|
||||||
for (i = 0; i < s->n_preferred_ciphers; i++) {
|
commalist_started = 0;
|
||||||
const struct ssh2_ciphers *c = s->preferred_ciphers[i];
|
for (i = 0; i < s->n_preferred_ciphers; i++) {
|
||||||
if (!c) continue; /* warning flag */
|
const struct ssh2_ciphers *c = s->preferred_ciphers[i];
|
||||||
for (j = 0; j < c->nciphers; j++) {
|
if (!c) continue; /* warning flag */
|
||||||
if (commalist_started)
|
for (j = 0; j < c->nciphers; j++) {
|
||||||
ssh2_pkt_addstring_str(s->pktout, ",");
|
if (commalist_started)
|
||||||
ssh2_pkt_addstring_str(s->pktout, c->list[j]->name);
|
ssh2_pkt_addstring_str(s->pktout, ",");
|
||||||
commalist_started = 1;
|
ssh2_pkt_addstring_str(s->pktout, c->list[j]->name);
|
||||||
|
commalist_started = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* List server->client encryption algorithms. */
|
/* List MAC algorithms (client->server then server->client). */
|
||||||
ssh2_pkt_addstring_start(s->pktout);
|
for (j = 0; j < 2; j++) {
|
||||||
commalist_started = 0;
|
ssh2_pkt_addstring_start(s->pktout);
|
||||||
for (i = 0; i < s->n_preferred_ciphers; i++) {
|
for (i = 0; i < s->nmacs; i++) {
|
||||||
const struct ssh2_ciphers *c = s->preferred_ciphers[i];
|
ssh2_pkt_addstring_str(s->pktout, s->maclist[i]->name);
|
||||||
if (!c) continue; /* warning flag */
|
if (i < s->nmacs - 1)
|
||||||
for (j = 0; j < c->nciphers; j++) {
|
|
||||||
if (commalist_started)
|
|
||||||
ssh2_pkt_addstring_str(s->pktout, ",");
|
ssh2_pkt_addstring_str(s->pktout, ",");
|
||||||
ssh2_pkt_addstring_str(s->pktout, c->list[j]->name);
|
|
||||||
commalist_started = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* List client->server MAC algorithms. */
|
|
||||||
ssh2_pkt_addstring_start(s->pktout);
|
|
||||||
for (i = 0; i < s->nmacs; i++) {
|
|
||||||
ssh2_pkt_addstring_str(s->pktout, s->maclist[i]->name);
|
|
||||||
if (i < s->nmacs - 1)
|
|
||||||
ssh2_pkt_addstring_str(s->pktout, ",");
|
|
||||||
}
|
|
||||||
/* List server->client MAC algorithms. */
|
|
||||||
ssh2_pkt_addstring_start(s->pktout);
|
|
||||||
for (i = 0; i < s->nmacs; i++) {
|
|
||||||
ssh2_pkt_addstring_str(s->pktout, s->maclist[i]->name);
|
|
||||||
if (i < s->nmacs - 1)
|
|
||||||
ssh2_pkt_addstring_str(s->pktout, ",");
|
|
||||||
}
|
|
||||||
/* List client->server compression algorithms,
|
/* List client->server compression algorithms,
|
||||||
* then server->client compression algorithms. (We use the
|
* then server->client compression algorithms. (We use the
|
||||||
* same set twice.) */
|
* same set twice.) */
|
||||||
|
Loading…
Reference in New Issue
Block a user