Mercurial > dropbear
comparison common-kex.c @ 118:5312ca05ed48 private-rez
propagate of 717950f4061f1123659ee87c7c168805af920ab7 and 839f98f136788cc1466e4641bf796f96040a085d from branch 'matt.dbclient.authpam' to 'matt.dbclient.rez'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 12 Sep 2004 04:56:50 +0000 |
parents | 2010f4119c1a |
children | 0cfba3034be5 |
comparison
equal
deleted
inserted
replaced
57:3b2a5a1c4347 | 118:5312ca05ed48 |
---|---|
1 /* | 1 /* |
2 * Dropbear - a SSH2 server | 2 * Dropbear SSH |
3 * SSH client implementation | |
4 * | |
5 * This code is copied from the larger file "kex.c" | |
6 * some functions are verbatim, others are generalized --mihnea | |
7 * | 3 * |
8 * Copyright (c) 2002-2004 Matt Johnston | 4 * Copyright (c) 2002-2004 Matt Johnston |
9 * Portions Copyright (c) 2004 by Mihnea Stoenescu | 5 * Portions Copyright (c) 2004 by Mihnea Stoenescu |
10 * All rights reserved. | 6 * All rights reserved. |
11 * | 7 * |
466 TRACE(("leave recv_msg_kexinit")); | 462 TRACE(("leave recv_msg_kexinit")); |
467 } | 463 } |
468 | 464 |
469 /* Initialises and generate one side of the diffie-hellman key exchange values. | 465 /* Initialises and generate one side of the diffie-hellman key exchange values. |
470 * See the ietf-secsh-transport draft, section 6, for details */ | 466 * See the ietf-secsh-transport draft, section 6, for details */ |
467 /* dh_pub and dh_priv MUST be already initialised */ | |
471 void gen_kexdh_vals(mp_int *dh_pub, mp_int *dh_priv) { | 468 void gen_kexdh_vals(mp_int *dh_pub, mp_int *dh_priv) { |
472 | 469 |
473 mp_int dh_p, dh_q, dh_g; | 470 DEF_MP_INT(dh_p); |
471 DEF_MP_INT(dh_q); | |
472 DEF_MP_INT(dh_g); | |
474 unsigned char randbuf[DH_P_LEN]; | 473 unsigned char randbuf[DH_P_LEN]; |
475 int dh_q_len; | 474 int dh_q_len; |
476 | 475 |
477 TRACE(("enter send_msg_kexdh_reply")); | 476 TRACE(("enter send_msg_kexdh_reply")); |
478 | 477 |
479 m_mp_init_multi(&dh_g, &dh_p, &dh_q, dh_priv, dh_pub, NULL); | 478 m_mp_init_multi(&dh_g, &dh_p, &dh_q, NULL); |
480 | 479 |
481 /* read the prime and generator*/ | 480 /* read the prime and generator*/ |
482 if (mp_read_unsigned_bin(&dh_p, (unsigned char*)dh_p_val, DH_P_LEN) | 481 if (mp_read_unsigned_bin(&dh_p, (unsigned char*)dh_p_val, DH_P_LEN) |
483 != MP_OKAY) { | 482 != MP_OKAY) { |
484 dropbear_exit("Diffie-Hellman error"); | 483 dropbear_exit("Diffie-Hellman error"); |
633 TRACE(("hostkey algo %s", algo->name)); | 632 TRACE(("hostkey algo %s", algo->name)); |
634 ses.newkeys->algo_hostkey = algo->val; | 633 ses.newkeys->algo_hostkey = algo->val; |
635 | 634 |
636 /* encryption_algorithms_client_to_server */ | 635 /* encryption_algorithms_client_to_server */ |
637 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); | 636 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); |
638 if (algo == NULL) { | 637 if (c2s_cipher_algo == NULL) { |
639 erralgo = "enc c->s"; | 638 erralgo = "enc c->s"; |
640 goto error; | 639 goto error; |
641 } | 640 } |
641 TRACE(("c2s is %s", c2s_cipher_algo->name)); | |
642 | 642 |
643 /* encryption_algorithms_server_to_client */ | 643 /* encryption_algorithms_server_to_client */ |
644 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); | 644 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); |
645 if (algo == NULL) { | 645 if (s2c_cipher_algo == NULL) { |
646 erralgo = "enc s->c"; | 646 erralgo = "enc s->c"; |
647 goto error; | 647 goto error; |
648 } | 648 } |
649 TRACE(("s2c is %s", s2c_cipher_algo->name)); | |
649 | 650 |
650 /* mac_algorithms_client_to_server */ | 651 /* mac_algorithms_client_to_server */ |
651 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); | 652 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); |
652 if (algo == NULL) { | 653 if (c2s_hash_algo == NULL) { |
653 erralgo = "mac c->s"; | 654 erralgo = "mac c->s"; |
654 goto error; | 655 goto error; |
655 } | 656 } |
656 | 657 |
657 /* mac_algorithms_server_to_client */ | 658 /* mac_algorithms_server_to_client */ |
658 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); | 659 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); |
659 if (algo == NULL) { | 660 if (s2c_hash_algo == NULL) { |
660 erralgo = "mac s->c"; | 661 erralgo = "mac s->c"; |
661 goto error; | 662 goto error; |
662 } | 663 } |
663 | 664 |
664 /* compression_algorithms_client_to_server */ | 665 /* compression_algorithms_client_to_server */ |
665 c2s_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess); | 666 c2s_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess); |
666 if (algo == NULL) { | 667 if (c2s_comp_algo == NULL) { |
667 erralgo = "comp c->s"; | 668 erralgo = "comp c->s"; |
668 goto error; | 669 goto error; |
669 } | 670 } |
670 | 671 |
671 /* compression_algorithms_server_to_client */ | 672 /* compression_algorithms_server_to_client */ |
672 s2c_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess); | 673 s2c_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess); |
673 if (algo == NULL) { | 674 if (s2c_comp_algo == NULL) { |
674 erralgo = "comp s->c"; | 675 erralgo = "comp s->c"; |
675 goto error; | 676 goto error; |
676 } | 677 } |
677 | 678 |
678 /* languages_client_to_server */ | 679 /* languages_client_to_server */ |