diff options
Diffstat (limited to 'kex.c')
-rw-r--r-- | kex.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: kex.c,v 1.87 2012/08/17 01:22:56 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 | * |
@@ -304,6 +304,7 @@ choose_enc(Enc *enc, char *client, char *server) | |||
304 | enc->name = name; | 304 | enc->name = name; |
305 | enc->enabled = 0; | 305 | enc->enabled = 0; |
306 | enc->iv = NULL; | 306 | enc->iv = NULL; |
307 | enc->iv_len = cipher_ivlen(enc->cipher); | ||
307 | enc->key = NULL; | 308 | enc->key = NULL; |
308 | enc->key_len = cipher_keylen(enc->cipher); | 309 | enc->key_len = cipher_keylen(enc->cipher); |
309 | enc->block_size = cipher_blocksize(enc->cipher); | 310 | enc->block_size = cipher_blocksize(enc->cipher); |
@@ -415,7 +416,7 @@ kex_choose_conf(Kex *kex) | |||
415 | char **my, **peer; | 416 | char **my, **peer; |
416 | char **cprop, **sprop; | 417 | char **cprop, **sprop; |
417 | int nenc, nmac, ncomp; | 418 | int nenc, nmac, ncomp; |
418 | u_int mode, ctos, need; | 419 | u_int mode, ctos, need, authlen; |
419 | int first_kex_follows, type; | 420 | int first_kex_follows, type; |
420 | 421 | ||
421 | my = kex_buf2prop(&kex->my, NULL); | 422 | my = kex_buf2prop(&kex->my, NULL); |
@@ -448,13 +449,16 @@ kex_choose_conf(Kex *kex) | |||
448 | nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; | 449 | nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; |
449 | nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC; | 450 | nmac = ctos ? PROPOSAL_MAC_ALGS_CTOS : PROPOSAL_MAC_ALGS_STOC; |
450 | ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC; | 451 | ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC; |
451 | choose_enc (&newkeys->enc, cprop[nenc], sprop[nenc]); | 452 | choose_enc(&newkeys->enc, cprop[nenc], sprop[nenc]); |
452 | choose_mac (&newkeys->mac, cprop[nmac], sprop[nmac]); | 453 | /* ignore mac for authenticated encryption */ |
454 | authlen = cipher_authlen(newkeys->enc.cipher); | ||
455 | if (authlen == 0) | ||
456 | choose_mac(&newkeys->mac, cprop[nmac], sprop[nmac]); | ||
453 | choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]); | 457 | choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]); |
454 | debug("kex: %s %s %s %s", | 458 | debug("kex: %s %s %s %s", |
455 | ctos ? "client->server" : "server->client", | 459 | ctos ? "client->server" : "server->client", |
456 | newkeys->enc.name, | 460 | newkeys->enc.name, |
457 | newkeys->mac.name, | 461 | authlen == 0 ? newkeys->mac.name : "<implicit>", |
458 | newkeys->comp.name); | 462 | newkeys->comp.name); |
459 | } | 463 | } |
460 | choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]); | 464 | choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]); |
@@ -467,6 +471,8 @@ kex_choose_conf(Kex *kex) | |||
467 | need = newkeys->enc.key_len; | 471 | need = newkeys->enc.key_len; |
468 | if (need < newkeys->enc.block_size) | 472 | if (need < newkeys->enc.block_size) |
469 | need = newkeys->enc.block_size; | 473 | need = newkeys->enc.block_size; |
474 | if (need < newkeys->enc.iv_len) | ||
475 | need = newkeys->enc.iv_len; | ||
470 | if (need < newkeys->mac.key_len) | 476 | if (need < newkeys->mac.key_len) |
471 | need = newkeys->mac.key_len; | 477 | need = newkeys->mac.key_len; |
472 | } | 478 | } |