Mercurial > dropbear
comparison libtommath/bn_mp_init_multi.c @ 1692:1051e4eea25a
Update LibTomMath to 1.2.0 (#84)
* update C files
* update other files
* update headers
* update makefiles
* remove mp_set/get_double()
* use ltm 1.2.0 API
* update ltm_desc
* use bundled tommath if system-tommath is too old
* XMALLOC etc. were changed to MP_MALLOC etc.
author | Steffen Jaeckel <s@jaeckel.eu> |
---|---|
date | Tue, 26 May 2020 17:36:47 +0200 |
parents | f52919ffd3b1 |
children |
comparison
equal
deleted
inserted
replaced
1691:2d3745d58843 | 1692:1051e4eea25a |
---|---|
1 #include "tommath_private.h" | 1 #include "tommath_private.h" |
2 #ifdef BN_MP_INIT_MULTI_C | 2 #ifdef BN_MP_INIT_MULTI_C |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis | 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ |
4 * | 4 /* SPDX-License-Identifier: Unlicense */ |
5 * LibTomMath is a library that provides multiple-precision | |
6 * integer arithmetic as well as number theoretic functionality. | |
7 * | |
8 * The library was designed directly after the MPI library by | |
9 * Michael Fromberger but has been written from scratch with | |
10 * additional optimizations in place. | |
11 * | |
12 * SPDX-License-Identifier: Unlicense | |
13 */ | |
14 | 5 |
15 #include <stdarg.h> | 6 #include <stdarg.h> |
16 | 7 |
17 int mp_init_multi(mp_int *mp, ...) | 8 mp_err mp_init_multi(mp_int *mp, ...) |
18 { | 9 { |
19 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ | 10 mp_err err = MP_OKAY; /* Assume ok until proven otherwise */ |
20 int n = 0; /* Number of ok inits */ | 11 int n = 0; /* Number of ok inits */ |
21 mp_int *cur_arg = mp; | 12 mp_int *cur_arg = mp; |
22 va_list args; | 13 va_list args; |
23 | 14 |
24 va_start(args, mp); /* init args to next argument from caller */ | 15 va_start(args, mp); /* init args to next argument from caller */ |
35 while (n-- != 0) { | 26 while (n-- != 0) { |
36 mp_clear(cur_arg); | 27 mp_clear(cur_arg); |
37 cur_arg = va_arg(clean_args, mp_int *); | 28 cur_arg = va_arg(clean_args, mp_int *); |
38 } | 29 } |
39 va_end(clean_args); | 30 va_end(clean_args); |
40 res = MP_MEM; | 31 err = MP_MEM; |
41 break; | 32 break; |
42 } | 33 } |
43 n++; | 34 n++; |
44 cur_arg = va_arg(args, mp_int *); | 35 cur_arg = va_arg(args, mp_int *); |
45 } | 36 } |
46 va_end(args); | 37 va_end(args); |
47 return res; /* Assumed ok, if error flagged above. */ | 38 return err; /* Assumed ok, if error flagged above. */ |
48 } | 39 } |
49 | 40 |
50 #endif | 41 #endif |
51 | |
52 /* ref: HEAD -> master, tag: v1.1.0 */ | |
53 /* git commit: 08549ad6bc8b0cede0b357a9c341c5c6473a9c55 */ | |
54 /* commit time: 2019-01-28 20:32:32 +0100 */ |