Mercurial > dropbear
comparison libtommath/bn_mp_init_multi.c @ 1655:f52919ffd3b1
update ltm to 1.1.0 and enable FIPS 186.4 compliant key-generation (#79)
* make key-generation compliant to FIPS 186.4
* fix includes in tommath_class.h
* update fuzzcorpus instead of error-out
* fixup fuzzing make-targets
* update Makefile.in
* apply necessary patches to ltm sources
* clean-up not required ltm files
* update to vanilla ltm 1.1.0
this already only contains the required files
* remove set/get double
author | Steffen Jaeckel <s_jaeckel@gmx.de> |
---|---|
date | Mon, 16 Sep 2019 15:50:38 +0200 |
parents | 8bba51a55704 |
children | 1051e4eea25a |
comparison
equal
deleted
inserted
replaced
1654:cc0fc5131c5c | 1655:f52919ffd3b1 |
---|---|
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 * |
5 * LibTomMath is a library that provides multiple-precision | 5 * LibTomMath is a library that provides multiple-precision |
6 * integer arithmetic as well as number theoretic functionality. | 6 * integer arithmetic as well as number theoretic functionality. |
7 * | 7 * |
8 * The library was designed directly after the MPI library by | 8 * The library was designed directly after the MPI library by |
9 * Michael Fromberger but has been written from scratch with | 9 * Michael Fromberger but has been written from scratch with |
10 * additional optimizations in place. | 10 * additional optimizations in place. |
11 * | 11 * |
12 * The library is free for all purposes without any express | 12 * SPDX-License-Identifier: Unlicense |
13 * guarantee it works. | |
14 * | |
15 * Tom St Denis, [email protected], http://libtom.org | |
16 */ | 13 */ |
14 | |
17 #include <stdarg.h> | 15 #include <stdarg.h> |
18 | 16 |
19 int mp_init_multi(mp_int *mp, ...) | 17 int mp_init_multi(mp_int *mp, ...) |
20 { | 18 { |
21 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ | 19 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ |
22 int n = 0; /* Number of ok inits */ | 20 int n = 0; /* Number of ok inits */ |
23 mp_int* cur_arg = mp; | 21 mp_int *cur_arg = mp; |
24 va_list args; | 22 va_list args; |
25 | 23 |
26 va_start(args, mp); /* init args to next argument from caller */ | 24 va_start(args, mp); /* init args to next argument from caller */ |
27 while (cur_arg != NULL) { | 25 while (cur_arg != NULL) { |
28 if (mp_init(cur_arg) != MP_OKAY) { | 26 if (mp_init(cur_arg) != MP_OKAY) { |
29 /* Oops - error! Back-track and mp_clear what we already | 27 /* Oops - error! Back-track and mp_clear what we already |
30 succeeded in init-ing, then return error. | 28 succeeded in init-ing, then return error. |
31 */ | 29 */ |
32 va_list clean_args; | 30 va_list clean_args; |
33 | 31 |
34 /* now start cleaning up */ | 32 /* now start cleaning up */ |
35 cur_arg = mp; | 33 cur_arg = mp; |
36 va_start(clean_args, mp); | 34 va_start(clean_args, mp); |
37 while (n-- != 0) { | 35 while (n-- != 0) { |
38 mp_clear(cur_arg); | 36 mp_clear(cur_arg); |
39 cur_arg = va_arg(clean_args, mp_int*); | 37 cur_arg = va_arg(clean_args, mp_int *); |
40 } | 38 } |
41 va_end(clean_args); | 39 va_end(clean_args); |
42 res = MP_MEM; | 40 res = MP_MEM; |
43 break; | 41 break; |
44 } | 42 } |
45 n++; | 43 n++; |
46 cur_arg = va_arg(args, mp_int*); | 44 cur_arg = va_arg(args, mp_int *); |
47 } | 45 } |
48 va_end(args); | 46 va_end(args); |
49 return res; /* Assumed ok, if error flagged above. */ | 47 return res; /* Assumed ok, if error flagged above. */ |
50 } | 48 } |
51 | 49 |
52 #endif | 50 #endif |
53 | 51 |
54 /* ref: $Format:%D$ */ | 52 /* ref: HEAD -> master, tag: v1.1.0 */ |
55 /* git commit: $Format:%H$ */ | 53 /* git commit: 08549ad6bc8b0cede0b357a9c341c5c6473a9c55 */ |
56 /* commit time: $Format:%ai$ */ | 54 /* commit time: 2019-01-28 20:32:32 +0100 */ |