diff ecc.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 70625eed40c9
children 7540c0822374
line wrap: on
line diff
--- a/ecc.c	Tue May 21 13:44:48 2013 +0800
+++ b/ecc.c	Thu May 23 22:18:16 2013 +0800
@@ -72,11 +72,8 @@
 
 ecc_key * new_ecc_key(void) {
 	ecc_key *key = m_malloc(sizeof(*key));
-	key->pubkey.x = m_malloc(sizeof(mp_int));
-	key->pubkey.y = m_malloc(sizeof(mp_int));
-	key->pubkey.z = m_malloc(sizeof(mp_int));
-	key->k = m_malloc(sizeof(mp_int));
-	m_mp_init_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, key->k, NULL);
+	m_mp_alloc_init_multi(&key->pubkey.x, &key->pubkey.y, 
+		&key->pubkey.z, &key->k, NULL);
 	return key;
 }
 
@@ -92,7 +89,7 @@
 	t1 = m_malloc(sizeof(mp_int));
 	t2 = m_malloc(sizeof(mp_int));
 	
-	m_mp_init_multi(prime, b, t1, t2, NULL);
+	m_mp_alloc_init_multi(&prime, &b, &t1, &t2, NULL);
 	
    /* load prime and b */
 	if ((err = mp_read_radix(prime, key->dp->prime, 16)) != CRYPT_OK)                          { goto error; }