comparison der_get_multi_integer.c @ 143:5d99163f7e32 libtomcrypt-orig

import of libtomcrypt 0.99
author Matt Johnston <matt@ucc.asn.au>
date Sun, 19 Dec 2004 11:34:45 +0000
parents
children
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
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 * Tom St Denis, [email protected], http://libtomcrypt.org
10 */
11 #include <stdarg.h>
12 #include "mycrypt.h"
13
14 /* will read multiple DER INTEGER encoded mp_ints from src
15 * of upto [inlen] bytes. It will store the number of bytes
16 * read back into [inlen].
17 */
18 int der_get_multi_integer(const unsigned char *src, unsigned long *inlen,
19 mp_int *num, ...)
20 {
21 va_list args;
22 mp_int *next;
23 unsigned long wrote, len;
24 int err;
25
26 _ARGCHK(src != NULL);
27 _ARGCHK(inlen != NULL);
28
29 /* setup va list */
30 next = num;
31 len = *inlen;
32 wrote = 0;
33 va_start(args, num);
34
35 while (next != NULL) {
36 if ((err = der_decode_integer(src, inlen, next)) != CRYPT_OK) {
37 va_end(args);
38 return err;
39 }
40 wrote += *inlen;
41 src += *inlen;
42 len -= *inlen;
43 *inlen = len;
44 next = va_arg(args, mp_int*);
45 }
46 va_end(args);
47 *inlen = wrote;
48 return CRYPT_OK;
49 }
50