diff options
author | Colin Watson <cjwatson@debian.org> | 2013-05-07 10:06:42 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2013-05-07 10:06:42 +0100 |
commit | ecebda56da46a03dafff923d91c382f31faa9eec (patch) | |
tree | 449614b6c06a2622c74a609b31fcc46c60037c56 /kex.c | |
parent | c6a2c0334e45419875687d250aed9bea78480f2e (diff) | |
parent | ffc06452028ba78cd693d4ed43df8b60a10d6163 (diff) |
merge 6.2p1; reorder additions to monitor.h for easier merging in future
Diffstat (limited to 'kex.c')
-rw-r--r-- | kex.c | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: kex.c,v 1.86 2010/09/22 05:01:29 djm Exp $ */ | 1 | /* $OpenBSD: kex.c,v 1.88 2013/01/08 18:49:04 markus 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 | * |
@@ -246,8 +246,18 @@ kex_input_kexinit(int type, u_int32_t seq, void *ctxt) | |||
246 | packet_get_char(); | 246 | packet_get_char(); |
247 | for (i = 0; i < PROPOSAL_MAX; i++) | 247 | for (i = 0; i < PROPOSAL_MAX; i++) |
248 | xfree(packet_get_string(NULL)); | 248 | xfree(packet_get_string(NULL)); |
249 | (void) packet_get_char(); | 249 | /* |
250 | (void) packet_get_int(); | 250 | * XXX RFC4253 sec 7: "each side MAY guess" - currently no supported |
251 | * KEX method has the server move first, but a server might be using | ||
252 | * a custom method or one that we otherwise don't support. We should | ||
253 | * be prepared to remember first_kex_follows here so we can eat a | ||
254 | * packet later. | ||
255 | * XXX2 - RFC4253 is kind of ambiguous on what first_kex_follows means | ||
256 | * for cases where the server *doesn't* go first. I guess we should | ||
257 | * ignore it when it is set for these cases, which is what we do now. | ||
258 | */ | ||
259 | (void) packet_get_char(); /* first_kex_follows */ | ||
260 | (void) packet_get_int(); /* reserved */ | ||
251 | packet_check_eom(); | 261 | packet_check_eom(); |
252 | 262 | ||
253 | kex_kexinit_finish(kex); | 263 | kex_kexinit_finish(kex); |
@@ -298,6 +308,7 @@ choose_enc(Enc *enc, char *client, char *server) | |||
298 | enc->name = name; | 308 | enc->name = name; |
299 | enc->enabled = 0; | 309 | enc->enabled = 0; |
300 | enc->iv = NULL; | 310 | enc->iv = NULL; |
311 | enc->iv_len = cipher_ivlen(enc->cipher); | ||
301 | enc->key = NULL; | 312 | enc->key = NULL; |
302 | enc->key_len = cipher_keylen(enc->cipher); | 313 | enc->key_len = cipher_keylen(enc->cipher); |
303 | enc->block_size = cipher_blocksize(enc->cipher); | 314 | enc->block_size = cipher_blocksize(enc->cipher); |
@@ -423,7 +434,7 @@ kex_choose_conf(Kex *kex) | |||
423 | char **my, **peer; | 434 | char **my, **peer; |
424 | char **cprop, **sprop; | 435 | char **cprop, **sprop; |
425 | int nenc, nmac, ncomp; | 436 | int nenc, nmac, ncomp; |
426 | u_int mode, ctos, need; | 437 | u_int mode, ctos, need, authlen; |
427 | int first_kex_follows, type; | 438 | int first_kex_follows, type; |
428 | 439 | ||
429 | my = kex_buf2prop(&kex->my, NULL); | 440 | my = kex_buf2prop(&kex->my, NULL); |
@@ -456,13 +467,16 @@ kex_choose_conf(Kex *kex) | |||
456 | nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; | 467 | nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; |
457 | nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC; | 468 | nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC; |
458 | ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC; | 469 | ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC; |
459 | choose_enc (&newkeys->enc, cprop[nenc], sprop[nenc]); | 470 | choose_enc(&newkeys->enc, cprop[nenc], sprop[nenc]); |
460 | choose_mac (&newkeys->mac, cprop[nmac], sprop[nmac]); | 471 | /* ignore mac for authenticated encryption */ |
472 | authlen = cipher_authlen(newkeys->enc.cipher); | ||
473 | if (authlen == 0) | ||
474 | choose_mac(&newkeys->mac, cprop[nmac], sprop[nmac]); | ||
461 | choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]); | 475 | choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]); |
462 | debug("kex: %s %s %s %s", | 476 | debug("kex: %s %s %s %s", |
463 | ctos ? "client->server" : "server->client", | 477 | ctos ? "client->server" : "server->client", |
464 | newkeys->enc.name, | 478 | newkeys->enc.name, |
465 | newkeys->mac.name, | 479 | authlen == 0 ? newkeys->mac.name : "<implicit>", |
466 | newkeys->comp.name); | 480 | newkeys->comp.name); |
467 | } | 481 | } |
468 | choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]); | 482 | choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]); |
@@ -475,6 +489,8 @@ kex_choose_conf(Kex *kex) | |||
475 | need = newkeys->enc.key_len; | 489 | need = newkeys->enc.key_len; |
476 | if (need < newkeys->enc.block_size) | 490 | if (need < newkeys->enc.block_size) |
477 | need = newkeys->enc.block_size; | 491 | need = newkeys->enc.block_size; |
492 | if (need < newkeys->enc.iv_len) | ||
493 | need = newkeys->enc.iv_len; | ||
478 | if (need < newkeys->mac.key_len) | 494 | if (need < newkeys->mac.key_len) |
479 | need = newkeys->mac.key_len; | 495 | need = newkeys->mac.key_len; |
480 | } | 496 | } |