asn1t.h 32.2 KB
Newer Older
1
/*
R
Rich Salz 已提交
2
 * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
D
 
Dr. Stephen Henson 已提交
3
 *
R
Rich Salz 已提交
4 5 6 7
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
D
 
Dr. Stephen Henson 已提交
8
 */
R
Rich Salz 已提交
9

D
 
Dr. Stephen Henson 已提交
10
#ifndef HEADER_ASN1T_H
11
# define HEADER_ASN1T_H
D
 
Dr. Stephen Henson 已提交
12

13 14 15
# include <stddef.h>
# include <openssl/e_os2.h>
# include <openssl/asn1.h>
D
 
Dr. Stephen Henson 已提交
16

17 18 19 20
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
#  undef OPENSSL_EXTERN
#  define OPENSSL_EXTERN OPENSSL_EXPORT
# endif
21

D
 
Dr. Stephen Henson 已提交
22 23 24 25 26 27
/* ASN1 template defines, structures and functions */

#ifdef  __cplusplus
extern "C" {
#endif

28
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
29 30

/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
31
#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
32 33 34

/* Macros for start and end of ASN1_ITEM definition */

35
#  define ASN1_ITEM_start(itname) \
36
        const ASN1_ITEM itname##_it = {
37

38 39 40 41
#  define static_ASN1_ITEM_start(itname) \
        static const ASN1_ITEM itname##_it = {

#  define ASN1_ITEM_end(itname)                 \
42
                };
43

44
# else
45 46

/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
47
#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))
48 49 50

/* Macros for start and end of ASN1_ITEM definition */

51 52 53 54
#  define ASN1_ITEM_start(itname) \
        const ASN1_ITEM * itname##_it(void) \
        { \
                static const ASN1_ITEM local_it = {
55

A
Alessandro Ghedini 已提交
56
#  define static_ASN1_ITEM_start(itname) \
57
        static ASN1_ITEM_start(itname)
A
Alessandro Ghedini 已提交
58

59 60 61 62
#  define ASN1_ITEM_end(itname) \
                }; \
        return &local_it; \
        }
63

64
# endif
65

D
 
Dr. Stephen Henson 已提交
66 67
/* Macros to aid ASN1 template writing */

68 69 70 71 72 73 74 75 76 77 78 79 80 81
# define ASN1_ITEM_TEMPLATE(tname) \
        static const ASN1_TEMPLATE tname##_item_tt

# define ASN1_ITEM_TEMPLATE_END(tname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_PRIMITIVE,\
                -1,\
                &tname##_item_tt,\
                0,\
                NULL,\
                0,\
                #tname \
        ASN1_ITEM_end(tname)
82 83 84 85 86 87 88 89 90 91 92
# define static_ASN1_ITEM_TEMPLATE_END(tname) \
        ;\
        static_ASN1_ITEM_start(tname) \
                ASN1_ITYPE_PRIMITIVE,\
                -1,\
                &tname##_item_tt,\
                0,\
                NULL,\
                0,\
                #tname \
        ASN1_ITEM_end(tname)
D
 
Dr. Stephen Henson 已提交
93 94

/* This is a ASN1 type which just embeds a template */
95 96

/*-
97
 * This pair helps declare a SEQUENCE. We can do:
D
 
Dr. Stephen Henson 已提交
98
 *
99 100 101
 *      ASN1_SEQUENCE(stname) = {
 *              ... SEQUENCE components ...
 *      } ASN1_SEQUENCE_END(stname)
D
 
Dr. Stephen Henson 已提交
102
 *
103 104
 *      This will produce an ASN1_ITEM called stname_it
 *      for a structure called stname.
D
 
Dr. Stephen Henson 已提交
105
 *
106 107
 *      If you want the same structure but a different
 *      name then use:
D
 
Dr. Stephen Henson 已提交
108
 *
109 110 111
 *      ASN1_SEQUENCE(itname) = {
 *              ... SEQUENCE components ...
 *      } ASN1_SEQUENCE_END_name(stname, itname)
D
 
Dr. Stephen Henson 已提交
112
 *
113 114
 *      This will create an item called itname_it using
 *      a structure called stname.
D
 
Dr. Stephen Henson 已提交
115 116
 */

117 118 119 120 121
# define ASN1_SEQUENCE(tname) \
        static const ASN1_TEMPLATE tname##_seq_tt[]

# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)

122 123
# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)

124 125 126 127 128 129 130 131 132
# define ASN1_SEQUENCE_END_name(stname, tname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(stname),\
133
                #tname \
134 135
        ASN1_ITEM_end(tname)

136 137 138 139 140 141 142 143 144 145 146 147
# define static_ASN1_SEQUENCE_END_name(stname, tname) \
        ;\
        static_ASN1_ITEM_start(tname) \
                ASN1_ITYPE_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)

148 149 150 151 152 153 154 155 156 157 158 159 160 161
# define ASN1_NDEF_SEQUENCE(tname) \
        ASN1_SEQUENCE(tname)

# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
        ASN1_SEQUENCE_cb(tname, cb)

# define ASN1_SEQUENCE_cb(tname, cb) \
        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
        ASN1_SEQUENCE(tname)

# define ASN1_BROKEN_SEQUENCE(tname) \
        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
        ASN1_SEQUENCE(tname)

162 163
# define ASN1_SEQUENCE_ref(tname, cb) \
        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
        ASN1_SEQUENCE(tname)

# define ASN1_SEQUENCE_enc(tname, enc, cb) \
        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
        ASN1_SEQUENCE(tname)

# define ASN1_NDEF_SEQUENCE_END(tname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_NDEF_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(tname),\
                #tname \
        ASN1_ITEM_end(tname)
181 182
# define static_ASN1_NDEF_SEQUENCE_END(tname) \
        ;\
F
FdaSilvaYY 已提交
183
        static_ASN1_ITEM_start(tname) \
184 185 186 187 188 189 190 191
                ASN1_ITYPE_NDEF_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(tname),\
                #tname \
        ASN1_ITEM_end(tname)
192 193

# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
194
# define static_ASN1_BROKEN_SEQUENCE_END(stname) \
F
FdaSilvaYY 已提交
195
        static_ASN1_SEQUENCE_END_ref(stname, stname)
196 197 198 199

# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)

# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
200
# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
201 202 203 204 205 206 207 208 209 210

# define ASN1_SEQUENCE_END_ref(stname, tname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                &tname##_aux,\
                sizeof(stname),\
211
                #tname \
212
        ASN1_ITEM_end(tname)
213 214 215 216 217 218 219 220 221 222 223
# define static_ASN1_SEQUENCE_END_ref(stname, tname) \
        ;\
        static_ASN1_ITEM_start(tname) \
                ASN1_ITYPE_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                &tname##_aux,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)
224 225 226 227 228 229 230 231 232 233 234 235

# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_NDEF_SEQUENCE,\
                V_ASN1_SEQUENCE,\
                tname##_seq_tt,\
                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
                &tname##_aux,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)
D
 
Dr. Stephen Henson 已提交
236

237 238
/*-
 * This pair helps declare a CHOICE type. We can do:
D
 
Dr. Stephen Henson 已提交
239
 *
240 241 242 243 244 245 246 247 248 249 250 251 252 253
 *      ASN1_CHOICE(chname) = {
 *              ... CHOICE options ...
 *      ASN1_CHOICE_END(chname)
 *
 *      This will produce an ASN1_ITEM called chname_it
 *      for a structure called chname. The structure
 *      definition must look like this:
 *      typedef struct {
 *              int type;
 *              union {
 *                      ASN1_SOMETHING *opt1;
 *                      ASN1_SOMEOTHER *opt2;
 *              } value;
 *      } chname;
D
 
Dr. Stephen Henson 已提交
254
 *
255 256
 *      the name of the selector must be 'type'.
 *      to use an alternative selector name use the
D
 
Dr. Stephen Henson 已提交
257 258 259
 *      ASN1_CHOICE_END_selector() version.
 */

260 261 262 263 264 265 266 267 268
# define ASN1_CHOICE(tname) \
        static const ASN1_TEMPLATE tname##_ch_tt[]

# define ASN1_CHOICE_cb(tname, cb) \
        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
        ASN1_CHOICE(tname)

# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)

269 270
# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)

271 272
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)

273 274
# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)

275 276 277 278 279 280 281 282 283 284 285 286
# define ASN1_CHOICE_END_selector(stname, tname, selname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_CHOICE,\
                offsetof(stname,selname) ,\
                tname##_ch_tt,\
                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)

287 288 289 290 291 292 293 294 295 296 297 298
# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
        ;\
        static_ASN1_ITEM_start(tname) \
                ASN1_ITYPE_CHOICE,\
                offsetof(stname,selname) ,\
                tname##_ch_tt,\
                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
                NULL,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)

299 300 301 302 303 304 305 306 307 308 309
# define ASN1_CHOICE_END_cb(stname, tname, selname) \
        ;\
        ASN1_ITEM_start(tname) \
                ASN1_ITYPE_CHOICE,\
                offsetof(stname,selname) ,\
                tname##_ch_tt,\
                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
                &tname##_aux,\
                sizeof(stname),\
                #stname \
        ASN1_ITEM_end(tname)
D
 
Dr. Stephen Henson 已提交
310 311 312

/* This helps with the template wrapper form of ASN1_ITEM */

313 314 315
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
        (flags), (tag), 0,\
        #name, ASN1_ITEM_ref(type) }
D
 
Dr. Stephen Henson 已提交
316 317 318 319 320

/* These help with SEQUENCE or CHOICE components */

/* used to declare other types */

321 322 323
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
        (flags), (tag), offsetof(stname, field),\
        #field, ASN1_ITEM_ref(type) }
D
 
Dr. Stephen Henson 已提交
324 325 326

/* implicit and explicit helper macros */

327
# define ASN1_IMP_EX(stname, field, type, tag, ex) \
328
         ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)
D
 
Dr. Stephen Henson 已提交
329

330
# define ASN1_EXP_EX(stname, field, type, tag, ex) \
331
         ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)
D
 
Dr. Stephen Henson 已提交
332 333 334

/* Any defined by macros: the field used is in the table itself */

335 336 337 338 339 340 341
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
# else
#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
# endif
D
 
Dr. Stephen Henson 已提交
342
/* Plain simple type */
343
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
D
Dr. Stephen Henson 已提交
344 345
/* Embedded simple type */
# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
346 347

/* OPTIONAL simple type */
348
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
349
# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
350 351

/* IMPLICIT tagged simple type */
352
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
353
# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
D
 
Dr. Stephen Henson 已提交
354 355

/* IMPLICIT tagged OPTIONAL simple type */
356
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
357
# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
D
 
Dr. Stephen Henson 已提交
358 359 360

/* Same as above but EXPLICIT */

361
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
362
# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
363
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
364
# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
D
 
Dr. Stephen Henson 已提交
365 366

/* SEQUENCE OF type */
367 368
# define ASN1_SEQUENCE_OF(stname, field, type) \
                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
369 370

/* OPTIONAL SEQUENCE OF */
371 372
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
373 374 375

/* Same as above but for SET OF */

376 377
# define ASN1_SET_OF(stname, field, type) \
                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
378

379 380
# define ASN1_SET_OF_OPT(stname, field, type) \
                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
D
 
Dr. Stephen Henson 已提交
381 382 383

/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */

384 385
# define ASN1_IMP_SET_OF(stname, field, type, tag) \
                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
D
 
Dr. Stephen Henson 已提交
386

387 388
# define ASN1_EXP_SET_OF(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
D
 
Dr. Stephen Henson 已提交
389

390 391
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
D
 
Dr. Stephen Henson 已提交
392

393 394
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
D
 
Dr. Stephen Henson 已提交
395

396 397
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
D
 
Dr. Stephen Henson 已提交
398

399 400
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
D
 
Dr. Stephen Henson 已提交
401

402 403
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
D
 
Dr. Stephen Henson 已提交
404

405 406
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
D
 
Dr. Stephen Henson 已提交
407

408
/* EXPLICIT using indefinite length constructed form */
409 410
# define ASN1_NDEF_EXP(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
411

412
/* EXPLICIT OPTIONAL using indefinite length constructed form */
413 414
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
415

D
 
Dr. Stephen Henson 已提交
416 417
/* Macros for the ASN1_ADB structure */

418 419 420 421 422
# define ASN1_ADB(name) \
        static const ASN1_ADB_TABLE name##_adbtbl[]

# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION

D
Dr. Stephen Henson 已提交
423
#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
424 425 426 427
        ;\
        static const ASN1_ADB name##_adb = {\
                flags,\
                offsetof(name, field),\
D
Dr. Stephen Henson 已提交
428
                adb_cb,\
429 430 431 432 433
                name##_adbtbl,\
                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
                def,\
                none\
        }
D
 
Dr. Stephen Henson 已提交
434

435
# else
D
 
Dr. Stephen Henson 已提交
436

D
Dr. Stephen Henson 已提交
437
#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
438 439 440 441 442 443 444
        ;\
        static const ASN1_ITEM *name##_adb(void) \
        { \
        static const ASN1_ADB internal_adb = \
                {\
                flags,\
                offsetof(name, field),\
D
Dr. Stephen Henson 已提交
445
                adb_cb,\
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
                name##_adbtbl,\
                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
                def,\
                none\
                }; \
                return (const ASN1_ITEM *) &internal_adb; \
        } \
        void dummy_function(void)

# endif

# define ADB_ENTRY(val, template) {val, template}

# define ASN1_ADB_TEMPLATE(name) \
        static const ASN1_TEMPLATE name##_tt

/*
 * This is the ASN1 template structure that defines a wrapper round the
 * actual type. It determines the actual position of the field in the value
 * structure, various flags such as OPTIONAL and the field name.
D
 
Dr. Stephen Henson 已提交
466 467 468
 */

struct ASN1_TEMPLATE_st {
469 470 471 472 473
    unsigned long flags;        /* Various flags */
    long tag;                   /* tag, not used if no tagging */
    unsigned long offset;       /* Offset of this field in structure */
    const char *field_name;     /* Field name */
    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */
D
 
Dr. Stephen Henson 已提交
474 475
};

476 477
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */

478 479
# define ASN1_TEMPLATE_item(t) (t->item_ptr)
# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
D
 
Dr. Stephen Henson 已提交
480 481 482 483 484

typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
typedef struct ASN1_ADB_st ASN1_ADB;

struct ASN1_ADB_st {
485 486
    unsigned long flags;        /* Various flags */
    unsigned long offset;       /* Offset of selector field */
D
Dr. Stephen Henson 已提交
487
    int (*adb_cb)(long *psel);  /* Application callback */
488 489 490 491
    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */
    long tblcount;              /* Number of entries in tbl */
    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
D
 
Dr. Stephen Henson 已提交
492 493 494
};

struct ASN1_ADB_TABLE_st {
495 496
    long value;                 /* NID for an object or value for an int */
    const ASN1_TEMPLATE tt;     /* item for this value */
D
 
Dr. Stephen Henson 已提交
497 498 499 500 501
};

/* template flags */

/* Field is optional */
502
# define ASN1_TFLG_OPTIONAL      (0x1)
D
 
Dr. Stephen Henson 已提交
503 504

/* Field is a SET OF */
505
# define ASN1_TFLG_SET_OF        (0x1 << 1)
D
 
Dr. Stephen Henson 已提交
506 507

/* Field is a SEQUENCE OF */
508
# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)
D
 
Dr. Stephen Henson 已提交
509

510 511 512 513
/*
 * Special case: this refers to a SET OF that will be sorted into DER order
 * when encoded *and* the corresponding STACK will be modified to match the
 * new order.
514
 */
515
# define ASN1_TFLG_SET_ORDER     (0x3 << 1)
516 517

/* Mask for SET OF or SEQUENCE OF */
518
# define ASN1_TFLG_SK_MASK       (0x3 << 1)
D
 
Dr. Stephen Henson 已提交
519

520 521 522
/*
 * These flags mean the tag should be taken from the tag field. If EXPLICIT
 * then the underlying type is used for the inner tag.
D
 
Dr. Stephen Henson 已提交
523 524 525
 */

/* IMPLICIT tagging */
526
# define ASN1_TFLG_IMPTAG        (0x1 << 3)
D
 
Dr. Stephen Henson 已提交
527 528

/* EXPLICIT tagging, inner tag from underlying type */
529
# define ASN1_TFLG_EXPTAG        (0x2 << 3)
D
 
Dr. Stephen Henson 已提交
530

531
# define ASN1_TFLG_TAG_MASK      (0x3 << 3)
D
 
Dr. Stephen Henson 已提交
532 533

/* context specific IMPLICIT */
534
# define ASN1_TFLG_IMPLICIT      (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)
D
 
Dr. Stephen Henson 已提交
535 536

/* context specific EXPLICIT */
537
# define ASN1_TFLG_EXPLICIT      (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)
D
 
Dr. Stephen Henson 已提交
538

539 540 541 542
/*
 * If tagging is in force these determine the type of tag to use. Otherwise
 * the tag is determined by the underlying type. These values reflect the
 * actual octet format.
D
 
Dr. Stephen Henson 已提交
543 544
 */

545 546 547 548 549 550 551 552
/* Universal tag */
# define ASN1_TFLG_UNIVERSAL     (0x0<<6)
/* Application tag */
# define ASN1_TFLG_APPLICATION   (0x1<<6)
/* Context specific tag */
# define ASN1_TFLG_CONTEXT       (0x2<<6)
/* Private tag */
# define ASN1_TFLG_PRIVATE       (0x3<<6)
D
 
Dr. Stephen Henson 已提交
553

554
# define ASN1_TFLG_TAG_CLASS     (0x3<<6)
D
 
Dr. Stephen Henson 已提交
555

556 557 558
/*
 * These are for ANY DEFINED BY type. In this case the 'item' field points to
 * an ASN1_ADB structure which contains a table of values to decode the
D
 
Dr. Stephen Henson 已提交
559 560 561
 * relevant type
 */

562
# define ASN1_TFLG_ADB_MASK      (0x3<<8)
D
 
Dr. Stephen Henson 已提交
563

564
# define ASN1_TFLG_ADB_OID       (0x1<<8)
D
 
Dr. Stephen Henson 已提交
565

566
# define ASN1_TFLG_ADB_INT       (0x1<<9)
D
 
Dr. Stephen Henson 已提交
567

568 569 570
/*
 * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
 * indefinite length constructed encoding to be used if required.
571 572
 */

573
# define ASN1_TFLG_NDEF          (0x1<<11)
574

D
Dr. Stephen Henson 已提交
575 576 577
/* Field is embedded and not a pointer */
# define ASN1_TFLG_EMBED         (0x1 << 12)

D
 
Dr. Stephen Henson 已提交
578 579 580
/* This is the actual ASN1 item itself */

struct ASN1_ITEM_st {
581 582 583 584 585 586 587 588 589
    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE
                                 * or extern */
    long utype;                 /* underlying type */
    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
                                     * the contents */
    long tcount;                /* Number of templates if SEQUENCE or CHOICE */
    const void *funcs;          /* functions that handle this type */
    long size;                  /* Structure size (usually) */
    const char *sname;          /* Structure name */
D
 
Dr. Stephen Henson 已提交
590 591
};

592 593
/*-
 * These are values for the itype field and
D
 
Dr. Stephen Henson 已提交
594 595 596 597 598
 * determine how the type is interpreted.
 *
 * For PRIMITIVE types the underlying type
 * determines the behaviour if items is NULL.
 *
599
 * Otherwise templates must contain a single
D
 
Dr. Stephen Henson 已提交
600 601 602 603 604 605 606 607 608 609 610 611 612
 * template and the type is treated in the
 * same way as the type specified in the template.
 *
 * For SEQUENCE types the templates field points
 * to the members, the size field is the
 * structure size.
 *
 * For CHOICE types the templates field points
 * to each possible member (typically a union)
 * and the 'size' field is the offset of the
 * selector.
 *
 * The 'funcs' field is used for application
613
 * specific functions.
D
 
Dr. Stephen Henson 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626
 *
 * The EXTERN type uses a new style d2i/i2d.
 * The new style should be used where possible
 * because it avoids things like the d2i IMPLICIT
 * hack.
 *
 * MSTRING is a multiple string type, it is used
 * for a CHOICE of character strings where the
 * actual strings all occupy an ASN1_STRING
 * structure. In this case the 'utype' field
 * has a special meaning, it is used as a mask
 * of acceptable types using the B_ASN1 constants.
 *
627 628 629 630
 * NDEF_SEQUENCE is the same as SEQUENCE except
 * that it will use indefinite length constructed
 * encoding if requested.
 *
D
 
Dr. Stephen Henson 已提交
631 632
 */

633
# define ASN1_ITYPE_PRIMITIVE            0x0
634

635
# define ASN1_ITYPE_SEQUENCE             0x1
D
 
Dr. Stephen Henson 已提交
636

637
# define ASN1_ITYPE_CHOICE               0x2
D
 
Dr. Stephen Henson 已提交
638

639
# define ASN1_ITYPE_EXTERN               0x4
D
 
Dr. Stephen Henson 已提交
640

641
# define ASN1_ITYPE_MSTRING              0x5
D
 
Dr. Stephen Henson 已提交
642

643
# define ASN1_ITYPE_NDEF_SEQUENCE        0x6
D
 
Dr. Stephen Henson 已提交
644

645 646
/*
 * Cache for ASN1 tag and length, so we don't keep re-reading it for things
D
 
Dr. Stephen Henson 已提交
647 648 649
 * like CHOICE
 */

650 651 652 653 654 655 656
struct ASN1_TLC_st {
    char valid;                 /* Values below are valid */
    int ret;                    /* return value */
    long plen;                  /* length */
    int ptag;                   /* class value */
    int pclass;                 /* class value */
    int hdrlen;                 /* header length */
D
 
Dr. Stephen Henson 已提交
657 658 659
};

/* Typedefs for ASN1 function pointers */
660 661 662
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
                        const ASN1_ITEM *it, int tag, int aclass, char opt,
                        ASN1_TLC *ctx);
D
 
Dr. Stephen Henson 已提交
663

664 665
typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
                        const ASN1_ITEM *it, int tag, int aclass);
D
 
Dr. Stephen Henson 已提交
666 667 668
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);

669 670 671
typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
                               int indent, const char *fname,
                               const ASN1_PCTX *pctx);
672

673 674 675 676 677 678 679 680
typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,
                               int *putype, const ASN1_ITEM *it);
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
                               int len, int utype, char *free_cont,
                               const ASN1_ITEM *it);
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,
                                 const ASN1_ITEM *it, int indent,
                                 const ASN1_PCTX *pctx);
D
 
Dr. Stephen Henson 已提交
681 682

typedef struct ASN1_EXTERN_FUNCS_st {
683 684 685 686 687 688 689
    void *app_data;
    ASN1_ex_new_func *asn1_ex_new;
    ASN1_ex_free_func *asn1_ex_free;
    ASN1_ex_free_func *asn1_ex_clear;
    ASN1_ex_d2i *asn1_ex_d2i;
    ASN1_ex_i2d *asn1_ex_i2d;
    ASN1_ex_print_func *asn1_ex_print;
D
 
Dr. Stephen Henson 已提交
690 691 692
} ASN1_EXTERN_FUNCS;

typedef struct ASN1_PRIMITIVE_FUNCS_st {
693 694 695 696 697 698 699 700
    void *app_data;
    unsigned long flags;
    ASN1_ex_new_func *prim_new;
    ASN1_ex_free_func *prim_free;
    ASN1_ex_free_func *prim_clear;
    ASN1_primitive_c2i *prim_c2i;
    ASN1_primitive_i2c *prim_i2c;
    ASN1_primitive_print *prim_print;
D
 
Dr. Stephen Henson 已提交
701 702
} ASN1_PRIMITIVE_FUNCS;

703 704 705 706 707 708 709 710 711 712 713
/*
 * This is the ASN1_AUX structure: it handles various miscellaneous
 * requirements. For example the use of reference counts and an informational
 * callback. The "informational callback" is called at various points during
 * the ASN1 encoding and decoding. It can be used to provide minor
 * customisation of the structures used. This is most useful where the
 * supplied routines *almost* do the right thing but need some extra help at
 * a few points. If the callback returns zero then it is assumed a fatal
 * error has occurred and the main operation should be abandoned. If major
 * changes in the default behaviour are required then an external type is
 * more appropriate.
D
 
Dr. Stephen Henson 已提交
714 715
 */

716
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
717
                        void *exarg);
D
 
Dr. Stephen Henson 已提交
718 719

typedef struct ASN1_AUX_st {
720 721 722 723 724 725
    void *app_data;
    int flags;
    int ref_offset;             /* Offset of reference value */
    int ref_lock;               /* Lock type to use */
    ASN1_aux_cb *asn1_cb;
    int enc_offset;             /* Offset of ASN1_ENCODING structure */
D
 
Dr. Stephen Henson 已提交
726 727
} ASN1_AUX;

728 729
/* For print related callbacks exarg points to this structure */
typedef struct ASN1_PRINT_ARG_st {
730 731 732
    BIO *out;
    int indent;
    const ASN1_PCTX *pctx;
733 734
} ASN1_PRINT_ARG;

D
Dr. Stephen Henson 已提交
735 736
/* For streaming related callbacks exarg points to this structure */
typedef struct ASN1_STREAM_ARG_st {
737 738 739 740 741 742
    /* BIO to stream through */
    BIO *out;
    /* BIO with filters appended */
    BIO *ndef_bio;
    /* Streaming I/O boundary */
    unsigned char **boundary;
D
Dr. Stephen Henson 已提交
743 744
} ASN1_STREAM_ARG;

D
 
Dr. Stephen Henson 已提交
745 746 747
/* Flags in ASN1_AUX */

/* Use a reference count */
748
# define ASN1_AFLG_REFCOUNT      1
D
 
Dr. Stephen Henson 已提交
749
/* Save the encoding of structure (useful for signatures) */
750
# define ASN1_AFLG_ENCODING      2
D
 
Dr. Stephen Henson 已提交
751
/* The Sequence length is invalid */
752
# define ASN1_AFLG_BROKEN        4
D
 
Dr. Stephen Henson 已提交
753 754 755

/* operation values for asn1_cb */

756 757 758 759 760 761 762 763 764 765 766 767 768 769
# define ASN1_OP_NEW_PRE         0
# define ASN1_OP_NEW_POST        1
# define ASN1_OP_FREE_PRE        2
# define ASN1_OP_FREE_POST       3
# define ASN1_OP_D2I_PRE         4
# define ASN1_OP_D2I_POST        5
# define ASN1_OP_I2D_PRE         6
# define ASN1_OP_I2D_POST        7
# define ASN1_OP_PRINT_PRE       8
# define ASN1_OP_PRINT_POST      9
# define ASN1_OP_STREAM_PRE      10
# define ASN1_OP_STREAM_POST     11
# define ASN1_OP_DETACHED_PRE    12
# define ASN1_OP_DETACHED_POST   13
D
 
Dr. Stephen Henson 已提交
770 771

/* Macro to implement a primitive type */
772 773 774 775 776
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
                                ASN1_ITEM_start(itname) \
                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
                                ASN1_ITEM_end(itname)
D
 
Dr. Stephen Henson 已提交
777 778

/* Macro to implement a multi string type */
779 780 781 782
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
                                ASN1_ITEM_start(itname) \
                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
                                ASN1_ITEM_end(itname)
D
 
Dr. Stephen Henson 已提交
783

784 785 786 787 788 789 790 791 792 793
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
        ASN1_ITEM_start(sname) \
                ASN1_ITYPE_EXTERN, \
                tag, \
                NULL, \
                0, \
                &fptrs, \
                0, \
                #sname \
        ASN1_ITEM_end(sname)
D
 
Dr. Stephen Henson 已提交
794 795 796

/* Macro to implement standard functions in terms of ASN1_ITEM structures */

797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)

# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)

# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)

# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)

# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)

# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
        pre stname *fname##_new(void) \
        { \
                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
        } \
        pre void fname##_free(stname *a) \
        { \
                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
        }

# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
        stname *fname##_new(void) \
        { \
                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
        } \
        void fname##_free(stname *a) \
        { \
                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
        }

# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)

# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
        { \
                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
        } \
        int i2d_##fname(stname *a, unsigned char **out) \
        { \
                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
        }

# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
        { \
                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
        }

850 851 852 853 854 855 856 857 858 859 860 861 862
# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
        static stname *d2i_##stname(stname **a, \
                                   const unsigned char **in, long len) \
        { \
                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
                                               ASN1_ITEM_rptr(stname)); \
        } \
        static int i2d_##stname(stname *a, unsigned char **out) \
        { \
                return ASN1_item_i2d((ASN1_VALUE *)a, out, \
                                     ASN1_ITEM_rptr(stname)); \
        }

863 864 865
/*
 * This includes evil casts to remove const: they will go away when full ASN1
 * constification is done.
D
 
Dr. Stephen Henson 已提交
866
 */
867 868 869 870 871 872 873 874 875 876 877 878
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
        { \
                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
        } \
        int i2d_##fname(const stname *a, unsigned char **out) \
        { \
                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
        }

# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
        stname * stname##_dup(stname *x) \
D
 
Dr. Stephen Henson 已提交
879 880 881 882
        { \
        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
        }

883 884
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
885

886 887 888 889 890 891 892
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
        int fname##_print_ctx(BIO *out, stname *x, int indent, \
                                                const ASN1_PCTX *pctx) \
        { \
                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
                        ASN1_ITEM_rptr(itname), pctx); \
        }
893

894 895
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
D
 
Dr. Stephen Henson 已提交
896

897 898 899
# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
D
 
Dr. Stephen Henson 已提交
900 901 902

/* external definitions for primitive types */

903 904 905 906 907 908
DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
DECLARE_ASN1_ITEM(CBIGNUM)
DECLARE_ASN1_ITEM(BIGNUM)
909 910 911 912 913 914 915 916
DECLARE_ASN1_ITEM(INT32)
DECLARE_ASN1_ITEM(ZINT32)
DECLARE_ASN1_ITEM(UINT32)
DECLARE_ASN1_ITEM(ZUINT32)
DECLARE_ASN1_ITEM(INT64)
DECLARE_ASN1_ITEM(ZINT64)
DECLARE_ASN1_ITEM(UINT64)
DECLARE_ASN1_ITEM(ZUINT64)
917 918 919 920 921 922 923

# if OPENSSL_API_COMPAT < 0x10200000L
/*
 * LONG and ZLONG are strongly discouraged for use as stored data, as the
 * underlying C type (long) differs in size depending on the architecture.
 * They are designed with 32-bit longs in mind.
 */
924 925
DECLARE_ASN1_ITEM(LONG)
DECLARE_ASN1_ITEM(ZLONG)
926
# endif
D
 
Dr. Stephen Henson 已提交
927

928
DEFINE_STACK_OF(ASN1_VALUE)
D
 
Dr. Stephen Henson 已提交
929 930 931 932 933 934

/* Functions used internally by the ASN1 code */

int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);

935 936 937 938 939 940
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
                     const ASN1_ITEM *it, int tag, int aclass, char opt,
                     ASN1_TLC *ctx);

int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
                     const ASN1_ITEM *it, int tag, int aclass);
D
 
Dr. Stephen Henson 已提交
941 942 943 944 945

#ifdef  __cplusplus
}
#endif
#endif