Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/math/multi.c
5971 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
#include "tomcrypt.h"
10
11
#ifdef LTC_MPI
12
#include <stdarg.h>
13
14
int ltc_init_multi(void **a, ...)
15
{
16
void **cur = a;
17
int np = 0;
18
va_list args;
19
20
va_start(args, a);
21
while (cur != NULL) {
22
if (mp_init(cur) != CRYPT_OK) {
23
/* failed */
24
va_list clean_list;
25
26
va_start(clean_list, a);
27
cur = a;
28
while (np--) {
29
mp_clear(*cur);
30
cur = va_arg(clean_list, void**);
31
}
32
va_end(clean_list);
33
va_end(args);
34
return CRYPT_MEM;
35
}
36
++np;
37
cur = va_arg(args, void**);
38
}
39
va_end(args);
40
return CRYPT_OK;
41
}
42
43
void ltc_deinit_multi(void *a, ...)
44
{
45
void *cur = a;
46
va_list args;
47
48
va_start(args, a);
49
while (cur != NULL) {
50
mp_clear(cur);
51
cur = va_arg(args, void *);
52
}
53
va_end(args);
54
}
55
56
void ltc_cleanup_multi(void **a, ...)
57
{
58
void **cur = a;
59
va_list args;
60
61
va_start(args, a);
62
while (cur != NULL) {
63
if (*cur != NULL) {
64
mp_clear(*cur);
65
*cur = NULL;
66
}
67
cur = va_arg(args, void**);
68
}
69
va_end(args);
70
}
71
72
#endif
73
74