1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
6
* The library is free for all purposes without any express
9
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
16
@file der_encode_sequence_multi.c
17
ASN.1 DER, encode a SEQUENCE, Tom St Denis
22
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
25
unsigned long size, x;
30
LTC_ARGCHK(out != NULL);
31
LTC_ARGCHK(outlen != NULL);
33
/* get size of output that will be required */
34
va_start(args, outlen);
37
type = va_arg(args, int);
38
size = va_arg(args, unsigned long);
39
data = va_arg(args, void*);
41
if (type == LTC_ASN1_EOL) {
46
case LTC_ASN1_INTEGER:
47
case LTC_ASN1_SHORT_INTEGER:
48
case LTC_ASN1_BIT_STRING:
49
case LTC_ASN1_OCTET_STRING:
51
case LTC_ASN1_OBJECT_IDENTIFIER:
52
case LTC_ASN1_IA5_STRING:
53
case LTC_ASN1_PRINTABLE_STRING:
54
case LTC_ASN1_UTCTIME:
55
case LTC_ASN1_SEQUENCE:
61
return CRYPT_INVALID_ARG;
66
/* allocate structure for x elements */
71
list = XCALLOC(sizeof(*list), x);
76
/* fill in the structure */
77
va_start(args, outlen);
80
type = va_arg(args, int);
81
size = va_arg(args, unsigned long);
82
data = va_arg(args, void*);
84
if (type == LTC_ASN1_EOL) {
89
case LTC_ASN1_INTEGER:
90
case LTC_ASN1_SHORT_INTEGER:
91
case LTC_ASN1_BIT_STRING:
92
case LTC_ASN1_OCTET_STRING:
94
case LTC_ASN1_OBJECT_IDENTIFIER:
95
case LTC_ASN1_IA5_STRING:
96
case LTC_ASN1_PRINTABLE_STRING:
97
case LTC_ASN1_UTCTIME:
98
case LTC_ASN1_SEQUENCE:
101
list[x++].data = data;
106
err = CRYPT_INVALID_ARG;
112
err = der_encode_sequence(list, x, out, outlen);
121
/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */
122
/* $Revision: 1.6 $ */
123
/* $Date: 2005/06/18 19:20:23 $ */