Mercurial > dropbear
comparison common-kex.c @ 739:d44325108d0e kexguess
first_kex_packet_follows working, needs tidying
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 29 Mar 2013 20:44:13 +0800 |
parents | bf0ac0512ef7 |
children | 3062da90dab8 |
comparison
equal
deleted
inserted
replaced
725:49f68a7b7a55 | 739:d44325108d0e |
---|---|
129 buf_putstring(ses.writepayload, "", 0); | 129 buf_putstring(ses.writepayload, "", 0); |
130 | 130 |
131 /* languages_server_to_client */ | 131 /* languages_server_to_client */ |
132 buf_putstring(ses.writepayload, "", 0); | 132 buf_putstring(ses.writepayload, "", 0); |
133 | 133 |
134 /* first_kex_packet_follows - unimplemented for now */ | 134 /* first_kex_packet_follows */ |
135 buf_putbyte(ses.writepayload, 0x00); | 135 buf_putbyte(ses.writepayload, (ses.send_kex_first_guess != NULL)); |
136 | 136 |
137 /* reserved unit32 */ | 137 /* reserved unit32 */ |
138 buf_putint(ses.writepayload, 0); | 138 buf_putint(ses.writepayload, 0); |
139 | 139 |
140 /* set up transmitted kex packet buffer for hashing. | 140 /* set up transmitted kex packet buffer for hashing. |
142 ses.transkexinit = buf_newcopy(ses.writepayload); | 142 ses.transkexinit = buf_newcopy(ses.writepayload); |
143 | 143 |
144 encrypt_packet(); | 144 encrypt_packet(); |
145 ses.dataallowed = 0; /* don't send other packets during kex */ | 145 ses.dataallowed = 0; /* don't send other packets during kex */ |
146 | 146 |
147 ses.kexstate.sentkexinit = 1; | |
148 | |
149 ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context)); | |
150 | |
151 if (ses.send_kex_first_guess) { | |
152 ses.newkeys->algo_kex = sshkex[0].val; | |
153 ses.newkeys->algo_hostkey = sshhostkey[0].val; | |
154 ses.send_kex_first_guess(); | |
155 } | |
156 | |
147 TRACE(("DATAALLOWED=0")) | 157 TRACE(("DATAALLOWED=0")) |
148 TRACE(("-> KEXINIT")) | 158 TRACE(("-> KEXINIT")) |
149 ses.kexstate.sentkexinit = 1; | 159 |
150 } | 160 } |
151 | 161 |
152 /* *** NOTE regarding (send|recv)_msg_newkeys *** | 162 /* *** NOTE regarding (send|recv)_msg_newkeys *** |
153 * Changed by mihnea from the original kex.c to set dataallowed after a | 163 * Changed by mihnea from the original kex.c to set dataallowed after a |
154 * completed key exchange, no matter the order in which it was performed. | 164 * completed key exchange, no matter the order in which it was performed. |
234 /* sent/recv'd MSG_NEWKEYS */ | 244 /* sent/recv'd MSG_NEWKEYS */ |
235 ses.kexstate.recvnewkeys = 0; | 245 ses.kexstate.recvnewkeys = 0; |
236 ses.kexstate.sentnewkeys = 0; | 246 ses.kexstate.sentnewkeys = 0; |
237 | 247 |
238 /* first_packet_follows */ | 248 /* first_packet_follows */ |
239 ses.kexstate.firstfollows = 0; | 249 ses.kexstate.them_firstfollows = 0; |
240 | 250 |
241 ses.kexstate.datatrans = 0; | 251 ses.kexstate.datatrans = 0; |
242 ses.kexstate.datarecv = 0; | 252 ses.kexstate.datarecv = 0; |
253 | |
254 ses.kexstate.our_first_follows_matches = 0; | |
243 | 255 |
244 ses.kexstate.lastkextime = time(NULL); | 256 ses.kexstate.lastkextime = time(NULL); |
245 | 257 |
246 } | 258 } |
247 | 259 |
553 | 565 |
554 DEF_MP_INT(dh_p); | 566 DEF_MP_INT(dh_p); |
555 DEF_MP_INT(dh_q); | 567 DEF_MP_INT(dh_q); |
556 DEF_MP_INT(dh_g); | 568 DEF_MP_INT(dh_g); |
557 | 569 |
558 TRACE(("enter send_msg_kexdh_reply")) | 570 TRACE(("enter gen_kexdh_vals")) |
559 | 571 |
560 m_mp_init_multi(&dh_g, &dh_p, &dh_q, NULL); | 572 m_mp_init_multi(&dh_g, &dh_p, &dh_q, NULL); |
561 | 573 |
562 /* read the prime and generator*/ | 574 /* read the prime and generator*/ |
563 load_dh_p(&dh_p); | 575 load_dh_p(&dh_p); |
676 int allgood = 1; /* we AND this with each goodguess and see if its still | 688 int allgood = 1; /* we AND this with each goodguess and see if its still |
677 true after */ | 689 true after */ |
678 | 690 |
679 buf_incrpos(ses.payload, 16); /* start after the cookie */ | 691 buf_incrpos(ses.payload, 16); /* start after the cookie */ |
680 | 692 |
681 ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context)); | 693 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys)); |
682 | 694 |
683 /* kex_algorithms */ | 695 /* kex_algorithms */ |
684 algo = ses.buf_match_algo(ses.payload, sshkex, &goodguess); | 696 algo = ses.buf_match_algo(ses.payload, sshkex, &goodguess); |
685 allgood &= goodguess; | 697 allgood &= goodguess; |
686 if (algo == NULL) { | 698 if (algo == NULL) { |
752 buf_eatstring(ses.payload); | 764 buf_eatstring(ses.payload); |
753 | 765 |
754 /* languages_server_to_client */ | 766 /* languages_server_to_client */ |
755 buf_eatstring(ses.payload); | 767 buf_eatstring(ses.payload); |
756 | 768 |
757 /* first_kex_packet_follows */ | 769 /* their first_kex_packet_follows */ |
758 if (buf_getbool(ses.payload)) { | 770 if (buf_getbool(ses.payload)) { |
759 ses.kexstate.firstfollows = 1; | 771 TRACE(("them kex firstfollows. allgood %d", allgood)) |
772 ses.kexstate.them_firstfollows = 1; | |
760 /* if the guess wasn't good, we ignore the packet sent */ | 773 /* if the guess wasn't good, we ignore the packet sent */ |
761 if (!allgood) { | 774 if (!allgood) { |
762 ses.ignorenext = 1; | 775 ses.ignorenext = 1; |
763 } | 776 } |
764 } | 777 } |
797 ses.newkeys->trans.algo_comp = s2c_comp_algo->val; | 810 ses.newkeys->trans.algo_comp = s2c_comp_algo->val; |
798 } | 811 } |
799 | 812 |
800 /* reserved for future extensions */ | 813 /* reserved for future extensions */ |
801 buf_getint(ses.payload); | 814 buf_getint(ses.payload); |
815 | |
816 if (ses.send_kex_first_guess && allgood) { | |
817 TRACE(("our_first_follows_matches 1")) | |
818 ses.kexstate.our_first_follows_matches = 1; | |
819 } | |
802 return; | 820 return; |
803 | 821 |
804 error: | 822 error: |
805 dropbear_exit("No matching algo %s", erralgo); | 823 dropbear_exit("No matching algo %s", erralgo); |
806 } | 824 } |