Mercurial > dropbear
comparison common-kex.c @ 741:eafdf8b363f5 kexguess
Get rid of client/server specific buf_match_algo, use single
function with a couple of if statements instead
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 30 Mar 2013 23:55:05 +0800 |
parents | 3062da90dab8 |
children | 465fefc4f6e0 |
comparison
equal
deleted
inserted
replaced
740:3062da90dab8 | 741:eafdf8b363f5 |
---|---|
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; | 695 enum kexguess2_used kexguess2 = KEXGUESS2_LOOK; |
696 | 696 |
697 /* kex_algorithms */ | 697 /* kex_algorithms */ |
698 algo = ses.buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess); | 698 algo = buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess); |
699 allgood &= goodguess; | 699 allgood &= goodguess; |
700 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) { | 700 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) { |
701 erralgo = "kex"; | 701 erralgo = "kex"; |
702 goto error; | 702 goto error; |
703 } | 703 } |
704 TRACE(("kexguess2 %d", kexguess2)) | 704 TRACE(("kexguess2 %d", kexguess2)) |
705 TRACE(("kex algo %s", algo->name)) | 705 TRACE(("kex algo %s", algo->name)) |
706 ses.newkeys->algo_kex = algo->val; | 706 ses.newkeys->algo_kex = algo->val; |
707 | 707 |
708 /* server_host_key_algorithms */ | 708 /* server_host_key_algorithms */ |
709 algo = ses.buf_match_algo(ses.payload, sshhostkey, &kexguess2, &goodguess); | 709 algo = buf_match_algo(ses.payload, sshhostkey, &kexguess2, &goodguess); |
710 allgood &= goodguess; | 710 allgood &= goodguess; |
711 if (algo == NULL) { | 711 if (algo == NULL) { |
712 erralgo = "hostkey"; | 712 erralgo = "hostkey"; |
713 goto error; | 713 goto error; |
714 } | 714 } |
715 TRACE(("hostkey algo %s", algo->name)) | 715 TRACE(("hostkey algo %s", algo->name)) |
716 ses.newkeys->algo_hostkey = algo->val; | 716 ses.newkeys->algo_hostkey = algo->val; |
717 | 717 |
718 /* encryption_algorithms_client_to_server */ | 718 /* encryption_algorithms_client_to_server */ |
719 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, NULL, NULL); | 719 c2s_cipher_algo = buf_match_algo(ses.payload, sshciphers, NULL, NULL); |
720 if (c2s_cipher_algo == NULL) { | 720 if (c2s_cipher_algo == NULL) { |
721 erralgo = "enc c->s"; | 721 erralgo = "enc c->s"; |
722 goto error; | 722 goto error; |
723 } | 723 } |
724 TRACE(("enc c2s is %s", c2s_cipher_algo->name)) | 724 TRACE(("enc c2s is %s", c2s_cipher_algo->name)) |
725 | 725 |
726 /* encryption_algorithms_server_to_client */ | 726 /* encryption_algorithms_server_to_client */ |
727 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, NULL, NULL); | 727 s2c_cipher_algo = buf_match_algo(ses.payload, sshciphers, NULL, NULL); |
728 if (s2c_cipher_algo == NULL) { | 728 if (s2c_cipher_algo == NULL) { |
729 erralgo = "enc s->c"; | 729 erralgo = "enc s->c"; |
730 goto error; | 730 goto error; |
731 } | 731 } |
732 TRACE(("enc s2c is %s", s2c_cipher_algo->name)) | 732 TRACE(("enc s2c is %s", s2c_cipher_algo->name)) |
733 | 733 |
734 /* mac_algorithms_client_to_server */ | 734 /* mac_algorithms_client_to_server */ |
735 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, NULL, NULL); | 735 c2s_hash_algo = buf_match_algo(ses.payload, sshhashes, NULL, NULL); |
736 if (c2s_hash_algo == NULL) { | 736 if (c2s_hash_algo == NULL) { |
737 erralgo = "mac c->s"; | 737 erralgo = "mac c->s"; |
738 goto error; | 738 goto error; |
739 } | 739 } |
740 TRACE(("hash c2s is %s", c2s_hash_algo->name)) | 740 TRACE(("hash c2s is %s", c2s_hash_algo->name)) |
741 | 741 |
742 /* mac_algorithms_server_to_client */ | 742 /* mac_algorithms_server_to_client */ |
743 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, NULL, NULL); | 743 s2c_hash_algo = buf_match_algo(ses.payload, sshhashes, NULL, NULL); |
744 if (s2c_hash_algo == NULL) { | 744 if (s2c_hash_algo == NULL) { |
745 erralgo = "mac s->c"; | 745 erralgo = "mac s->c"; |
746 goto error; | 746 goto error; |
747 } | 747 } |
748 TRACE(("hash s2c is %s", s2c_hash_algo->name)) | 748 TRACE(("hash s2c is %s", s2c_hash_algo->name)) |
749 | 749 |
750 /* compression_algorithms_client_to_server */ | 750 /* compression_algorithms_client_to_server */ |
751 c2s_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); | 751 c2s_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); |
752 if (c2s_comp_algo == NULL) { | 752 if (c2s_comp_algo == NULL) { |
753 erralgo = "comp c->s"; | 753 erralgo = "comp c->s"; |
754 goto error; | 754 goto error; |
755 } | 755 } |
756 TRACE(("hash c2s is %s", c2s_comp_algo->name)) | 756 TRACE(("hash c2s is %s", c2s_comp_algo->name)) |
757 | 757 |
758 /* compression_algorithms_server_to_client */ | 758 /* compression_algorithms_server_to_client */ |
759 s2c_comp_algo = ses.buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); | 759 s2c_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); |
760 if (s2c_comp_algo == NULL) { | 760 if (s2c_comp_algo == NULL) { |
761 erralgo = "comp s->c"; | 761 erralgo = "comp s->c"; |
762 goto error; | 762 goto error; |
763 } | 763 } |
764 TRACE(("hash s2c is %s", s2c_comp_algo->name)) | 764 TRACE(("hash s2c is %s", s2c_comp_algo->name)) |