mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Reindent the section that was marked `XXX The lines below should be
reindented before this is committed'. Unfortunately not before it was committed, but you can't have everything :-) [originally from svn r7499]
This commit is contained in:
parent
dad558a1e5
commit
723d834a13
192
ssh.c
192
ssh.c
@ -5573,112 +5573,110 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ssh->kex->main_type == KEXTYPE_DH) {
|
if (ssh->kex->main_type == KEXTYPE_DH) {
|
||||||
/* XXX The lines below should be reindented before this is committed.*/
|
/*
|
||||||
/*
|
* Work out the number of bits of key we will need from the
|
||||||
* Work out the number of bits of key we will need from the key
|
* key exchange. We start with the maximum key length of
|
||||||
* exchange. We start with the maximum key length of either
|
* either cipher...
|
||||||
* cipher...
|
*/
|
||||||
*/
|
{
|
||||||
{
|
int csbits, scbits;
|
||||||
int csbits, scbits;
|
|
||||||
|
|
||||||
csbits = s->cscipher_tobe->keylen;
|
csbits = s->cscipher_tobe->keylen;
|
||||||
scbits = s->sccipher_tobe->keylen;
|
scbits = s->sccipher_tobe->keylen;
|
||||||
s->nbits = (csbits > scbits ? csbits : scbits);
|
s->nbits = (csbits > scbits ? csbits : scbits);
|
||||||
}
|
}
|
||||||
/* The keys only have hlen-bit entropy, since they're based on
|
/* The keys only have hlen-bit entropy, since they're based on
|
||||||
* a hash. So cap the key size at hlen bits. */
|
* a hash. So cap the key size at hlen bits. */
|
||||||
if (s->nbits > ssh->kex->hash->hlen * 8)
|
if (s->nbits > ssh->kex->hash->hlen * 8)
|
||||||
s->nbits = ssh->kex->hash->hlen * 8;
|
s->nbits = ssh->kex->hash->hlen * 8;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're doing Diffie-Hellman group exchange, start by
|
* If we're doing Diffie-Hellman group exchange, start by
|
||||||
* requesting a group.
|
* requesting a group.
|
||||||
*/
|
*/
|
||||||
if (!ssh->kex->pdata) {
|
if (!ssh->kex->pdata) {
|
||||||
logevent("Doing Diffie-Hellman group exchange");
|
logevent("Doing Diffie-Hellman group exchange");
|
||||||
ssh->pkt_ctx |= SSH2_PKTCTX_DHGEX;
|
ssh->pkt_ctx |= SSH2_PKTCTX_DHGEX;
|
||||||
/*
|
/*
|
||||||
* Work out how big a DH group we will need to allow that
|
* Work out how big a DH group we will need to allow that
|
||||||
* much data.
|
* much data.
|
||||||
*/
|
*/
|
||||||
s->pbits = 512 << ((s->nbits - 1) / 64);
|
s->pbits = 512 << ((s->nbits - 1) / 64);
|
||||||
s->pktout = ssh2_pkt_init(SSH2_MSG_KEX_DH_GEX_REQUEST);
|
s->pktout = ssh2_pkt_init(SSH2_MSG_KEX_DH_GEX_REQUEST);
|
||||||
ssh2_pkt_adduint32(s->pktout, s->pbits);
|
ssh2_pkt_adduint32(s->pktout, s->pbits);
|
||||||
ssh2_pkt_send_noqueue(ssh, s->pktout);
|
ssh2_pkt_send_noqueue(ssh, s->pktout);
|
||||||
|
|
||||||
crWaitUntil(pktin);
|
crWaitUntil(pktin);
|
||||||
if (pktin->type != SSH2_MSG_KEX_DH_GEX_GROUP) {
|
if (pktin->type != SSH2_MSG_KEX_DH_GEX_GROUP) {
|
||||||
bombout(("expected key exchange group packet from server"));
|
bombout(("expected key exchange group packet from server"));
|
||||||
crStop(0);
|
crStop(0);
|
||||||
}
|
}
|
||||||
s->p = ssh2_pkt_getmp(pktin);
|
s->p = ssh2_pkt_getmp(pktin);
|
||||||
s->g = ssh2_pkt_getmp(pktin);
|
s->g = ssh2_pkt_getmp(pktin);
|
||||||
if (!s->p || !s->g) {
|
if (!s->p || !s->g) {
|
||||||
bombout(("unable to read mp-ints from incoming group packet"));
|
bombout(("unable to read mp-ints from incoming group packet"));
|
||||||
crStop(0);
|
crStop(0);
|
||||||
}
|
}
|
||||||
ssh->kex_ctx = dh_setup_gex(s->p, s->g);
|
ssh->kex_ctx = dh_setup_gex(s->p, s->g);
|
||||||
s->kex_init_value = SSH2_MSG_KEX_DH_GEX_INIT;
|
s->kex_init_value = SSH2_MSG_KEX_DH_GEX_INIT;
|
||||||
s->kex_reply_value = SSH2_MSG_KEX_DH_GEX_REPLY;
|
s->kex_reply_value = SSH2_MSG_KEX_DH_GEX_REPLY;
|
||||||
} else {
|
} else {
|
||||||
ssh->pkt_ctx |= SSH2_PKTCTX_DHGROUP;
|
ssh->pkt_ctx |= SSH2_PKTCTX_DHGROUP;
|
||||||
ssh->kex_ctx = dh_setup_group(ssh->kex);
|
ssh->kex_ctx = dh_setup_group(ssh->kex);
|
||||||
s->kex_init_value = SSH2_MSG_KEXDH_INIT;
|
s->kex_init_value = SSH2_MSG_KEXDH_INIT;
|
||||||
s->kex_reply_value = SSH2_MSG_KEXDH_REPLY;
|
s->kex_reply_value = SSH2_MSG_KEXDH_REPLY;
|
||||||
logeventf(ssh, "Using Diffie-Hellman with standard group \"%s\"",
|
logeventf(ssh, "Using Diffie-Hellman with standard group \"%s\"",
|
||||||
ssh->kex->groupname);
|
ssh->kex->groupname);
|
||||||
}
|
}
|
||||||
|
|
||||||
logeventf(ssh, "Doing Diffie-Hellman key exchange with hash %s",
|
logeventf(ssh, "Doing Diffie-Hellman key exchange with hash %s",
|
||||||
ssh->kex->hash->text_name);
|
ssh->kex->hash->text_name);
|
||||||
/*
|
/*
|
||||||
* Now generate and send e for Diffie-Hellman.
|
* Now generate and send e for Diffie-Hellman.
|
||||||
*/
|
*/
|
||||||
set_busy_status(ssh->frontend, BUSY_CPU); /* this can take a while */
|
set_busy_status(ssh->frontend, BUSY_CPU); /* this can take a while */
|
||||||
s->e = dh_create_e(ssh->kex_ctx, s->nbits * 2);
|
s->e = dh_create_e(ssh->kex_ctx, s->nbits * 2);
|
||||||
s->pktout = ssh2_pkt_init(s->kex_init_value);
|
s->pktout = ssh2_pkt_init(s->kex_init_value);
|
||||||
ssh2_pkt_addmp(s->pktout, s->e);
|
ssh2_pkt_addmp(s->pktout, s->e);
|
||||||
ssh2_pkt_send_noqueue(ssh, s->pktout);
|
ssh2_pkt_send_noqueue(ssh, s->pktout);
|
||||||
|
|
||||||
set_busy_status(ssh->frontend, BUSY_WAITING); /* wait for server */
|
set_busy_status(ssh->frontend, BUSY_WAITING); /* wait for server */
|
||||||
crWaitUntil(pktin);
|
crWaitUntil(pktin);
|
||||||
if (pktin->type != s->kex_reply_value) {
|
if (pktin->type != s->kex_reply_value) {
|
||||||
bombout(("expected key exchange reply packet from server"));
|
bombout(("expected key exchange reply packet from server"));
|
||||||
crStop(0);
|
crStop(0);
|
||||||
}
|
}
|
||||||
set_busy_status(ssh->frontend, BUSY_CPU); /* cogitate */
|
set_busy_status(ssh->frontend, BUSY_CPU); /* cogitate */
|
||||||
ssh_pkt_getstring(pktin, &s->hostkeydata, &s->hostkeylen);
|
ssh_pkt_getstring(pktin, &s->hostkeydata, &s->hostkeylen);
|
||||||
s->hkey = ssh->hostkey->newkey(s->hostkeydata, s->hostkeylen);
|
s->hkey = ssh->hostkey->newkey(s->hostkeydata, s->hostkeylen);
|
||||||
s->f = ssh2_pkt_getmp(pktin);
|
s->f = ssh2_pkt_getmp(pktin);
|
||||||
if (!s->f) {
|
if (!s->f) {
|
||||||
bombout(("unable to parse key exchange reply packet"));
|
bombout(("unable to parse key exchange reply packet"));
|
||||||
crStop(0);
|
crStop(0);
|
||||||
}
|
}
|
||||||
ssh_pkt_getstring(pktin, &s->sigdata, &s->siglen);
|
ssh_pkt_getstring(pktin, &s->sigdata, &s->siglen);
|
||||||
|
|
||||||
s->K = dh_find_K(ssh->kex_ctx, s->f);
|
s->K = dh_find_K(ssh->kex_ctx, s->f);
|
||||||
|
|
||||||
/* We assume everything from now on will be quick, and it might
|
/* We assume everything from now on will be quick, and it might
|
||||||
* involve user interaction. */
|
* involve user interaction. */
|
||||||
set_busy_status(ssh->frontend, BUSY_NOT);
|
set_busy_status(ssh->frontend, BUSY_NOT);
|
||||||
|
|
||||||
hash_string(ssh->kex->hash, ssh->exhash, s->hostkeydata, s->hostkeylen);
|
hash_string(ssh->kex->hash, ssh->exhash, s->hostkeydata, s->hostkeylen);
|
||||||
if (!ssh->kex->pdata) {
|
if (!ssh->kex->pdata) {
|
||||||
hash_uint32(ssh->kex->hash, ssh->exhash, s->pbits);
|
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->p);
|
||||||
hash_mpint(ssh->kex->hash, ssh->exhash, s->g);
|
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->e);
|
||||||
hash_mpint(ssh->kex->hash, ssh->exhash, s->f);
|
hash_mpint(ssh->kex->hash, ssh->exhash, s->f);
|
||||||
|
|
||||||
dh_cleanup(ssh->kex_ctx);
|
dh_cleanup(ssh->kex_ctx);
|
||||||
freebn(s->f);
|
freebn(s->f);
|
||||||
if (!ssh->kex->pdata) {
|
if (!ssh->kex->pdata) {
|
||||||
freebn(s->g);
|
freebn(s->g);
|
||||||
freebn(s->p);
|
freebn(s->p);
|
||||||
}
|
}
|
||||||
/* XXX end incorrectly-indented section */
|
|
||||||
} else {
|
} else {
|
||||||
logeventf(ssh, "Doing RSA key exchange with hash %s",
|
logeventf(ssh, "Doing RSA key exchange with hash %s",
|
||||||
ssh->kex->hash->text_name);
|
ssh->kex->hash->text_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user