]> andersk Git - gssapi-openssh.git/blobdiff - openssh/kex.c
merged OpenSSH 5.2p1 to trunk
[gssapi-openssh.git] / openssh / kex.c
index ea5d9acfecebfb456234a34bf422d39f1746c996..38db004c4dc4f0a570adf76c8379c00e36d2a087 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: kex.c,v 1.77 2007/01/21 01:41:54 stevesk Exp $ */
+/* $OpenBSD: kex.c,v 1.80 2008/09/06 12:24:13 djm Exp $ */
 /*
  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
  *
@@ -48,6 +48,7 @@
 #include "match.h"
 #include "dispatch.h"
 #include "monitor.h"
+#include "canohost.h"
 
 #ifdef GSSAPI
 #include "ssh-gss.h"
@@ -68,6 +69,7 @@ static void kex_kexinit_finish(Kex *);
 static void kex_choose_conf(Kex *);
 
 /* put algorithm proposal into buffer */
+/* used in sshconnect.c as well as kex.c */
 void
 kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
 {
@@ -91,7 +93,7 @@ static char **
 kex_buf2prop(Buffer *raw, int *first_kex_follows)
 {
        Buffer b;
-       int i;
+       u_int i;
        char **proposal;
 
        proposal = xcalloc(PROPOSAL_MAX, sizeof(char *));
@@ -112,7 +114,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows)
                *first_kex_follows = i;
        debug2("kex_parse_kexinit: first_kex_follows %d ", i);
        i = buffer_get_int(&b);
-       debug2("kex_parse_kexinit: reserved %d ", i);
+       debug2("kex_parse_kexinit: reserved %u ", i);
        buffer_free(&b);
        return proposal;
 }
@@ -127,6 +129,7 @@ kex_prop_free(char **proposal)
        xfree(proposal);
 }
 
+/* ARGSUSED */
 static void
 kex_protocol_error(int type, u_int32_t seq, void *ctxt)
 {
@@ -198,6 +201,7 @@ kex_send_kexinit(Kex *kex)
        kex->flags |= KEX_INIT_SENT;
 }
 
+/* ARGSUSED */
 void
 kex_input_kexinit(int type, u_int32_t seq, void *ctxt)
 {
@@ -262,7 +266,8 @@ choose_enc(Enc *enc, char *client, char *server)
 {
        char *name = match_list(client, server, NULL);
        if (name == NULL)
-               fatal("no matching cipher found: client %s server %s", client, server);
+               fatal("no matching cipher found: client %s server %s",
+                   client, server);
        if ((enc->cipher = cipher_by_name(name)) == NULL)
                fatal("matching cipher is not supported: %s", name);
        enc->name = name;
@@ -278,8 +283,9 @@ choose_mac(Mac *mac, char *client, char *server)
 {
        char *name = match_list(client, server, NULL);
        if (name == NULL)
-               fatal("no matching mac found: client %s server %s", client, server);
-       if (mac_init(mac, name) < 0)
+               fatal("no matching mac found: client %s server %s",
+                   client, server);
+       if (mac_setup(mac, name) < 0)
                fatal("unsupported mac %s", name);
        /* truncate the key */
        if (datafellows & SSH_BUG_HMAC)
@@ -312,7 +318,7 @@ choose_kex(Kex *k, char *client, char *server)
 {
        k->name = match_list(client, server, NULL);
        if (k->name == NULL)
-               fatal("no kex alg");
+               fatal("Unable to negotiate a key exchange method");
        if (strcmp(k->name, KEX_DH1) == 0) {
                k->kex_type = KEX_DH_GRP1_SHA1;
                k->evp_md = EVP_sha1();
@@ -390,6 +396,13 @@ kex_choose_conf(Kex *kex)
        int nenc, nmac, ncomp;
        u_int mode, ctos, need;
        int first_kex_follows, type;
+       int log_flag = 0;
+
+       int auth_flag;
+
+       auth_flag = packet_authentication_state();
+
+       debug ("AUTH STATE IS %d", auth_flag);
 
        my   = kex_buf2prop(&kex->my, NULL);
        peer = kex_buf2prop(&kex->peer, &first_kex_follows);
@@ -406,18 +419,42 @@ kex_choose_conf(Kex *kex)
        for (mode = 0; mode < MODE_MAX; mode++) {
                newkeys = xcalloc(1, sizeof(*newkeys));
                kex->newkeys[mode] = newkeys;
-               ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN);
+               ctos = (!kex->server && mode == MODE_OUT) ||
+                   (kex->server && mode == MODE_IN);
                nenc  = ctos ? PROPOSAL_ENC_ALGS_CTOS  : PROPOSAL_ENC_ALGS_STOC;
                nmac  = ctos ? PROPOSAL_MAC_ALGS_CTOS  : PROPOSAL_MAC_ALGS_STOC;
                ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC;
                choose_enc (&newkeys->enc,  cprop[nenc],  sprop[nenc]);
                choose_mac (&newkeys->mac,  cprop[nmac],  sprop[nmac]);
                choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]);
+               debug("REQUESTED ENC.NAME is '%s'", newkeys->enc.name);
+               if (strcmp(newkeys->enc.name, "none") == 0) {
+                               debug("Requesting NONE. Authflag is %d", auth_flag);                    
+                       if (auth_flag == 1) {
+                               debug("None requested post authentication.");
+                       } else {
+                               fatal("Pre-authentication none cipher requests are not allowed.");
+                       }
+               } 
                debug("kex: %s %s %s %s",
                    ctos ? "client->server" : "server->client",
                    newkeys->enc.name,
                    newkeys->mac.name,
                    newkeys->comp.name);
+               /* client starts withctos = 0 && log flag = 0 and no log*/
+               /* 2nd client pass ctos=1 and flag = 1 so no log*/
+               /* server starts with ctos =1 && log_flag = 0 so log */
+               /* 2nd sever pass ctos = 1 && log flag = 1 so no log*/
+               /* -cjr*/
+               if (ctos && !log_flag) {
+                       logit("SSH: Server;Ltype: Kex;Remote: %s-%d;Enc: %s;MAC: %s;Comp: %s",
+                             get_remote_ipaddr(),
+                             get_remote_port(),
+                             newkeys->enc.name,
+                             newkeys->mac.name,
+                             newkeys->comp.name);
+               }
+               log_flag = 1;
        }
        choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]);
        choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
This page took 0.03599 seconds and 4 git commands to generate.