Reindent the section that was marked `XXX The lines below should be
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 1 May 2007 12:26:44 +0000 (12:26 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 1 May 2007 12:26:44 +0000 (12:26 +0000)
reindented before this is committed'. Unfortunately not before it
was committed, but you can't have everything :-)

git-svn-id: svn://svn.tartarus.org/sgt/putty@7499 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index 64a069e..21fcd2d 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -5573,112 +5573,110 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
     }
 
     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 key
-     * exchange. We start with the maximum key length of either
-     * cipher...
-     */
-    {
-       int csbits, scbits;
-
-       csbits = s->cscipher_tobe->keylen;
-       scbits = s->sccipher_tobe->keylen;
-       s->nbits = (csbits > scbits ? csbits : scbits);
-    }
-    /* The keys only have hlen-bit entropy, since they're based on
-     * a hash. So cap the key size at hlen bits. */
-    if (s->nbits > ssh->kex->hash->hlen * 8)
-       s->nbits = ssh->kex->hash->hlen * 8;
+        /*
+         * Work out the number of bits of key we will need from the
+         * key exchange. We start with the maximum key length of
+         * either cipher...
+         */
+        {
+            int csbits, scbits;
 
-    /*
-     * If we're doing Diffie-Hellman group exchange, start by
-     * requesting a group.
-     */
-    if (!ssh->kex->pdata) {
-       logevent("Doing Diffie-Hellman group exchange");
-       ssh->pkt_ctx |= SSH2_PKTCTX_DHGEX;
-       /*
-        * Work out how big a DH group we will need to allow that
-        * much data.
-        */
-       s->pbits = 512 << ((s->nbits - 1) / 64);
-       s->pktout = ssh2_pkt_init(SSH2_MSG_KEX_DH_GEX_REQUEST);
-       ssh2_pkt_adduint32(s->pktout, s->pbits);
-       ssh2_pkt_send_noqueue(ssh, s->pktout);
+            csbits = s->cscipher_tobe->keylen;
+            scbits = s->sccipher_tobe->keylen;
+            s->nbits = (csbits > scbits ? csbits : scbits);
+        }
+        /* The keys only have hlen-bit entropy, since they're based on
+         * a hash. So cap the key size at hlen bits. */
+        if (s->nbits > ssh->kex->hash->hlen * 8)
+            s->nbits = ssh->kex->hash->hlen * 8;
 
-       crWaitUntil(pktin);
-       if (pktin->type != SSH2_MSG_KEX_DH_GEX_GROUP) {
-           bombout(("expected key exchange group packet from server"));
-           crStop(0);
-       }
-       s->p = ssh2_pkt_getmp(pktin);
-       s->g = ssh2_pkt_getmp(pktin);
-       if (!s->p || !s->g) {
-           bombout(("unable to read mp-ints from incoming group packet"));
-           crStop(0);
-       }
-       ssh->kex_ctx = dh_setup_gex(s->p, s->g);
-       s->kex_init_value = SSH2_MSG_KEX_DH_GEX_INIT;
-       s->kex_reply_value = SSH2_MSG_KEX_DH_GEX_REPLY;
-    } else {
-       ssh->pkt_ctx |= SSH2_PKTCTX_DHGROUP;
-       ssh->kex_ctx = dh_setup_group(ssh->kex);
-       s->kex_init_value = SSH2_MSG_KEXDH_INIT;
-       s->kex_reply_value = SSH2_MSG_KEXDH_REPLY;
-       logeventf(ssh, "Using Diffie-Hellman with standard group \"%s\"",
-                 ssh->kex->groupname);
-    }
+        /*
+         * If we're doing Diffie-Hellman group exchange, start by
+         * requesting a group.
+         */
+        if (!ssh->kex->pdata) {
+            logevent("Doing Diffie-Hellman group exchange");
+            ssh->pkt_ctx |= SSH2_PKTCTX_DHGEX;
+            /*
+             * Work out how big a DH group we will need to allow that
+             * much data.
+             */
+            s->pbits = 512 << ((s->nbits - 1) / 64);
+            s->pktout = ssh2_pkt_init(SSH2_MSG_KEX_DH_GEX_REQUEST);
+            ssh2_pkt_adduint32(s->pktout, s->pbits);
+            ssh2_pkt_send_noqueue(ssh, s->pktout);
 
-    logeventf(ssh, "Doing Diffie-Hellman key exchange with hash %s",
-             ssh->kex->hash->text_name);
-    /*
-     * Now generate and send e for Diffie-Hellman.
-     */
-    set_busy_status(ssh->frontend, BUSY_CPU); /* this can take a while */
-    s->e = dh_create_e(ssh->kex_ctx, s->nbits * 2);
-    s->pktout = ssh2_pkt_init(s->kex_init_value);
-    ssh2_pkt_addmp(s->pktout, s->e);
-    ssh2_pkt_send_noqueue(ssh, s->pktout);
+            crWaitUntil(pktin);
+            if (pktin->type != SSH2_MSG_KEX_DH_GEX_GROUP) {
+                bombout(("expected key exchange group packet from server"));
+                crStop(0);
+            }
+            s->p = ssh2_pkt_getmp(pktin);
+            s->g = ssh2_pkt_getmp(pktin);
+            if (!s->p || !s->g) {
+                bombout(("unable to read mp-ints from incoming group packet"));
+                crStop(0);
+            }
+            ssh->kex_ctx = dh_setup_gex(s->p, s->g);
+            s->kex_init_value = SSH2_MSG_KEX_DH_GEX_INIT;
+            s->kex_reply_value = SSH2_MSG_KEX_DH_GEX_REPLY;
+        } else {
+            ssh->pkt_ctx |= SSH2_PKTCTX_DHGROUP;
+            ssh->kex_ctx = dh_setup_group(ssh->kex);
+            s->kex_init_value = SSH2_MSG_KEXDH_INIT;
+            s->kex_reply_value = SSH2_MSG_KEXDH_REPLY;
+            logeventf(ssh, "Using Diffie-Hellman with standard group \"%s\"",
+                      ssh->kex->groupname);
+        }
 
-    set_busy_status(ssh->frontend, BUSY_WAITING); /* wait for server */
-    crWaitUntil(pktin);
-    if (pktin->type != s->kex_reply_value) {
-       bombout(("expected key exchange reply packet from server"));
-       crStop(0);
-    }
-    set_busy_status(ssh->frontend, BUSY_CPU); /* cogitate */
-    ssh_pkt_getstring(pktin, &s->hostkeydata, &s->hostkeylen);
-    s->hkey = ssh->hostkey->newkey(s->hostkeydata, s->hostkeylen);
-    s->f = ssh2_pkt_getmp(pktin);
-    if (!s->f) {
-       bombout(("unable to parse key exchange reply packet"));
-       crStop(0);
-    }
-    ssh_pkt_getstring(pktin, &s->sigdata, &s->siglen);
+        logeventf(ssh, "Doing Diffie-Hellman key exchange with hash %s",
+                  ssh->kex->hash->text_name);
+        /*
+         * Now generate and send e for Diffie-Hellman.
+         */
+        set_busy_status(ssh->frontend, BUSY_CPU); /* this can take a while */
+        s->e = dh_create_e(ssh->kex_ctx, s->nbits * 2);
+        s->pktout = ssh2_pkt_init(s->kex_init_value);
+        ssh2_pkt_addmp(s->pktout, s->e);
+        ssh2_pkt_send_noqueue(ssh, s->pktout);
 
-    s->K = dh_find_K(ssh->kex_ctx, s->f);
+        set_busy_status(ssh->frontend, BUSY_WAITING); /* wait for server */
+        crWaitUntil(pktin);
+        if (pktin->type != s->kex_reply_value) {
+            bombout(("expected key exchange reply packet from server"));
+            crStop(0);
+        }
+        set_busy_status(ssh->frontend, BUSY_CPU); /* cogitate */
+        ssh_pkt_getstring(pktin, &s->hostkeydata, &s->hostkeylen);
+        s->hkey = ssh->hostkey->newkey(s->hostkeydata, s->hostkeylen);
+        s->f = ssh2_pkt_getmp(pktin);
+        if (!s->f) {
+            bombout(("unable to parse key exchange reply packet"));
+            crStop(0);
+        }
+        ssh_pkt_getstring(pktin, &s->sigdata, &s->siglen);
 
-    /* We assume everything from now on will be quick, and it might
-     * involve user interaction. */
-    set_busy_status(ssh->frontend, BUSY_NOT);
+        s->K = dh_find_K(ssh->kex_ctx, s->f);
 
-    hash_string(ssh->kex->hash, ssh->exhash, s->hostkeydata, s->hostkeylen);
-    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);
+        /* We assume everything from now on will be quick, and it might
+         * involve user interaction. */
+        set_busy_status(ssh->frontend, BUSY_NOT);
 
-    dh_cleanup(ssh->kex_ctx);
-    freebn(s->f);
-    if (!ssh->kex->pdata) {
-        freebn(s->g);
-       freebn(s->p);
-    }
-        /* XXX end incorrectly-indented section */
+        hash_string(ssh->kex->hash, ssh->exhash, s->hostkeydata, s->hostkeylen);
+        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);
+
+        dh_cleanup(ssh->kex_ctx);
+        freebn(s->f);
+        if (!ssh->kex->pdata) {
+            freebn(s->g);
+            freebn(s->p);
+        }
     } else {
        logeventf(ssh, "Doing RSA key exchange with hash %s",
                  ssh->kex->hash->text_name);