Mercurial > dropbear
diff bignum.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 | a78a38e402d1 |
children | 7540c0822374 |
line wrap: on
line diff
--- a/bignum.c Tue May 21 13:44:48 2013 +0800 +++ b/bignum.c Thu May 23 22:18:16 2013 +0800 @@ -52,6 +52,22 @@ va_end(args); } +void m_mp_alloc_init_multi(mp_int **mp, ...) +{ + mp_int** cur_arg = mp; + va_list args; + + va_start(args, mp); /* init args to next argument from caller */ + while (cur_arg != NULL) { + *cur_arg = m_malloc(sizeof(mp_int)); + if (mp_init(*cur_arg) != MP_OKAY) { + dropbear_exit("Mem alloc error"); + } + cur_arg = va_arg(args, mp_int**); + } + va_end(args); +} + void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) { if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) {