comparison common-kex.c @ 740:3062da90dab8 kexguess

Add kexguess2 behaviour
author Matt Johnston <matt@ucc.asn.au>
date Fri, 29 Mar 2013 23:29:48 +0800
parents d44325108d0e
children eafdf8b363f5
comparison
equal deleted inserted replaced
739:d44325108d0e 740:3062da90dab8
690 690
691 buf_incrpos(ses.payload, 16); /* start after the cookie */ 691 buf_incrpos(ses.payload, 16); /* start after the cookie */
692 692
693 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys)); 693 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys));
694 694
695 enum kexguess2_used kexguess2 = KEXGUESS2_LOOK;
696
695 /* kex_algorithms */ 697 /* kex_algorithms */
696 algo = ses.buf_match_algo(ses.payload, sshkex, &goodguess); 698 algo = ses.buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess);
697 allgood &= goodguess; 699 allgood &= goodguess;
698 if (algo == NULL) { 700 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) {
699 erralgo = "kex"; 701 erralgo = "kex";
700 goto error; 702 goto error;
701 } 703 }
704 TRACE(("kexguess2 %d", kexguess2))
702 TRACE(("kex algo %s", algo->name)) 705 TRACE(("kex algo %s", algo->name))
703 ses.newkeys->algo_kex = algo->val; 706 ses.newkeys->algo_kex = algo->val;
704 707
705 /* server_host_key_algorithms */ 708 /* server_host_key_algorithms */
706 algo = ses.buf_match_algo(ses.payload, sshhostkey, &goodguess); 709 algo = ses.buf_match_algo(ses.payload, sshhostkey, &kexguess2, &goodguess);
707 allgood &= goodguess; 710 allgood &= goodguess;
708 if (algo == NULL) { 711 if (algo == NULL) {
709 erralgo = "hostkey"; 712 erralgo = "hostkey";
710 goto error; 713 goto error;
711 } 714 }
712 TRACE(("hostkey algo %s", algo->name)) 715 TRACE(("hostkey algo %s", algo->name))
713 ses.newkeys->algo_hostkey = algo->val; 716 ses.newkeys->algo_hostkey = algo->val;
714 717
715 /* encryption_algorithms_client_to_server */ 718 /* encryption_algorithms_client_to_server */
716 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); 719 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, NULL, NULL);
717 if (c2s_cipher_algo == NULL) { 720 if (c2s_cipher_algo == NULL) {
718 erralgo = "enc c->s"; 721 erralgo = "enc c->s";
719 goto error; 722 goto error;
720 } 723 }
721 TRACE(("enc c2s is %s", c2s_cipher_algo->name)) 724 TRACE(("enc c2s is %s", c2s_cipher_algo->name))
722 725
723 /* encryption_algorithms_server_to_client */ 726 /* encryption_algorithms_server_to_client */
724 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess); 727 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, NULL, NULL);
725 if (s2c_cipher_algo == NULL) { 728 if (s2c_cipher_algo == NULL) {
726 erralgo = "enc s->c"; 729 erralgo = "enc s->c";
727 goto error; 730 goto error;
728 } 731 }
729 TRACE(("enc s2c is %s", s2c_cipher_algo->name)) 732 TRACE(("enc s2c is %s", s2c_cipher_algo->name))
730 733
731 /* mac_algorithms_client_to_server */ 734 /* mac_algorithms_client_to_server */
732 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); 735 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, NULL, NULL);
733 if (c2s_hash_algo == NULL) { 736 if (c2s_hash_algo == NULL) {
734 erralgo = "mac c->s"; 737 erralgo = "mac c->s";
735 goto error; 738 goto error;
736 } 739 }
737 TRACE(("hash c2s is %s", c2s_hash_algo->name)) 740 TRACE(("hash c2s is %s", c2s_hash_algo->name))
738 741
739 /* mac_algorithms_server_to_client */ 742 /* mac_algorithms_server_to_client */
740 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess); 743 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, NULL, NULL);
741 if (s2c_hash_algo == NULL) { 744 if (s2c_hash_algo == NULL) {
742 erralgo = "mac s->c"; 745 erralgo = "mac s->c";
743 goto error; 746 goto error;
744 } 747 }
745 TRACE(("hash s2c is %s", s2c_hash_algo->name)) 748 TRACE(("hash s2c is %s", s2c_hash_algo->name))
746 749
747 /* compression_algorithms_client_to_server */ 750 /* compression_algorithms_client_to_server */
748 c2s_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, &goodguess); 751 c2s_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL);
749 if (c2s_comp_algo == NULL) { 752 if (c2s_comp_algo == NULL) {
750 erralgo = "comp c->s"; 753 erralgo = "comp c->s";
751 goto error; 754 goto error;
752 } 755 }
753 TRACE(("hash c2s is %s", c2s_comp_algo->name)) 756 TRACE(("hash c2s is %s", c2s_comp_algo->name))
754 757
755 /* compression_algorithms_server_to_client */ 758 /* compression_algorithms_server_to_client */
756 s2c_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, &goodguess); 759 s2c_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL);
757 if (s2c_comp_algo == NULL) { 760 if (s2c_comp_algo == NULL) {
758 erralgo = "comp s->c"; 761 erralgo = "comp s->c";
759 goto error; 762 goto error;
760 } 763 }
761 TRACE(("hash s2c is %s", s2c_comp_algo->name)) 764 TRACE(("hash s2c is %s", s2c_comp_algo->name))