1 /* LibTomMath, multiple-precision integer library -- Tom St Denis
3 * LibTomMath is library that provides for multiple-precision
4 * integer arithmetic as well as number theoretic functionality.
6 * The library is designed directly after the MPI library by
7 * Michael Fromberger but has been written from scratch with
8 * additional optimizations in place.
10 * The library is free for all purposes without any express
13 * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
18 int mp_init_multi(mp_int *mp, ...)
20 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */
21 int n = 0; /* Number of ok inits */
25 va_start(args, mp); /* init args to next argument from caller */
26 while (cur_arg != NULL) {
27 if (mp_init(cur_arg) != MP_OKAY) {
28 /* Oops - error! Back-track and mp_clear what we already
29 succeeded in init-ing, then return error.
33 /* end the current list */
36 /* now start cleaning up */
38 va_start(clean_args, mp);
41 cur_arg = va_arg(clean_args, mp_int*);
48 cur_arg = va_arg(args, mp_int*);
51 return res; /* Assumed ok, if error flagged above. */
54 void mp_clear_multi(mp_int *mp, ...)
59 while (next_mp != NULL) {
61 next_mp = va_arg(args, mp_int*);