summaryrefslogtreecommitdiffhomepage
path: root/cli-kex.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2004-08-17 10:20:20 +0000
committerMatt Johnston <matt@ucc.asn.au>2004-08-17 10:20:20 +0000
commit4a52217ed410dfbfdceee4688688d756fa0d097e (patch)
treeaa75223fe057999adadd9aa8891ee9e926d11354 /cli-kex.c
parent954a8dce0fdd5f4d16eeb5436e4a8659e91e1cbd (diff)
default initialisers for mp_ints
--HG-- extra : convert_revision : af69bacb50a31523e383e8f73844d04681f9e394
Diffstat (limited to 'cli-kex.c')
-rw-r--r--cli-kex.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/cli-kex.c b/cli-kex.c
index ca29e7d..90c8d29 100644
--- a/cli-kex.c
+++ b/cli-kex.c
@@ -45,8 +45,8 @@ void send_msg_kexdh_init() {
cli_ses.dh_e = (mp_int*)m_malloc(sizeof(mp_int));
cli_ses.dh_x = (mp_int*)m_malloc(sizeof(mp_int));
-
m_mp_init_multi(cli_ses.dh_e, cli_ses.dh_x, NULL);
+
gen_kexdh_vals(cli_ses.dh_e, cli_ses.dh_x);
CHECKCLEARTOWRITE();
@@ -59,13 +59,18 @@ void send_msg_kexdh_init() {
/* Handle a diffie-hellman key exchange reply. */
void recv_msg_kexdh_reply() {
- mp_int dh_f;
+ DEF_MP_INT(dh_f);
sign_key *hostkey = NULL;
unsigned int type, keybloblen;
unsigned char* keyblob = NULL;
TRACE(("enter recv_msg_kexdh_reply"));
+
+ if (cli_ses.kex_state != KEXDH_INIT_SENT) {
+ dropbear_exit("Received out-of-order kexdhreply");
+ }
+ m_mp_init(&dh_f);
type = ses.newkeys->algo_hostkey;
TRACE(("type is %d", type));
@@ -83,7 +88,6 @@ void recv_msg_kexdh_reply() {
dropbear_exit("Bad KEX packet");
}
- m_mp_init(&dh_f);
if (buf_getmpint(ses.payload, &dh_f) != DROPBEAR_SUCCESS) {
TRACE(("failed getting mpint"));
dropbear_exit("Bad KEX packet");
@@ -91,6 +95,9 @@ void recv_msg_kexdh_reply() {
kexdh_comb_key(cli_ses.dh_e, cli_ses.dh_x, &dh_f, hostkey);
mp_clear(&dh_f);
+ mp_clear_multi(cli_ses.dh_e, cli_ses.dh_x, NULL);
+ m_free(cli_ses.dh_e);
+ m_free(cli_ses.dh_x);
if (buf_verify(ses.payload, hostkey, ses.hash, SHA1_HASH_SIZE)
!= DROPBEAR_SUCCESS) {