comparison cli-kex.c @ 34:e2a1eaa19f22

Client mostly works up to password auth Need to rework algo-choosing etc, since server is now broken.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Jul 2004 16:44:16 +0000
parents f789045062e6
children 095d689fed16
comparison
equal deleted inserted replaced
33:f789045062e6 34:e2a1eaa19f22
41 void send_msg_kexdh_init() { 41 void send_msg_kexdh_init() {
42 42
43 cli_ses.dh_e = (mp_int*)m_malloc(sizeof(mp_int)); 43 cli_ses.dh_e = (mp_int*)m_malloc(sizeof(mp_int));
44 cli_ses.dh_x = (mp_int*)m_malloc(sizeof(mp_int)); 44 cli_ses.dh_x = (mp_int*)m_malloc(sizeof(mp_int));
45 45
46 m_mp_init_multi(cli_ses.dh_e, cli_ses.dh_x); 46 m_mp_init_multi(cli_ses.dh_e, cli_ses.dh_x, NULL);
47 gen_kexdh_vals(cli_ses.dh_e, cli_ses.dh_x); 47 gen_kexdh_vals(cli_ses.dh_e, cli_ses.dh_x);
48 48
49 CHECKCLEARTOWRITE(); 49 CHECKCLEARTOWRITE();
50 buf_putbyte(ses.writepayload, SSH_MSG_KEXDH_INIT); 50 buf_putbyte(ses.writepayload, SSH_MSG_KEXDH_INIT);
51 buf_putmpint(ses.writepayload, cli_ses.dh_e); 51 buf_putmpint(ses.writepayload, cli_ses.dh_e);
56 /* Handle a diffie-hellman key exchange reply. */ 56 /* Handle a diffie-hellman key exchange reply. */
57 void recv_msg_kexdh_reply() { 57 void recv_msg_kexdh_reply() {
58 58
59 mp_int dh_f; 59 mp_int dh_f;
60 sign_key *hostkey = NULL; 60 sign_key *hostkey = NULL;
61 int type; 61 int type, keylen;
62 62
63 TRACE(("enter recv_msg_kexdh_reply"));
63 type = ses.newkeys->algo_hostkey; 64 type = ses.newkeys->algo_hostkey;
65 TRACE(("type is %d", type));
64 66
65 hostkey = new_sign_key(); 67 hostkey = new_sign_key();
68 keylen = buf_getint(ses.payload);
69
66 if (buf_get_pub_key(ses.payload, hostkey, &type) != DROPBEAR_SUCCESS) { 70 if (buf_get_pub_key(ses.payload, hostkey, &type) != DROPBEAR_SUCCESS) {
71 TRACE(("failed getting pubkey"));
67 dropbear_exit("Bad KEX packet"); 72 dropbear_exit("Bad KEX packet");
68 } 73 }
69 74
70 m_mp_init(&dh_f); 75 m_mp_init(&dh_f);
71 if (buf_getmpint(ses.payload, &dh_f) != DROPBEAR_SUCCESS) { 76 if (buf_getmpint(ses.payload, &dh_f) != DROPBEAR_SUCCESS) {
77 TRACE(("failed getting mpint"));
72 dropbear_exit("Bad KEX packet"); 78 dropbear_exit("Bad KEX packet");
73 } 79 }
74 80
75 kexdh_comb_key(cli_ses.dh_e, cli_ses.dh_x, &dh_f, hostkey); 81 kexdh_comb_key(cli_ses.dh_e, cli_ses.dh_x, &dh_f, hostkey);
76 mp_clear(&dh_f); 82 mp_clear(&dh_f);