]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/asn1t.h
Rename DECLARE*STACK_OF to DEFINE*STACK_OF
[thirdparty/openssl.git] / include / openssl / asn1t.h
CommitLineData
9d6b1ce6 1/* asn1t.h */
0f113f3e
MC
2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4 * 2000.
9d6b1ce6
DSH
5 */
6/* ====================================================================
24484759 7 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
9d6b1ce6
DSH
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
0f113f3e 14 * notice, this list of conditions and the following disclaimer.
9d6b1ce6
DSH
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59#ifndef HEADER_ASN1T_H
0f113f3e 60# define HEADER_ASN1T_H
9d6b1ce6 61
0f113f3e
MC
62# include <stddef.h>
63# include <openssl/e_os2.h>
64# include <openssl/asn1.h>
9d6b1ce6 65
0f113f3e
MC
66# ifdef OPENSSL_BUILD_SHLIBCRYPTO
67# undef OPENSSL_EXTERN
68# define OPENSSL_EXTERN OPENSSL_EXPORT
69# endif
26da3e65 70
9d6b1ce6
DSH
71/* ASN1 template defines, structures and functions */
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
0f113f3e 77# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
bb5ea36b
DSH
78
79/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
0f113f3e 80# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
bb5ea36b
DSH
81
82/* Macros for start and end of ASN1_ITEM definition */
83
0f113f3e
MC
84# define ASN1_ITEM_start(itname) \
85 OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {
bb5ea36b 86
df2ee0e2
BL
87# define static_ASN1_ITEM_start(itname) \
88 static const ASN1_ITEM itname##_it = {
89
90# define ASN1_ITEM_end(itname) \
0f113f3e 91 };
bb5ea36b 92
0f113f3e 93# else
bb5ea36b
DSH
94
95/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
0f113f3e 96# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))
bb5ea36b
DSH
97
98/* Macros for start and end of ASN1_ITEM definition */
99
0f113f3e
MC
100# define ASN1_ITEM_start(itname) \
101 const ASN1_ITEM * itname##_it(void) \
102 { \
103 static const ASN1_ITEM local_it = {
bb5ea36b 104
05e97f1d 105# define static_ASN1_ITEM_start(itname) \
03cbd3b8 106 static ASN1_ITEM_start(itname)
05e97f1d 107
0f113f3e
MC
108# define ASN1_ITEM_end(itname) \
109 }; \
110 return &local_it; \
111 }
bb5ea36b 112
0f113f3e 113# endif
bb5ea36b 114
9d6b1ce6
DSH
115/* Macros to aid ASN1 template writing */
116
0f113f3e
MC
117# define ASN1_ITEM_TEMPLATE(tname) \
118 static const ASN1_TEMPLATE tname##_item_tt
119
120# define ASN1_ITEM_TEMPLATE_END(tname) \
121 ;\
122 ASN1_ITEM_start(tname) \
123 ASN1_ITYPE_PRIMITIVE,\
124 -1,\
125 &tname##_item_tt,\
126 0,\
127 NULL,\
128 0,\
129 #tname \
130 ASN1_ITEM_end(tname)
df2ee0e2
BL
131# define static_ASN1_ITEM_TEMPLATE_END(tname) \
132 ;\
133 static_ASN1_ITEM_start(tname) \
134 ASN1_ITYPE_PRIMITIVE,\
135 -1,\
136 &tname##_item_tt,\
137 0,\
138 NULL,\
139 0,\
140 #tname \
141 ASN1_ITEM_end(tname)
9d6b1ce6
DSH
142
143/* This is a ASN1 type which just embeds a template */
0f113f3e
MC
144
145/*-
1d97c843 146 * This pair helps declare a SEQUENCE. We can do:
9d6b1ce6 147 *
0f113f3e
MC
148 * ASN1_SEQUENCE(stname) = {
149 * ... SEQUENCE components ...
150 * } ASN1_SEQUENCE_END(stname)
9d6b1ce6 151 *
0f113f3e
MC
152 * This will produce an ASN1_ITEM called stname_it
153 * for a structure called stname.
9d6b1ce6 154 *
0f113f3e
MC
155 * If you want the same structure but a different
156 * name then use:
9d6b1ce6 157 *
0f113f3e
MC
158 * ASN1_SEQUENCE(itname) = {
159 * ... SEQUENCE components ...
160 * } ASN1_SEQUENCE_END_name(stname, itname)
9d6b1ce6 161 *
0f113f3e
MC
162 * This will create an item called itname_it using
163 * a structure called stname.
9d6b1ce6
DSH
164 */
165
0f113f3e
MC
166# define ASN1_SEQUENCE(tname) \
167 static const ASN1_TEMPLATE tname##_seq_tt[]
168
169# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
170
df2ee0e2
BL
171# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
172
0f113f3e
MC
173# define ASN1_SEQUENCE_END_name(stname, tname) \
174 ;\
175 ASN1_ITEM_start(tname) \
176 ASN1_ITYPE_SEQUENCE,\
177 V_ASN1_SEQUENCE,\
178 tname##_seq_tt,\
179 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
180 NULL,\
181 sizeof(stname),\
182 #stname \
183 ASN1_ITEM_end(tname)
184
df2ee0e2
BL
185# define static_ASN1_SEQUENCE_END_name(stname, tname) \
186 ;\
187 static_ASN1_ITEM_start(tname) \
188 ASN1_ITYPE_SEQUENCE,\
189 V_ASN1_SEQUENCE,\
190 tname##_seq_tt,\
191 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
192 NULL,\
193 sizeof(stname),\
194 #stname \
195 ASN1_ITEM_end(tname)
196
0f113f3e
MC
197# define ASN1_NDEF_SEQUENCE(tname) \
198 ASN1_SEQUENCE(tname)
199
200# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
201 ASN1_SEQUENCE_cb(tname, cb)
202
203# define ASN1_SEQUENCE_cb(tname, cb) \
204 static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
205 ASN1_SEQUENCE(tname)
206
207# define ASN1_BROKEN_SEQUENCE(tname) \
208 static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
209 ASN1_SEQUENCE(tname)
210
211# define ASN1_SEQUENCE_ref(tname, cb, lck) \
212 static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
213 ASN1_SEQUENCE(tname)
214
215# define ASN1_SEQUENCE_enc(tname, enc, cb) \
216 static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
217 ASN1_SEQUENCE(tname)
218
219# define ASN1_NDEF_SEQUENCE_END(tname) \
220 ;\
221 ASN1_ITEM_start(tname) \
222 ASN1_ITYPE_NDEF_SEQUENCE,\
223 V_ASN1_SEQUENCE,\
224 tname##_seq_tt,\
225 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
226 NULL,\
227 sizeof(tname),\
228 #tname \
229 ASN1_ITEM_end(tname)
df2ee0e2
BL
230# define static_ASN1_NDEF_SEQUENCE_END(tname) \
231 ;\
232 static_ASN1_ITEM_start(tname) \
233 ASN1_ITYPE_NDEF_SEQUENCE,\
234 V_ASN1_SEQUENCE,\
235 tname##_seq_tt,\
236 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
237 NULL,\
238 sizeof(tname),\
239 #tname \
240 ASN1_ITEM_end(tname)
0f113f3e
MC
241
242# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
df2ee0e2
BL
243# define static_ASN1_BROKEN_SEQUENCE_END(stname) \
244 static_ASN1_SEQUENCE_END_ref(stname, stname)
0f113f3e
MC
245
246# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
247
248# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
df2ee0e2 249# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
0f113f3e
MC
250
251# define ASN1_SEQUENCE_END_ref(stname, tname) \
252 ;\
253 ASN1_ITEM_start(tname) \
254 ASN1_ITYPE_SEQUENCE,\
255 V_ASN1_SEQUENCE,\
256 tname##_seq_tt,\
257 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
258 &tname##_aux,\
259 sizeof(stname),\
260 #stname \
261 ASN1_ITEM_end(tname)
df2ee0e2
BL
262# define static_ASN1_SEQUENCE_END_ref(stname, tname) \
263 ;\
264 static_ASN1_ITEM_start(tname) \
265 ASN1_ITYPE_SEQUENCE,\
266 V_ASN1_SEQUENCE,\
267 tname##_seq_tt,\
268 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
269 &tname##_aux,\
270 sizeof(stname),\
271 #stname \
272 ASN1_ITEM_end(tname)
0f113f3e
MC
273
274# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
275 ;\
276 ASN1_ITEM_start(tname) \
277 ASN1_ITYPE_NDEF_SEQUENCE,\
278 V_ASN1_SEQUENCE,\
279 tname##_seq_tt,\
280 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
281 &tname##_aux,\
282 sizeof(stname),\
283 #stname \
284 ASN1_ITEM_end(tname)
9d6b1ce6 285
1d97c843
TH
286/*-
287 * This pair helps declare a CHOICE type. We can do:
9d6b1ce6 288 *
0f113f3e
MC
289 * ASN1_CHOICE(chname) = {
290 * ... CHOICE options ...
291 * ASN1_CHOICE_END(chname)
292 *
293 * This will produce an ASN1_ITEM called chname_it
294 * for a structure called chname. The structure
295 * definition must look like this:
296 * typedef struct {
297 * int type;
298 * union {
299 * ASN1_SOMETHING *opt1;
300 * ASN1_SOMEOTHER *opt2;
301 * } value;
302 * } chname;
9d6b1ce6 303 *
0f113f3e
MC
304 * the name of the selector must be 'type'.
305 * to use an alternative selector name use the
9d6b1ce6
DSH
306 * ASN1_CHOICE_END_selector() version.
307 */
308
0f113f3e
MC
309# define ASN1_CHOICE(tname) \
310 static const ASN1_TEMPLATE tname##_ch_tt[]
311
312# define ASN1_CHOICE_cb(tname, cb) \
313 static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
314 ASN1_CHOICE(tname)
315
316# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
317
df2ee0e2
BL
318# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
319
0f113f3e
MC
320# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
321
df2ee0e2
BL
322# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
323
0f113f3e
MC
324# define ASN1_CHOICE_END_selector(stname, tname, selname) \
325 ;\
326 ASN1_ITEM_start(tname) \
327 ASN1_ITYPE_CHOICE,\
328 offsetof(stname,selname) ,\
329 tname##_ch_tt,\
330 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
331 NULL,\
332 sizeof(stname),\
333 #stname \
334 ASN1_ITEM_end(tname)
335
df2ee0e2
BL
336# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
337 ;\
338 static_ASN1_ITEM_start(tname) \
339 ASN1_ITYPE_CHOICE,\
340 offsetof(stname,selname) ,\
341 tname##_ch_tt,\
342 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
343 NULL,\
344 sizeof(stname),\
345 #stname \
346 ASN1_ITEM_end(tname)
347
0f113f3e
MC
348# define ASN1_CHOICE_END_cb(stname, tname, selname) \
349 ;\
350 ASN1_ITEM_start(tname) \
351 ASN1_ITYPE_CHOICE,\
352 offsetof(stname,selname) ,\
353 tname##_ch_tt,\
354 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
355 &tname##_aux,\
356 sizeof(stname),\
357 #stname \
358 ASN1_ITEM_end(tname)
9d6b1ce6
DSH
359
360/* This helps with the template wrapper form of ASN1_ITEM */
361
0f113f3e
MC
362# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
363 (flags), (tag), 0,\
364 #name, ASN1_ITEM_ref(type) }
9d6b1ce6
DSH
365
366/* These help with SEQUENCE or CHOICE components */
367
368/* used to declare other types */
369
0f113f3e
MC
370# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
371 (flags), (tag), offsetof(stname, field),\
372 #field, ASN1_ITEM_ref(type) }
9d6b1ce6 373
9d6b1ce6
DSH
374/* implicit and explicit helper macros */
375
0f113f3e
MC
376# define ASN1_IMP_EX(stname, field, type, tag, ex) \
377 ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
9d6b1ce6 378
0f113f3e
MC
379# define ASN1_EXP_EX(stname, field, type, tag, ex) \
380 ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
9d6b1ce6
DSH
381
382/* Any defined by macros: the field used is in the table itself */
383
0f113f3e
MC
384# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
385# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
386# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
387# else
388# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
389# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
390# endif
9d6b1ce6 391/* Plain simple type */
0f113f3e 392# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
de17bd5d
DSH
393/* Embedded simple type */
394# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
9d6b1ce6
DSH
395
396/* OPTIONAL simple type */
0f113f3e 397# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
9d6b1ce6
DSH
398
399/* IMPLICIT tagged simple type */
0f113f3e 400# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
9d6b1ce6
DSH
401
402/* IMPLICIT tagged OPTIONAL simple type */
0f113f3e 403# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
9d6b1ce6
DSH
404
405/* Same as above but EXPLICIT */
406
0f113f3e
MC
407# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
408# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
9d6b1ce6
DSH
409
410/* SEQUENCE OF type */
0f113f3e
MC
411# define ASN1_SEQUENCE_OF(stname, field, type) \
412 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
9d6b1ce6
DSH
413
414/* OPTIONAL SEQUENCE OF */
0f113f3e
MC
415# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
416 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
9d6b1ce6
DSH
417
418/* Same as above but for SET OF */
419
0f113f3e
MC
420# define ASN1_SET_OF(stname, field, type) \
421 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
9d6b1ce6 422
0f113f3e
MC
423# define ASN1_SET_OF_OPT(stname, field, type) \
424 ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
9d6b1ce6
DSH
425
426/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
427
0f113f3e
MC
428# define ASN1_IMP_SET_OF(stname, field, type, tag) \
429 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
9d6b1ce6 430
0f113f3e
MC
431# define ASN1_EXP_SET_OF(stname, field, type, tag) \
432 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
9d6b1ce6 433
0f113f3e
MC
434# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
435 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
9d6b1ce6 436
0f113f3e
MC
437# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
438 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
9d6b1ce6 439
0f113f3e
MC
440# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
441 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
9d6b1ce6 442
0f113f3e
MC
443# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
444 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
9d6b1ce6 445
0f113f3e
MC
446# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
447 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
9d6b1ce6 448
0f113f3e
MC
449# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
450 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
9d6b1ce6 451
f8492ffe 452/* EXPLICIT using indefinite length constructed form */
0f113f3e
MC
453# define ASN1_NDEF_EXP(stname, field, type, tag) \
454 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
f8492ffe 455
230fd6b7 456/* EXPLICIT OPTIONAL using indefinite length constructed form */
0f113f3e
MC
457# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
458 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
230fd6b7 459
9d6b1ce6
DSH
460/* Macros for the ASN1_ADB structure */
461
0f113f3e
MC
462# define ASN1_ADB(name) \
463 static const ASN1_ADB_TABLE name##_adbtbl[]
464
465# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
466
467# define ASN1_ADB_END(name, flags, field, app_table, def, none) \
468 ;\
469 static const ASN1_ADB name##_adb = {\
470 flags,\
471 offsetof(name, field),\
472 app_table,\
473 name##_adbtbl,\
474 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
475 def,\
476 none\
477 }
9d6b1ce6 478
0f113f3e 479# else
9d6b1ce6 480
0f113f3e
MC
481# define ASN1_ADB_END(name, flags, field, app_table, def, none) \
482 ;\
483 static const ASN1_ITEM *name##_adb(void) \
484 { \
485 static const ASN1_ADB internal_adb = \
486 {\
487 flags,\
488 offsetof(name, field),\
489 app_table,\
490 name##_adbtbl,\
491 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
492 def,\
493 none\
494 }; \
495 return (const ASN1_ITEM *) &internal_adb; \
496 } \
497 void dummy_function(void)
498
499# endif
500
501# define ADB_ENTRY(val, template) {val, template}
502
503# define ASN1_ADB_TEMPLATE(name) \
504 static const ASN1_TEMPLATE name##_tt
505
506/*
507 * This is the ASN1 template structure that defines a wrapper round the
508 * actual type. It determines the actual position of the field in the value
509 * structure, various flags such as OPTIONAL and the field name.
9d6b1ce6
DSH
510 */
511
512struct ASN1_TEMPLATE_st {
0f113f3e
MC
513 unsigned long flags; /* Various flags */
514 long tag; /* tag, not used if no tagging */
515 unsigned long offset; /* Offset of this field in structure */
516# ifndef NO_ASN1_FIELD_NAMES
517 const char *field_name; /* Field name */
518# endif
519 ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
9d6b1ce6
DSH
520};
521
bb5ea36b
DSH
522/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
523
0f113f3e
MC
524# define ASN1_TEMPLATE_item(t) (t->item_ptr)
525# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
9d6b1ce6
DSH
526
527typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
528typedef struct ASN1_ADB_st ASN1_ADB;
529
530struct ASN1_ADB_st {
0f113f3e
MC
531 unsigned long flags; /* Various flags */
532 unsigned long offset; /* Offset of selector field */
533 STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */
534 const ASN1_ADB_TABLE *tbl; /* Table of possible types */
535 long tblcount; /* Number of entries in tbl */
536 const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
537 const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
9d6b1ce6
DSH
538};
539
540struct ASN1_ADB_TABLE_st {
0f113f3e
MC
541 long value; /* NID for an object or value for an int */
542 const ASN1_TEMPLATE tt; /* item for this value */
9d6b1ce6
DSH
543};
544
545/* template flags */
546
547/* Field is optional */
0f113f3e 548# define ASN1_TFLG_OPTIONAL (0x1)
9d6b1ce6
DSH
549
550/* Field is a SET OF */
0f113f3e 551# define ASN1_TFLG_SET_OF (0x1 << 1)
9d6b1ce6
DSH
552
553/* Field is a SEQUENCE OF */
0f113f3e 554# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
9d6b1ce6 555
0f113f3e
MC
556/*
557 * Special case: this refers to a SET OF that will be sorted into DER order
558 * when encoded *and* the corresponding STACK will be modified to match the
559 * new order.
06db4253 560 */
0f113f3e 561# define ASN1_TFLG_SET_ORDER (0x3 << 1)
06db4253
DSH
562
563/* Mask for SET OF or SEQUENCE OF */
0f113f3e 564# define ASN1_TFLG_SK_MASK (0x3 << 1)
9d6b1ce6 565
0f113f3e
MC
566/*
567 * These flags mean the tag should be taken from the tag field. If EXPLICIT
568 * then the underlying type is used for the inner tag.
9d6b1ce6
DSH
569 */
570
571/* IMPLICIT tagging */
0f113f3e 572# define ASN1_TFLG_IMPTAG (0x1 << 3)
9d6b1ce6
DSH
573
574/* EXPLICIT tagging, inner tag from underlying type */
0f113f3e 575# define ASN1_TFLG_EXPTAG (0x2 << 3)
9d6b1ce6 576
0f113f3e 577# define ASN1_TFLG_TAG_MASK (0x3 << 3)
9d6b1ce6
DSH
578
579/* context specific IMPLICIT */
0f113f3e 580# define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
9d6b1ce6
DSH
581
582/* context specific EXPLICIT */
0f113f3e 583# define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
9d6b1ce6 584
0f113f3e
MC
585/*
586 * If tagging is in force these determine the type of tag to use. Otherwise
587 * the tag is determined by the underlying type. These values reflect the
588 * actual octet format.
9d6b1ce6
DSH
589 */
590
0f113f3e
MC
591/* Universal tag */
592# define ASN1_TFLG_UNIVERSAL (0x0<<6)
593/* Application tag */
594# define ASN1_TFLG_APPLICATION (0x1<<6)
595/* Context specific tag */
596# define ASN1_TFLG_CONTEXT (0x2<<6)
597/* Private tag */
598# define ASN1_TFLG_PRIVATE (0x3<<6)
9d6b1ce6 599
0f113f3e 600# define ASN1_TFLG_TAG_CLASS (0x3<<6)
9d6b1ce6 601
0f113f3e
MC
602/*
603 * These are for ANY DEFINED BY type. In this case the 'item' field points to
604 * an ASN1_ADB structure which contains a table of values to decode the
9d6b1ce6
DSH
605 * relevant type
606 */
607
0f113f3e 608# define ASN1_TFLG_ADB_MASK (0x3<<8)
9d6b1ce6 609
0f113f3e 610# define ASN1_TFLG_ADB_OID (0x1<<8)
9d6b1ce6 611
0f113f3e 612# define ASN1_TFLG_ADB_INT (0x1<<9)
9d6b1ce6 613
0f113f3e
MC
614/*
615 * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
616 * indefinite length constructed encoding to be used if required.
230fd6b7
DSH
617 */
618
0f113f3e 619# define ASN1_TFLG_NDEF (0x1<<11)
230fd6b7 620
de17bd5d
DSH
621/* Field is embedded and not a pointer */
622# define ASN1_TFLG_EMBED (0x1 << 12)
623
9d6b1ce6
DSH
624/* This is the actual ASN1 item itself */
625
626struct ASN1_ITEM_st {
0f113f3e
MC
627 char itype; /* The item type, primitive, SEQUENCE, CHOICE
628 * or extern */
629 long utype; /* underlying type */
630 const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
631 * the contents */
632 long tcount; /* Number of templates if SEQUENCE or CHOICE */
633 const void *funcs; /* functions that handle this type */
634 long size; /* Structure size (usually) */
635# ifndef NO_ASN1_FIELD_NAMES
636 const char *sname; /* Structure name */
637# endif
9d6b1ce6
DSH
638};
639
c80fd6b2
MC
640/*-
641 * These are values for the itype field and
9d6b1ce6
DSH
642 * determine how the type is interpreted.
643 *
644 * For PRIMITIVE types the underlying type
645 * determines the behaviour if items is NULL.
646 *
0f113f3e 647 * Otherwise templates must contain a single
9d6b1ce6
DSH
648 * template and the type is treated in the
649 * same way as the type specified in the template.
650 *
651 * For SEQUENCE types the templates field points
652 * to the members, the size field is the
653 * structure size.
654 *
655 * For CHOICE types the templates field points
656 * to each possible member (typically a union)
657 * and the 'size' field is the offset of the
658 * selector.
659 *
660 * The 'funcs' field is used for application
0f113f3e 661 * specific functions.
9d6b1ce6 662 *
9d6b1ce6
DSH
663 * The EXTERN type uses a new style d2i/i2d.
664 * The new style should be used where possible
665 * because it avoids things like the d2i IMPLICIT
666 * hack.
667 *
668 * MSTRING is a multiple string type, it is used
669 * for a CHOICE of character strings where the
670 * actual strings all occupy an ASN1_STRING
671 * structure. In this case the 'utype' field
672 * has a special meaning, it is used as a mask
673 * of acceptable types using the B_ASN1 constants.
674 *
230fd6b7
DSH
675 * NDEF_SEQUENCE is the same as SEQUENCE except
676 * that it will use indefinite length constructed
677 * encoding if requested.
678 *
9d6b1ce6
DSH
679 */
680
0f113f3e 681# define ASN1_ITYPE_PRIMITIVE 0x0
230fd6b7 682
0f113f3e 683# define ASN1_ITYPE_SEQUENCE 0x1
9d6b1ce6 684
0f113f3e 685# define ASN1_ITYPE_CHOICE 0x2
9d6b1ce6 686
0f113f3e 687# define ASN1_ITYPE_EXTERN 0x4
9d6b1ce6 688
0f113f3e 689# define ASN1_ITYPE_MSTRING 0x5
9d6b1ce6 690
0f113f3e 691# define ASN1_ITYPE_NDEF_SEQUENCE 0x6
9d6b1ce6 692
0f113f3e
MC
693/*
694 * Cache for ASN1 tag and length, so we don't keep re-reading it for things
9d6b1ce6
DSH
695 * like CHOICE
696 */
697
0f113f3e
MC
698struct ASN1_TLC_st {
699 char valid; /* Values below are valid */
700 int ret; /* return value */
701 long plen; /* length */
702 int ptag; /* class value */
703 int pclass; /* class value */
704 int hdrlen; /* header length */
9d6b1ce6
DSH
705};
706
707/* Typedefs for ASN1 function pointers */
708
0f113f3e 709typedef ASN1_VALUE *ASN1_new_func(void);
9d6b1ce6 710typedef void ASN1_free_func(ASN1_VALUE *a);
0f113f3e
MC
711typedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,
712 long length);
713typedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);
9d6b1ce6 714
0f113f3e
MC
715typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
716 const ASN1_ITEM *it, int tag, int aclass, char opt,
717 ASN1_TLC *ctx);
9d6b1ce6 718
0f113f3e
MC
719typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
720 const ASN1_ITEM *it, int tag, int aclass);
9d6b1ce6
DSH
721typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
722typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
723
0f113f3e
MC
724typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
725 int indent, const char *fname,
726 const ASN1_PCTX *pctx);
1ef7acfe 727
0f113f3e
MC
728typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,
729 int *putype, const ASN1_ITEM *it);
730typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
731 int len, int utype, char *free_cont,
732 const ASN1_ITEM *it);
733typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,
734 const ASN1_ITEM *it, int indent,
735 const ASN1_PCTX *pctx);
9d6b1ce6 736
9d6b1ce6 737typedef struct ASN1_EXTERN_FUNCS_st {
0f113f3e
MC
738 void *app_data;
739 ASN1_ex_new_func *asn1_ex_new;
740 ASN1_ex_free_func *asn1_ex_free;
741 ASN1_ex_free_func *asn1_ex_clear;
742 ASN1_ex_d2i *asn1_ex_d2i;
743 ASN1_ex_i2d *asn1_ex_i2d;
744 ASN1_ex_print_func *asn1_ex_print;
9d6b1ce6
DSH
745} ASN1_EXTERN_FUNCS;
746
747typedef struct ASN1_PRIMITIVE_FUNCS_st {
0f113f3e
MC
748 void *app_data;
749 unsigned long flags;
750 ASN1_ex_new_func *prim_new;
751 ASN1_ex_free_func *prim_free;
752 ASN1_ex_free_func *prim_clear;
753 ASN1_primitive_c2i *prim_c2i;
754 ASN1_primitive_i2c *prim_i2c;
755 ASN1_primitive_print *prim_print;
9d6b1ce6
DSH
756} ASN1_PRIMITIVE_FUNCS;
757
0f113f3e
MC
758/*
759 * This is the ASN1_AUX structure: it handles various miscellaneous
760 * requirements. For example the use of reference counts and an informational
761 * callback. The "informational callback" is called at various points during
762 * the ASN1 encoding and decoding. It can be used to provide minor
763 * customisation of the structures used. This is most useful where the
764 * supplied routines *almost* do the right thing but need some extra help at
765 * a few points. If the callback returns zero then it is assumed a fatal
766 * error has occurred and the main operation should be abandoned. If major
767 * changes in the default behaviour are required then an external type is
768 * more appropriate.
9d6b1ce6
DSH
769 */
770
24484759 771typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
0f113f3e 772 void *exarg);
9d6b1ce6
DSH
773
774typedef struct ASN1_AUX_st {
0f113f3e
MC
775 void *app_data;
776 int flags;
777 int ref_offset; /* Offset of reference value */
778 int ref_lock; /* Lock type to use */
779 ASN1_aux_cb *asn1_cb;
780 int enc_offset; /* Offset of ASN1_ENCODING structure */
9d6b1ce6
DSH
781} ASN1_AUX;
782
24484759
DSH
783/* For print related callbacks exarg points to this structure */
784typedef struct ASN1_PRINT_ARG_st {
0f113f3e
MC
785 BIO *out;
786 int indent;
787 const ASN1_PCTX *pctx;
24484759
DSH
788} ASN1_PRINT_ARG;
789
8931b30d
DSH
790/* For streaming related callbacks exarg points to this structure */
791typedef struct ASN1_STREAM_ARG_st {
0f113f3e
MC
792 /* BIO to stream through */
793 BIO *out;
794 /* BIO with filters appended */
795 BIO *ndef_bio;
796 /* Streaming I/O boundary */
797 unsigned char **boundary;
8931b30d
DSH
798} ASN1_STREAM_ARG;
799
9d6b1ce6
DSH
800/* Flags in ASN1_AUX */
801
802/* Use a reference count */
0f113f3e 803# define ASN1_AFLG_REFCOUNT 1
9d6b1ce6 804/* Save the encoding of structure (useful for signatures) */
0f113f3e 805# define ASN1_AFLG_ENCODING 2
9d6b1ce6 806/* The Sequence length is invalid */
0f113f3e 807# define ASN1_AFLG_BROKEN 4
9d6b1ce6
DSH
808
809/* operation values for asn1_cb */
810
0f113f3e
MC
811# define ASN1_OP_NEW_PRE 0
812# define ASN1_OP_NEW_POST 1
813# define ASN1_OP_FREE_PRE 2
814# define ASN1_OP_FREE_POST 3
815# define ASN1_OP_D2I_PRE 4
816# define ASN1_OP_D2I_POST 5
817# define ASN1_OP_I2D_PRE 6
818# define ASN1_OP_I2D_POST 7
819# define ASN1_OP_PRINT_PRE 8
820# define ASN1_OP_PRINT_POST 9
821# define ASN1_OP_STREAM_PRE 10
822# define ASN1_OP_STREAM_POST 11
823# define ASN1_OP_DETACHED_PRE 12
824# define ASN1_OP_DETACHED_POST 13
9d6b1ce6
DSH
825
826/* Macro to implement a primitive type */
0f113f3e
MC
827# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
828# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
829 ASN1_ITEM_start(itname) \
830 ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
831 ASN1_ITEM_end(itname)
9d6b1ce6
DSH
832
833/* Macro to implement a multi string type */
0f113f3e
MC
834# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
835 ASN1_ITEM_start(itname) \
836 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
837 ASN1_ITEM_end(itname)
9d6b1ce6 838
0f113f3e
MC
839# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
840 ASN1_ITEM_start(sname) \
841 ASN1_ITYPE_EXTERN, \
842 tag, \
843 NULL, \
844 0, \
845 &fptrs, \
846 0, \
847 #sname \
848 ASN1_ITEM_end(sname)
9d6b1ce6
DSH
849
850/* Macro to implement standard functions in terms of ASN1_ITEM structures */
851
0f113f3e
MC
852# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
853
854# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
855
856# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
857 IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
858
859# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
860 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
861
862# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
863 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
864
865# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
866 pre stname *fname##_new(void) \
867 { \
868 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
869 } \
870 pre void fname##_free(stname *a) \
871 { \
872 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
873 }
874
875# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
876 stname *fname##_new(void) \
877 { \
878 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
879 } \
880 void fname##_free(stname *a) \
881 { \
882 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
883 }
884
885# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
886 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
887 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
888
889# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
890 stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
891 { \
892 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
893 } \
894 int i2d_##fname(stname *a, unsigned char **out) \
895 { \
896 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
897 }
898
899# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
900 int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
901 { \
902 return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
903 }
904
4fb6b0de
DSH
905# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
906 static stname *d2i_##stname(stname **a, \
907 const unsigned char **in, long len) \
908 { \
909 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
910 ASN1_ITEM_rptr(stname)); \
911 } \
912 static int i2d_##stname(stname *a, unsigned char **out) \
913 { \
914 return ASN1_item_i2d((ASN1_VALUE *)a, out, \
915 ASN1_ITEM_rptr(stname)); \
916 }
917
0f113f3e
MC
918/*
919 * This includes evil casts to remove const: they will go away when full ASN1
920 * constification is done.
9d6b1ce6 921 */
0f113f3e
MC
922# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
923 stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
924 { \
925 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
926 } \
927 int i2d_##fname(const stname *a, unsigned char **out) \
928 { \
929 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
930 }
931
932# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
933 stname * stname##_dup(stname *x) \
1241126a
DSH
934 { \
935 return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
936 }
937
0f113f3e
MC
938# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
939 IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
9194296d 940
0f113f3e
MC
941# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
942 int fname##_print_ctx(BIO *out, stname *x, int indent, \
943 const ASN1_PCTX *pctx) \
944 { \
945 return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
946 ASN1_ITEM_rptr(itname), pctx); \
947 }
9194296d 948
0f113f3e
MC
949# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
950 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
9d6b1ce6 951
0f113f3e
MC
952# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
953 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
954 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
9d6b1ce6
DSH
955
956/* external definitions for primitive types */
957
bb5ea36b
DSH
958DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
959DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
960DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
bb5ea36b
DSH
961DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
962DECLARE_ASN1_ITEM(CBIGNUM)
963DECLARE_ASN1_ITEM(BIGNUM)
964DECLARE_ASN1_ITEM(LONG)
965DECLARE_ASN1_ITEM(ZLONG)
9d6b1ce6 966
85885715 967DEFINE_STACK_OF(ASN1_VALUE)
9d6b1ce6
DSH
968
969/* Functions used internally by the ASN1 code */
970
971int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
972void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
9d6b1ce6 973
0f113f3e
MC
974int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
975 const ASN1_ITEM *it, int tag, int aclass, char opt,
976 ASN1_TLC *ctx);
977
978int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
979 const ASN1_ITEM *it, int tag, int aclass);
9d6b1ce6 980
9d6b1ce6
DSH
981#ifdef __cplusplus
982}
983#endif
984#endif