|
Lines 74-80
Link Here
|
| 74 |
|
74 |
|
| 75 |
/* parse buffer and return algorithm proposal */ |
75 |
/* parse buffer and return algorithm proposal */ |
| 76 |
static char ** |
76 |
static char ** |
| 77 |
kex_buf2prop(Buffer *raw) |
77 |
kex_buf2prop(Buffer *raw, int *first_kex_follows) |
| 78 |
{ |
78 |
{ |
| 79 |
Buffer b; |
79 |
Buffer b; |
| 80 |
int i; |
80 |
int i; |
|
Lines 94-99
Link Here
|
| 94 |
} |
94 |
} |
| 95 |
/* first kex follows / reserved */ |
95 |
/* first kex follows / reserved */ |
| 96 |
i = buffer_get_char(&b); |
96 |
i = buffer_get_char(&b); |
|
|
97 |
if (first_kex_follows != NULL) |
| 98 |
*first_kex_follows = i; |
| 97 |
debug2("kex_parse_kexinit: first_kex_follows %d ", i); |
99 |
debug2("kex_parse_kexinit: first_kex_follows %d ", i); |
| 98 |
i = buffer_get_int(&b); |
100 |
i = buffer_get_int(&b); |
| 99 |
debug2("kex_parse_kexinit: reserved %d ", i); |
101 |
debug2("kex_parse_kexinit: reserved %d ", i); |
|
Lines 317-322
Link Here
|
| 317 |
xfree(hostkeyalg); |
319 |
xfree(hostkeyalg); |
| 318 |
} |
320 |
} |
| 319 |
|
321 |
|
|
|
322 |
static int |
| 323 |
proposals_match(char *my[PROPOSAL_MAX], char *peer[PROPOSAL_MAX]) |
| 324 |
{ |
| 325 |
int i, j; |
| 326 |
int prop[] = { PROPOSAL_KEX_ALGS, PROPOSAL_SERVER_HOST_KEY_ALGS, -1 }; |
| 327 |
char *p; |
| 328 |
|
| 329 |
for (i = 0; prop[i] != -1; i++) { |
| 330 |
j = prop[i]; |
| 331 |
if ((p = strchr(my[j], ',')) != NULL) |
| 332 |
*p = '\0'; |
| 333 |
if ((p = strchr(peer[j], ',')) != NULL) |
| 334 |
*p = '\0'; |
| 335 |
if (strcmp(my[j], peer[j]) != 0) { |
| 336 |
debug2("proposal mismatch: %s %s", my[j], peer[j]); |
| 337 |
return (0); |
| 338 |
} |
| 339 |
} |
| 340 |
debug2("proposals match"); |
| 341 |
return (1); |
| 342 |
} |
| 343 |
|
| 320 |
static void |
344 |
static void |
| 321 |
kex_choose_conf(Kex *kex) |
345 |
kex_choose_conf(Kex *kex) |
| 322 |
{ |
346 |
{ |
|
Lines 327-335
Link Here
|
| 327 |
int mode; |
351 |
int mode; |
| 328 |
int ctos; /* direction: if true client-to-server */ |
352 |
int ctos; /* direction: if true client-to-server */ |
| 329 |
int need; |
353 |
int need; |
|
|
354 |
int first_kex_follows, type; |
| 330 |
|
355 |
|
| 331 |
my = kex_buf2prop(&kex->my); |
356 |
my = kex_buf2prop(&kex->my, NULL); |
| 332 |
peer = kex_buf2prop(&kex->peer); |
357 |
peer = kex_buf2prop(&kex->peer, &first_kex_follows); |
| 333 |
|
358 |
|
| 334 |
if (kex->server) { |
359 |
if (kex->server) { |
| 335 |
cprop=peer; |
360 |
cprop=peer; |
|
Lines 372-377
Link Here
|
| 372 |
} |
397 |
} |
| 373 |
/* XXX need runden? */ |
398 |
/* XXX need runden? */ |
| 374 |
kex->we_need = need; |
399 |
kex->we_need = need; |
|
|
400 |
|
| 401 |
/* ignore the next message if the proposals do not match */ |
| 402 |
if (first_kex_follows && !proposals_match(my, peer)) { |
| 403 |
type = packet_read(); |
| 404 |
debug2("skipping next packet (type %u)", type); |
| 405 |
} |
| 375 |
|
406 |
|
| 376 |
kex_prop_free(my); |
407 |
kex_prop_free(my); |
| 377 |
kex_prop_free(peer); |
408 |
kex_prop_free(peer); |