summaryrefslogtreecommitdiffhomepage
path: root/rsa.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-05-23 22:18:16 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-05-23 22:18:16 +0800
commitd9e790e7dc7737158c9affb7087035dd2c31c003 (patch)
tree0e610eace4bd5b3f25812e30b85b0c22063c28ef /rsa.c
parent51b5cdd4308f4236d4d1453d482d0086d11a851e (diff)
Add m_mp_alloc_init_multi() helper
--HG-- branch : ecc
Diffstat (limited to 'rsa.c')
-rw-r--r--rsa.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/rsa.c b/rsa.c
index 6fd30b8..92adee4 100644
--- a/rsa.c
+++ b/rsa.c
@@ -50,9 +50,7 @@ int buf_get_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) {
int ret = DROPBEAR_FAILURE;
TRACE(("enter buf_get_rsa_pub_key"))
dropbear_assert(key != NULL);
- key->e = m_malloc(sizeof(mp_int));
- key->n = m_malloc(sizeof(mp_int));
- m_mp_init_multi(key->e, key->n, NULL);
+ m_mp_alloc_init_multi(&key->e, &key->n, NULL);
key->d = NULL;
key->p = NULL;
key->q = NULL;
@@ -98,8 +96,7 @@ int buf_get_rsa_priv_key(buffer* buf, dropbear_rsa_key *key) {
key->p = NULL;
key->q = NULL;
- key->d = m_malloc(sizeof(mp_int));
- m_mp_init(key->d);
+ m_mp_alloc_init_multi(&key->d);
if (buf_getmpint(buf, key->d) == DROPBEAR_FAILURE) {
TRACE(("leave buf_get_rsa_priv_key: d: ret == DROPBEAR_FAILURE"))
goto out;
@@ -108,9 +105,7 @@ int buf_get_rsa_priv_key(buffer* buf, dropbear_rsa_key *key) {
if (buf->pos == buf->len) {
/* old Dropbear private keys didn't keep p and q, so we will ignore them*/
} else {
- key->p = m_malloc(sizeof(mp_int));
- key->q = m_malloc(sizeof(mp_int));
- m_mp_init_multi(key->p, key->q, NULL);
+ m_mp_alloc_init_multi(&key->p, &key->q, NULL);
if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE) {
TRACE(("leave buf_get_rsa_priv_key: p: ret == DROPBEAR_FAILURE"))