summaryrefslogtreecommitdiff
path: root/kex.c
diff options
context:
space:
mode:
Diffstat (limited to 'kex.c')
-rw-r--r--kex.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/kex.c b/kex.c
index b2223c5ff..ad2e93cc1 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.c,v 1.77 2007/01/21 01:41:54 stevesk Exp $ */ 1/* $OpenBSD: kex.c,v 1.78 2007/05/30 05:58:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -87,7 +87,7 @@ static char **
87kex_buf2prop(Buffer *raw, int *first_kex_follows) 87kex_buf2prop(Buffer *raw, int *first_kex_follows)
88{ 88{
89 Buffer b; 89 Buffer b;
90 int i; 90 u_int i;
91 char **proposal; 91 char **proposal;
92 92
93 proposal = xcalloc(PROPOSAL_MAX, sizeof(char *)); 93 proposal = xcalloc(PROPOSAL_MAX, sizeof(char *));
@@ -108,7 +108,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows)
108 *first_kex_follows = i; 108 *first_kex_follows = i;
109 debug2("kex_parse_kexinit: first_kex_follows %d ", i); 109 debug2("kex_parse_kexinit: first_kex_follows %d ", i);
110 i = buffer_get_int(&b); 110 i = buffer_get_int(&b);
111 debug2("kex_parse_kexinit: reserved %d ", i); 111 debug2("kex_parse_kexinit: reserved %u ", i);
112 buffer_free(&b); 112 buffer_free(&b);
113 return proposal; 113 return proposal;
114} 114}
@@ -123,6 +123,7 @@ kex_prop_free(char **proposal)
123 xfree(proposal); 123 xfree(proposal);
124} 124}
125 125
126/* ARGSUSED */
126static void 127static void
127kex_protocol_error(int type, u_int32_t seq, void *ctxt) 128kex_protocol_error(int type, u_int32_t seq, void *ctxt)
128{ 129{
@@ -194,6 +195,7 @@ kex_send_kexinit(Kex *kex)
194 kex->flags |= KEX_INIT_SENT; 195 kex->flags |= KEX_INIT_SENT;
195} 196}
196 197
198/* ARGSUSED */
197void 199void
198kex_input_kexinit(int type, u_int32_t seq, void *ctxt) 200kex_input_kexinit(int type, u_int32_t seq, void *ctxt)
199{ 201{
@@ -258,7 +260,8 @@ choose_enc(Enc *enc, char *client, char *server)
258{ 260{
259 char *name = match_list(client, server, NULL); 261 char *name = match_list(client, server, NULL);
260 if (name == NULL) 262 if (name == NULL)
261 fatal("no matching cipher found: client %s server %s", client, server); 263 fatal("no matching cipher found: client %s server %s",
264 client, server);
262 if ((enc->cipher = cipher_by_name(name)) == NULL) 265 if ((enc->cipher = cipher_by_name(name)) == NULL)
263 fatal("matching cipher is not supported: %s", name); 266 fatal("matching cipher is not supported: %s", name);
264 enc->name = name; 267 enc->name = name;
@@ -274,7 +277,8 @@ choose_mac(Mac *mac, char *client, char *server)
274{ 277{
275 char *name = match_list(client, server, NULL); 278 char *name = match_list(client, server, NULL);
276 if (name == NULL) 279 if (name == NULL)
277 fatal("no matching mac found: client %s server %s", client, server); 280 fatal("no matching mac found: client %s server %s",
281 client, server);
278 if (mac_init(mac, name) < 0) 282 if (mac_init(mac, name) < 0)
279 fatal("unsupported mac %s", name); 283 fatal("unsupported mac %s", name);
280 /* truncate the key */ 284 /* truncate the key */
@@ -308,7 +312,7 @@ choose_kex(Kex *k, char *client, char *server)
308{ 312{
309 k->name = match_list(client, server, NULL); 313 k->name = match_list(client, server, NULL);
310 if (k->name == NULL) 314 if (k->name == NULL)
311 fatal("no kex alg"); 315 fatal("Unable to negotiate a key exchange method");
312 if (strcmp(k->name, KEX_DH1) == 0) { 316 if (strcmp(k->name, KEX_DH1) == 0) {
313 k->kex_type = KEX_DH_GRP1_SHA1; 317 k->kex_type = KEX_DH_GRP1_SHA1;
314 k->evp_md = EVP_sha1(); 318 k->evp_md = EVP_sha1();
@@ -388,7 +392,8 @@ kex_choose_conf(Kex *kex)
388 for (mode = 0; mode < MODE_MAX; mode++) { 392 for (mode = 0; mode < MODE_MAX; mode++) {
389 newkeys = xcalloc(1, sizeof(*newkeys)); 393 newkeys = xcalloc(1, sizeof(*newkeys));
390 kex->newkeys[mode] = newkeys; 394 kex->newkeys[mode] = newkeys;
391 ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN); 395 ctos = (!kex->server && mode == MODE_OUT) ||
396 (kex->server && mode == MODE_IN);
392 nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; 397 nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC;
393 nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC; 398 nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC;
394 ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC; 399 ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC;