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
14 @file der_decode_sequence_multi.c
15 ASN.1 DER, decode a SEQUENCE, Tom St Denis
21 Decode a SEQUENCE type using a VA list
22 @param in Input buffer
23 @param inlen Length of input in octets
24 @remark <...> is of the form <type, size, data> (int, unsigned long, void*)
25 @return CRYPT_OK on success
27 int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...)
31 unsigned long size, x;
36 LTC_ARGCHK(in != NULL);
38 /* get size of output that will be required */
39 va_start(args, inlen);
42 type = (ltc_asn1_type)va_arg(args, int);
43 size = va_arg(args, unsigned long);
44 data = va_arg(args, void*);
45 LTC_UNUSED_PARAM(size);
46 LTC_UNUSED_PARAM(data);
48 if (type == LTC_ASN1_EOL) {
53 case LTC_ASN1_BOOLEAN:
54 case LTC_ASN1_INTEGER:
55 case LTC_ASN1_SHORT_INTEGER:
56 case LTC_ASN1_BIT_STRING:
57 case LTC_ASN1_OCTET_STRING:
59 case LTC_ASN1_OBJECT_IDENTIFIER:
60 case LTC_ASN1_IA5_STRING:
61 case LTC_ASN1_PRINTABLE_STRING:
62 case LTC_ASN1_UTF8_STRING:
63 case LTC_ASN1_UTCTIME:
66 case LTC_ASN1_SEQUENCE:
68 case LTC_ASN1_RAW_BIT_STRING:
69 case LTC_ASN1_TELETEX_STRING:
70 case LTC_ASN1_GENERALIZEDTIME:
75 case LTC_ASN1_CONSTRUCTED:
76 case LTC_ASN1_CONTEXT_SPECIFIC:
78 return CRYPT_INVALID_ARG;
83 /* allocate structure for x elements */
88 list = XCALLOC(sizeof(*list), x);
93 /* fill in the structure */
94 va_start(args, inlen);
97 type = (ltc_asn1_type)va_arg(args, int);
98 size = va_arg(args, unsigned long);
99 data = va_arg(args, void*);
101 if (type == LTC_ASN1_EOL) {
106 case LTC_ASN1_BOOLEAN:
107 case LTC_ASN1_INTEGER:
108 case LTC_ASN1_SHORT_INTEGER:
109 case LTC_ASN1_BIT_STRING:
110 case LTC_ASN1_OCTET_STRING:
112 case LTC_ASN1_OBJECT_IDENTIFIER:
113 case LTC_ASN1_IA5_STRING:
114 case LTC_ASN1_PRINTABLE_STRING:
115 case LTC_ASN1_UTF8_STRING:
116 case LTC_ASN1_UTCTIME:
117 case LTC_ASN1_SEQUENCE:
120 case LTC_ASN1_CHOICE:
121 case LTC_ASN1_RAW_BIT_STRING:
122 case LTC_ASN1_TELETEX_STRING:
123 case LTC_ASN1_GENERALIZEDTIME:
124 LTC_SET_ASN1(list, x++, type, data, size);
126 /* coverity[dead_error_line] */
128 case LTC_ASN1_CONSTRUCTED:
129 case LTC_ASN1_CONTEXT_SPECIFIC:
135 err = der_decode_sequence(in, inlen, list, x);
143 /* ref: $Format:%D$ */
144 /* git commit: $Format:%H$ */
145 /* commit time: $Format:%ai$ */