Mercurial > dropbear
comparison rsa.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 | 75509065db53 |
comparison
equal
deleted
inserted
replaced
804:34b73c9d8aa3 | 805:724c3e0c8734 |
---|---|
48 int buf_get_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) { | 48 int buf_get_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) { |
49 | 49 |
50 int ret = DROPBEAR_FAILURE; | 50 int ret = DROPBEAR_FAILURE; |
51 TRACE(("enter buf_get_rsa_pub_key")) | 51 TRACE(("enter buf_get_rsa_pub_key")) |
52 dropbear_assert(key != NULL); | 52 dropbear_assert(key != NULL); |
53 key->e = m_malloc(sizeof(mp_int)); | 53 m_mp_alloc_init_multi(&key->e, &key->n, NULL); |
54 key->n = m_malloc(sizeof(mp_int)); | |
55 m_mp_init_multi(key->e, key->n, NULL); | |
56 key->d = NULL; | 54 key->d = NULL; |
57 key->p = NULL; | 55 key->p = NULL; |
58 key->q = NULL; | 56 key->q = NULL; |
59 | 57 |
60 buf_incrpos(buf, 4+SSH_SIGNKEY_RSA_LEN); /* int + "ssh-rsa" */ | 58 buf_incrpos(buf, 4+SSH_SIGNKEY_RSA_LEN); /* int + "ssh-rsa" */ |
96 | 94 |
97 key->d = NULL; | 95 key->d = NULL; |
98 key->p = NULL; | 96 key->p = NULL; |
99 key->q = NULL; | 97 key->q = NULL; |
100 | 98 |
101 key->d = m_malloc(sizeof(mp_int)); | 99 m_mp_alloc_init_multi(&key->d); |
102 m_mp_init(key->d); | |
103 if (buf_getmpint(buf, key->d) == DROPBEAR_FAILURE) { | 100 if (buf_getmpint(buf, key->d) == DROPBEAR_FAILURE) { |
104 TRACE(("leave buf_get_rsa_priv_key: d: ret == DROPBEAR_FAILURE")) | 101 TRACE(("leave buf_get_rsa_priv_key: d: ret == DROPBEAR_FAILURE")) |
105 goto out; | 102 goto out; |
106 } | 103 } |
107 | 104 |
108 if (buf->pos == buf->len) { | 105 if (buf->pos == buf->len) { |
109 /* old Dropbear private keys didn't keep p and q, so we will ignore them*/ | 106 /* old Dropbear private keys didn't keep p and q, so we will ignore them*/ |
110 } else { | 107 } else { |
111 key->p = m_malloc(sizeof(mp_int)); | 108 m_mp_alloc_init_multi(&key->p, &key->q, NULL); |
112 key->q = m_malloc(sizeof(mp_int)); | |
113 m_mp_init_multi(key->p, key->q, NULL); | |
114 | 109 |
115 if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE) { | 110 if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE) { |
116 TRACE(("leave buf_get_rsa_priv_key: p: ret == DROPBEAR_FAILURE")) | 111 TRACE(("leave buf_get_rsa_priv_key: p: ret == DROPBEAR_FAILURE")) |
117 goto out; | 112 goto out; |
118 } | 113 } |