comparison common-kex.c @ 257:63601217f5ab

* options.h, common-kex.c: fix support of 4096 byte host keys
author Matt Johnston <matt@ucc.asn.au>
date Wed, 30 Nov 2005 10:11:24 +0000
parents 5e4110bb753a
children 64abb124763d 3e098639b05f 0e69e948caba
comparison
equal deleted inserted replaced
256:ac890087b8c1 257:63601217f5ab
392 392
393 /* Originally from kex.c, generalized for cli/svr mode --mihnea */ 393 /* Originally from kex.c, generalized for cli/svr mode --mihnea */
394 /* Belongs in common_kex.c where it should be moved after review */ 394 /* Belongs in common_kex.c where it should be moved after review */
395 void recv_msg_kexinit() { 395 void recv_msg_kexinit() {
396 396
397 unsigned int kexhashbuf_len = 0;
398 unsigned int remote_ident_len = 0;
399 unsigned int local_ident_len = 0;
400
397 TRACE(("<- KEXINIT")) 401 TRACE(("<- KEXINIT"))
398 TRACE(("enter recv_msg_kexinit")) 402 TRACE(("enter recv_msg_kexinit"))
399 403
400 /* start the kex hash */
401 ses.kexhashbuf = buf_new(MAX_KEXHASHBUF);
402
403 if (!ses.kexstate.sentkexinit) { 404 if (!ses.kexstate.sentkexinit) {
404 /* we need to send a kex packet */ 405 /* we need to send a kex packet */
405 send_msg_kexinit(); 406 send_msg_kexinit();
406 TRACE(("continue recv_msg_kexinit: sent kexinit")) 407 TRACE(("continue recv_msg_kexinit: sent kexinit"))
407 } 408 }
408 409
410 /* start the kex hash */
411 local_ident_len = strlen(LOCAL_IDENT);
412 remote_ident_len = strlen((char*)ses.remoteident);
413
414 kexhashbuf_len = local_ident_len + remote_ident_len
415 + ses.transkexinit->len + ses.payload->len
416 + KEXHASHBUF_MAX_INTS;
417
418 ses.kexhashbuf = buf_new(kexhashbuf_len);
409 419
410 if (IS_DROPBEAR_CLIENT) { 420 if (IS_DROPBEAR_CLIENT) {
411 421
412 /* read the peer's choice of algos */ 422 /* read the peer's choice of algos */
413 read_kex_algos(); 423 read_kex_algos();
414 424
415 /* V_C, the client's version string (CR and NL excluded) */ 425 /* V_C, the client's version string (CR and NL excluded) */
416 buf_putstring(ses.kexhashbuf, 426 buf_putstring(ses.kexhashbuf,
417 (unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT)); 427 (unsigned char*)LOCAL_IDENT, local_ident_len);
418 /* V_S, the server's version string (CR and NL excluded) */ 428 /* V_S, the server's version string (CR and NL excluded) */
419 buf_putstring(ses.kexhashbuf, 429 buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
420 ses.remoteident, strlen((char*)ses.remoteident));
421 430
422 /* I_C, the payload of the client's SSH_MSG_KEXINIT */ 431 /* I_C, the payload of the client's SSH_MSG_KEXINIT */
423 buf_putstring(ses.kexhashbuf, 432 buf_putstring(ses.kexhashbuf,
424 buf_getptr(ses.transkexinit, ses.transkexinit->len), 433 ses.transkexinit->data, ses.transkexinit->len);
425 ses.transkexinit->len);
426 /* I_S, the payload of the server's SSH_MSG_KEXINIT */ 434 /* I_S, the payload of the server's SSH_MSG_KEXINIT */
427 buf_setpos(ses.payload, 0); 435 buf_setpos(ses.payload, 0);
428 buf_putstring(ses.kexhashbuf, 436 buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);
429 buf_getptr(ses.payload, ses.payload->len),
430 ses.payload->len);
431 437
432 } else { 438 } else {
433 /* SERVER */ 439 /* SERVER */
434 440
435 /* read the peer's choice of algos */ 441 /* read the peer's choice of algos */
436 read_kex_algos(); 442 read_kex_algos();
437 /* V_C, the client's version string (CR and NL excluded) */ 443 /* V_C, the client's version string (CR and NL excluded) */
444 buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
445 /* V_S, the server's version string (CR and NL excluded) */
438 buf_putstring(ses.kexhashbuf, 446 buf_putstring(ses.kexhashbuf,
439 ses.remoteident, strlen((char*)ses.remoteident)); 447 (unsigned char*)LOCAL_IDENT, local_ident_len);
440 /* V_S, the server's version string (CR and NL excluded) */
441 buf_putstring(ses.kexhashbuf,
442 (unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT));
443 448
444 /* I_C, the payload of the client's SSH_MSG_KEXINIT */ 449 /* I_C, the payload of the client's SSH_MSG_KEXINIT */
445 buf_setpos(ses.payload, 0); 450 buf_setpos(ses.payload, 0);
446 buf_putstring(ses.kexhashbuf, 451 buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);
447 buf_getptr(ses.payload, ses.payload->len), 452
448 ses.payload->len);
449 /* I_S, the payload of the server's SSH_MSG_KEXINIT */ 453 /* I_S, the payload of the server's SSH_MSG_KEXINIT */
450 buf_putstring(ses.kexhashbuf, 454 buf_putstring(ses.kexhashbuf,
451 buf_getptr(ses.transkexinit, ses.transkexinit->len), 455 ses.transkexinit->data, ses.transkexinit->len);
452 ses.transkexinit->len); 456
453 ses.requirenext = SSH_MSG_KEXDH_INIT; 457 ses.requirenext = SSH_MSG_KEXDH_INIT;
454 } 458 }
455 459
456 buf_free(ses.transkexinit); 460 buf_free(ses.transkexinit);
457 ses.transkexinit = NULL; 461 ses.transkexinit = NULL;