Mercurial > dropbear
comparison common-kex.c @ 852:7540c0822374 ecc
Various cleanups and fixes for warnings
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 12 Nov 2013 23:02:32 +0800 |
parents | 6c69e7df3621 |
children | 04ede40a529a |
comparison
equal
deleted
inserted
replaced
851:c1c1b43f78c2 | 852:7540c0822374 |
---|---|
575 DEF_MP_INT(dh_g); | 575 DEF_MP_INT(dh_g); |
576 | 576 |
577 TRACE(("enter gen_kexdh_vals")) | 577 TRACE(("enter gen_kexdh_vals")) |
578 | 578 |
579 struct kex_dh_param *param = m_malloc(sizeof(*param)); | 579 struct kex_dh_param *param = m_malloc(sizeof(*param)); |
580 m_mp_init_multi(¶m->pub, ¶m->priv, NULL); | 580 m_mp_init_multi(¶m->pub, ¶m->priv, &dh_g, &dh_p, &dh_q, NULL); |
581 | 581 |
582 /* read the prime and generator*/ | 582 /* read the prime and generator*/ |
583 load_dh_p(&dh_p); | 583 load_dh_p(&dh_p); |
584 | 584 |
585 if (mp_set_int(&dh_g, DH_G_VAL) != MP_OKAY) { | 585 if (mp_set_int(&dh_g, DH_G_VAL) != MP_OKAY) { |
736 m_free(param); | 736 m_free(param); |
737 } | 737 } |
738 | 738 |
739 void kexcurve25519_comb_key(struct kex_curve25519_param *param, buffer *buf_pub_them, | 739 void kexcurve25519_comb_key(struct kex_curve25519_param *param, buffer *buf_pub_them, |
740 sign_key *hostkey) { | 740 sign_key *hostkey) { |
741 unsigned char* out = m_malloc(CURVE25519_LEN); | 741 unsigned char out[CURVE25519_LEN]; |
742 const unsigned char* Q_C = NULL; | 742 const unsigned char* Q_C = NULL; |
743 const unsigned char* Q_S = NULL; | 743 const unsigned char* Q_S = NULL; |
744 | 744 |
745 if (buf_pub_them->len != CURVE25519_LEN) | 745 if (buf_pub_them->len != CURVE25519_LEN) |
746 { | 746 { |
747 dropbear_exit("Bad curve25519"); | 747 dropbear_exit("Bad curve25519"); |
748 } | 748 } |
749 | 749 |
750 curve25519_donna(out, param->priv, buf_pub_them->data); | 750 curve25519_donna(out, param->priv, buf_pub_them->data); |
751 ses.dh_K = m_malloc(sizeof(*ses.dh_K)); | 751 m_mp_alloc_init_multi(&ses.dh_K, NULL); |
752 m_mp_init(ses.dh_K); | |
753 bytes_to_mp(ses.dh_K, out, CURVE25519_LEN); | 752 bytes_to_mp(ses.dh_K, out, CURVE25519_LEN); |
754 m_free(out); | 753 m_burn(out, sizeof(out)); |
755 | 754 |
756 /* Create the remainder of the hash buffer, to generate the exchange hash. | 755 /* Create the remainder of the hash buffer, to generate the exchange hash. |
757 See RFC5656 section 4 page 7 */ | 756 See RFC5656 section 4 page 7 */ |
758 if (IS_DROPBEAR_CLIENT) { | 757 if (IS_DROPBEAR_CLIENT) { |
759 Q_C = param->pub; | 758 Q_C = param->pub; |