comparison dss.c @ 805:724c3e0c8734 ecc

Add m_mp_alloc_init_multi() helper
author Matt Johnston <matt@ucc.asn.au>
date Thu, 23 May 2013 22:18:16 +0800
parents 7dcb46da72d9
children 220f55d540ae
comparison
equal deleted inserted replaced
804:34b73c9d8aa3 805:724c3e0c8734
45 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 45 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
46 int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key) { 46 int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
47 47
48 TRACE(("enter buf_get_dss_pub_key")) 48 TRACE(("enter buf_get_dss_pub_key"))
49 dropbear_assert(key != NULL); 49 dropbear_assert(key != NULL);
50 key->p = m_malloc(sizeof(mp_int)); 50 m_mp_alloc_init_multi(&key->p, &key->q, &key->g, &key->y, NULL);
51 key->q = m_malloc(sizeof(mp_int));
52 key->g = m_malloc(sizeof(mp_int));
53 key->y = m_malloc(sizeof(mp_int));
54 m_mp_init_multi(key->p, key->q, key->g, key->y, NULL);
55 key->x = NULL; 51 key->x = NULL;
56 52
57 buf_incrpos(buf, 4+SSH_SIGNKEY_DSS_LEN); /* int + "ssh-dss" */ 53 buf_incrpos(buf, 4+SSH_SIGNKEY_DSS_LEN); /* int + "ssh-dss" */
58 if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE 54 if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE
59 || buf_getmpint(buf, key->q) == DROPBEAR_FAILURE 55 || buf_getmpint(buf, key->q) == DROPBEAR_FAILURE
85 ret = buf_get_dss_pub_key(buf, key); 81 ret = buf_get_dss_pub_key(buf, key);
86 if (ret == DROPBEAR_FAILURE) { 82 if (ret == DROPBEAR_FAILURE) {
87 return DROPBEAR_FAILURE; 83 return DROPBEAR_FAILURE;
88 } 84 }
89 85
90 key->x = m_malloc(sizeof(mp_int)); 86 m_mp_alloc_init_multi(&key->x, NULL);
91 m_mp_init(key->x);
92 ret = buf_getmpint(buf, key->x); 87 ret = buf_getmpint(buf, key->x);
93 if (ret == DROPBEAR_FAILURE) { 88 if (ret == DROPBEAR_FAILURE) {
94 m_free(key->x); 89 m_free(key->x);
95 } 90 }
96 91