comparison cli-session.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 983a817f8e41
children eafdf8b363f5
comparison
equal deleted inserted replaced
725:49f68a7b7a55 739:d44325108d0e
107 107
108 /* Not reached */ 108 /* Not reached */
109 109
110 } 110 }
111 111
112 static void cli_send_kex_first_guess() {
113 send_msg_kexdh_init();
114 dropbear_log(LOG_INFO, "kexdh_init guess sent");
115 //cli_ses.kex_state = KEXDH_INIT_SENT;
116 }
117
112 static void cli_session_init() { 118 static void cli_session_init() {
113 119
114 cli_ses.state = STATE_NOTHING; 120 cli_ses.state = STATE_NOTHING;
115 cli_ses.kex_state = KEX_NOTHING; 121 cli_ses.kex_state = KEX_NOTHING;
116 122
146 152
147 /* packet handlers */ 153 /* packet handlers */
148 ses.packettypes = cli_packettypes; 154 ses.packettypes = cli_packettypes;
149 155
150 ses.isserver = 0; 156 ses.isserver = 0;
157
158 ses.send_kex_first_guess = cli_send_kex_first_guess;
159
151 } 160 }
152 161
153 /* This function drives the progress of the session - it initiates KEX, 162 /* This function drives the progress of the session - it initiates KEX,
154 * service, userauth and channel requests */ 163 * service, userauth and channel requests */
155 static void cli_sessionloop() { 164 static void cli_sessionloop() {
156 165
157 TRACE(("enter cli_sessionloop")) 166 TRACE(("enter cli_sessionloop"))
158 167
159 if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) { 168 if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) {
160 cli_ses.kex_state = KEXINIT_RCVD;
161 }
162
163 if (cli_ses.kex_state == KEXINIT_RCVD) {
164
165 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT 169 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT
166 * negotiation would have failed. */ 170 * negotiation would have failed. */
167 send_msg_kexdh_init(); 171 if (!ses.kexstate.our_first_follows_matches) {
168 cli_ses.kex_state = KEXDH_INIT_SENT; 172 dropbear_log(LOG_INFO, "kexdh_init after remote's kexinit");
173 send_msg_kexdh_init();
174 }
175 cli_ses.kex_state = KEXDH_INIT_SENT;
169 TRACE(("leave cli_sessionloop: done with KEXINIT_RCVD")) 176 TRACE(("leave cli_sessionloop: done with KEXINIT_RCVD"))
170 return; 177 return;
171 } 178 }
172 179
173 /* A KEX has finished, so we should go back to our KEX_NOTHING state */ 180 /* A KEX has finished, so we should go back to our KEX_NOTHING state */