Mercurial > dropbear
comparison 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 |
comparison
equal
deleted
inserted
replaced
804:34b73c9d8aa3 | 805:724c3e0c8734 |
---|---|
50 cur_arg = va_arg(args, mp_int*); | 50 cur_arg = va_arg(args, mp_int*); |
51 } | 51 } |
52 va_end(args); | 52 va_end(args); |
53 } | 53 } |
54 | 54 |
55 void m_mp_alloc_init_multi(mp_int **mp, ...) | |
56 { | |
57 mp_int** cur_arg = mp; | |
58 va_list args; | |
59 | |
60 va_start(args, mp); /* init args to next argument from caller */ | |
61 while (cur_arg != NULL) { | |
62 *cur_arg = m_malloc(sizeof(mp_int)); | |
63 if (mp_init(*cur_arg) != MP_OKAY) { | |
64 dropbear_exit("Mem alloc error"); | |
65 } | |
66 cur_arg = va_arg(args, mp_int**); | |
67 } | |
68 va_end(args); | |
69 } | |
70 | |
55 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) { | 71 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) { |
56 | 72 |
57 if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) { | 73 if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) { |
58 dropbear_exit("Mem alloc error"); | 74 dropbear_exit("Mem alloc error"); |
59 } | 75 } |