Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:38

0001 /*
0002  * WARNING: do not edit!
0003  * Generated by Makefile from include/openssl/asn1t.h.in
0004  *
0005  * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
0006  *
0007  * Licensed under the Apache License 2.0 (the "License").  You may not use
0008  * this file except in compliance with the License.  You can obtain a copy
0009  * in the file LICENSE in the source distribution or at
0010  * https://www.openssl.org/source/license.html
0011  */
0012 
0013 
0014 
0015 #ifndef OPENSSL_ASN1T_H
0016 # define OPENSSL_ASN1T_H
0017 # pragma once
0018 
0019 # include <openssl/macros.h>
0020 # ifndef OPENSSL_NO_DEPRECATED_3_0
0021 #  define HEADER_ASN1T_H
0022 # endif
0023 
0024 # include <stddef.h>
0025 # include <openssl/e_os2.h>
0026 # include <openssl/asn1.h>
0027 
0028 # ifdef OPENSSL_BUILD_SHLIBCRYPTO
0029 #  undef OPENSSL_EXTERN
0030 #  define OPENSSL_EXTERN OPENSSL_EXPORT
0031 # endif
0032 
0033 /* ASN1 template defines, structures and functions */
0034 
0035 #ifdef  __cplusplus
0036 extern "C" {
0037 #endif
0038 
0039 /*-
0040  * These are the possible values for the itype field of the
0041  * ASN1_ITEM structure and determine how it is interpreted.
0042  *
0043  * For PRIMITIVE types the underlying type
0044  * determines the behaviour if items is NULL.
0045  *
0046  * Otherwise templates must contain a single
0047  * template and the type is treated in the
0048  * same way as the type specified in the template.
0049  *
0050  * For SEQUENCE types the templates field points
0051  * to the members, the size field is the
0052  * structure size.
0053  *
0054  * For CHOICE types the templates field points
0055  * to each possible member (typically a union)
0056  * and the 'size' field is the offset of the
0057  * selector.
0058  *
0059  * The 'funcs' field is used for application-specific
0060  * data and functions.
0061  *
0062  * The EXTERN type uses a new style d2i/i2d.
0063  * The new style should be used where possible
0064  * because it avoids things like the d2i IMPLICIT
0065  * hack.
0066  *
0067  * MSTRING is a multiple string type, it is used
0068  * for a CHOICE of character strings where the
0069  * actual strings all occupy an ASN1_STRING
0070  * structure. In this case the 'utype' field
0071  * has a special meaning, it is used as a mask
0072  * of acceptable types using the B_ASN1 constants.
0073  *
0074  * NDEF_SEQUENCE is the same as SEQUENCE except
0075  * that it will use indefinite length constructed
0076  * encoding if requested.
0077  *
0078  */
0079 
0080 # define ASN1_ITYPE_PRIMITIVE            0x0
0081 # define ASN1_ITYPE_SEQUENCE             0x1
0082 # define ASN1_ITYPE_CHOICE               0x2
0083 /* unused value                          0x3 */
0084 # define ASN1_ITYPE_EXTERN               0x4
0085 # define ASN1_ITYPE_MSTRING              0x5
0086 # define ASN1_ITYPE_NDEF_SEQUENCE        0x6
0087 
0088 /* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
0089 # define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))
0090 
0091 /* Macros for start and end of ASN1_ITEM definition */
0092 
0093 # define ASN1_ITEM_start(itname) \
0094         const ASN1_ITEM * itname##_it(void) \
0095         { \
0096                 static const ASN1_ITEM local_it = {
0097 
0098 # define static_ASN1_ITEM_start(itname) \
0099         static ASN1_ITEM_start(itname)
0100 
0101 # define ASN1_ITEM_end(itname) \
0102                 }; \
0103         return &local_it; \
0104         }
0105 
0106 /* Macros to aid ASN1 template writing */
0107 
0108 # define ASN1_ITEM_TEMPLATE(tname) \
0109         static const ASN1_TEMPLATE tname##_item_tt
0110 
0111 # define ASN1_ITEM_TEMPLATE_END(tname) \
0112         ;\
0113         ASN1_ITEM_start(tname) \
0114                 ASN1_ITYPE_PRIMITIVE,\
0115                 -1,\
0116                 &tname##_item_tt,\
0117                 0,\
0118                 NULL,\
0119                 0,\
0120                 #tname \
0121         ASN1_ITEM_end(tname)
0122 # define static_ASN1_ITEM_TEMPLATE_END(tname) \
0123         ;\
0124         static_ASN1_ITEM_start(tname) \
0125                 ASN1_ITYPE_PRIMITIVE,\
0126                 -1,\
0127                 &tname##_item_tt,\
0128                 0,\
0129                 NULL,\
0130                 0,\
0131                 #tname \
0132         ASN1_ITEM_end(tname)
0133 
0134 /* This is a ASN1 type which just embeds a template */
0135 
0136 /*-
0137  * This pair helps declare a SEQUENCE. We can do:
0138  *
0139  *      ASN1_SEQUENCE(stname) = {
0140  *              ... SEQUENCE components ...
0141  *      } ASN1_SEQUENCE_END(stname)
0142  *
0143  *      This will produce an ASN1_ITEM called stname_it
0144  *      for a structure called stname.
0145  *
0146  *      If you want the same structure but a different
0147  *      name then use:
0148  *
0149  *      ASN1_SEQUENCE(itname) = {
0150  *              ... SEQUENCE components ...
0151  *      } ASN1_SEQUENCE_END_name(stname, itname)
0152  *
0153  *      This will create an item called itname_it using
0154  *      a structure called stname.
0155  */
0156 
0157 # define ASN1_SEQUENCE(tname) \
0158         static const ASN1_TEMPLATE tname##_seq_tt[]
0159 
0160 # define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
0161 
0162 # define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
0163 
0164 # define ASN1_SEQUENCE_END_name(stname, tname) \
0165         ;\
0166         ASN1_ITEM_start(tname) \
0167                 ASN1_ITYPE_SEQUENCE,\
0168                 V_ASN1_SEQUENCE,\
0169                 tname##_seq_tt,\
0170                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0171                 NULL,\
0172                 sizeof(stname),\
0173                 #tname \
0174         ASN1_ITEM_end(tname)
0175 
0176 # define static_ASN1_SEQUENCE_END_name(stname, tname) \
0177         ;\
0178         static_ASN1_ITEM_start(tname) \
0179                 ASN1_ITYPE_SEQUENCE,\
0180                 V_ASN1_SEQUENCE,\
0181                 tname##_seq_tt,\
0182                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0183                 NULL,\
0184                 sizeof(stname),\
0185                 #stname \
0186         ASN1_ITEM_end(tname)
0187 
0188 # define ASN1_NDEF_SEQUENCE(tname) \
0189         ASN1_SEQUENCE(tname)
0190 
0191 # define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
0192         ASN1_SEQUENCE_cb(tname, cb)
0193 
0194 # define ASN1_SEQUENCE_cb(tname, cb) \
0195         static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
0196         ASN1_SEQUENCE(tname)
0197 
0198 # define ASN1_SEQUENCE_const_cb(tname, const_cb) \
0199         static const ASN1_AUX tname##_aux = \
0200             {NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb}; \
0201         ASN1_SEQUENCE(tname)
0202 
0203 # define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \
0204         static const ASN1_AUX tname##_aux = \
0205             {NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb}; \
0206         ASN1_SEQUENCE(tname)
0207 
0208 # define ASN1_SEQUENCE_ref(tname, cb) \
0209         static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0, NULL}; \
0210         ASN1_SEQUENCE(tname)
0211 
0212 # define ASN1_SEQUENCE_enc(tname, enc, cb) \
0213         static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL}; \
0214         ASN1_SEQUENCE(tname)
0215 
0216 # define ASN1_NDEF_SEQUENCE_END(tname) \
0217         ;\
0218         ASN1_ITEM_start(tname) \
0219                 ASN1_ITYPE_NDEF_SEQUENCE,\
0220                 V_ASN1_SEQUENCE,\
0221                 tname##_seq_tt,\
0222                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0223                 NULL,\
0224                 sizeof(tname),\
0225                 #tname \
0226         ASN1_ITEM_end(tname)
0227 # define static_ASN1_NDEF_SEQUENCE_END(tname) \
0228         ;\
0229         static_ASN1_ITEM_start(tname) \
0230                 ASN1_ITYPE_NDEF_SEQUENCE,\
0231                 V_ASN1_SEQUENCE,\
0232                 tname##_seq_tt,\
0233                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0234                 NULL,\
0235                 sizeof(tname),\
0236                 #tname \
0237         ASN1_ITEM_end(tname)
0238 
0239 
0240 # define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
0241 
0242 # define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
0243 # define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
0244 
0245 # define ASN1_SEQUENCE_END_ref(stname, tname) \
0246         ;\
0247         ASN1_ITEM_start(tname) \
0248                 ASN1_ITYPE_SEQUENCE,\
0249                 V_ASN1_SEQUENCE,\
0250                 tname##_seq_tt,\
0251                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0252                 &tname##_aux,\
0253                 sizeof(stname),\
0254                 #tname \
0255         ASN1_ITEM_end(tname)
0256 # define static_ASN1_SEQUENCE_END_ref(stname, tname) \
0257         ;\
0258         static_ASN1_ITEM_start(tname) \
0259                 ASN1_ITYPE_SEQUENCE,\
0260                 V_ASN1_SEQUENCE,\
0261                 tname##_seq_tt,\
0262                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0263                 &tname##_aux,\
0264                 sizeof(stname),\
0265                 #stname \
0266         ASN1_ITEM_end(tname)
0267 
0268 # define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
0269         ;\
0270         ASN1_ITEM_start(tname) \
0271                 ASN1_ITYPE_NDEF_SEQUENCE,\
0272                 V_ASN1_SEQUENCE,\
0273                 tname##_seq_tt,\
0274                 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
0275                 &tname##_aux,\
0276                 sizeof(stname),\
0277                 #stname \
0278         ASN1_ITEM_end(tname)
0279 
0280 /*-
0281  * This pair helps declare a CHOICE type. We can do:
0282  *
0283  *      ASN1_CHOICE(chname) = {
0284  *              ... CHOICE options ...
0285  *      ASN1_CHOICE_END(chname)
0286  *
0287  *      This will produce an ASN1_ITEM called chname_it
0288  *      for a structure called chname. The structure
0289  *      definition must look like this:
0290  *      typedef struct {
0291  *              int type;
0292  *              union {
0293  *                      ASN1_SOMETHING *opt1;
0294  *                      ASN1_SOMEOTHER *opt2;
0295  *              } value;
0296  *      } chname;
0297  *
0298  *      the name of the selector must be 'type'.
0299  *      to use an alternative selector name use the
0300  *      ASN1_CHOICE_END_selector() version.
0301  */
0302 
0303 # define ASN1_CHOICE(tname) \
0304         static const ASN1_TEMPLATE tname##_ch_tt[]
0305 
0306 # define ASN1_CHOICE_cb(tname, cb) \
0307         static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
0308         ASN1_CHOICE(tname)
0309 
0310 # define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
0311 
0312 # define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
0313 
0314 # define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
0315 
0316 # define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
0317 
0318 # define ASN1_CHOICE_END_selector(stname, tname, selname) \
0319         ;\
0320         ASN1_ITEM_start(tname) \
0321                 ASN1_ITYPE_CHOICE,\
0322                 offsetof(stname,selname) ,\
0323                 tname##_ch_tt,\
0324                 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
0325                 NULL,\
0326                 sizeof(stname),\
0327                 #stname \
0328         ASN1_ITEM_end(tname)
0329 
0330 # define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
0331         ;\
0332         static_ASN1_ITEM_start(tname) \
0333                 ASN1_ITYPE_CHOICE,\
0334                 offsetof(stname,selname) ,\
0335                 tname##_ch_tt,\
0336                 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
0337                 NULL,\
0338                 sizeof(stname),\
0339                 #stname \
0340         ASN1_ITEM_end(tname)
0341 
0342 # define ASN1_CHOICE_END_cb(stname, tname, selname) \
0343         ;\
0344         ASN1_ITEM_start(tname) \
0345                 ASN1_ITYPE_CHOICE,\
0346                 offsetof(stname,selname) ,\
0347                 tname##_ch_tt,\
0348                 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
0349                 &tname##_aux,\
0350                 sizeof(stname),\
0351                 #stname \
0352         ASN1_ITEM_end(tname)
0353 
0354 /* This helps with the template wrapper form of ASN1_ITEM */
0355 
0356 # define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
0357         (flags), (tag), 0,\
0358         #name, ASN1_ITEM_ref(type) }
0359 
0360 /* These help with SEQUENCE or CHOICE components */
0361 
0362 /* used to declare other types */
0363 
0364 # define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
0365         (flags), (tag), offsetof(stname, field),\
0366         #field, ASN1_ITEM_ref(type) }
0367 
0368 /* implicit and explicit helper macros */
0369 
0370 # define ASN1_IMP_EX(stname, field, type, tag, ex) \
0371          ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)
0372 
0373 # define ASN1_EXP_EX(stname, field, type, tag, ex) \
0374          ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)
0375 
0376 /* Any defined by macros: the field used is in the table itself */
0377 
0378 # define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
0379 # define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
0380 
0381 /* Plain simple type */
0382 # define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
0383 /* Embedded simple type */
0384 # define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
0385 
0386 /* OPTIONAL simple type */
0387 # define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
0388 # define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)
0389 
0390 /* IMPLICIT tagged simple type */
0391 # define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
0392 # define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
0393 
0394 /* IMPLICIT tagged OPTIONAL simple type */
0395 # define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
0396 # define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
0397 
0398 /* Same as above but EXPLICIT */
0399 
0400 # define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
0401 # define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
0402 # define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
0403 # define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
0404 
0405 /* SEQUENCE OF type */
0406 # define ASN1_SEQUENCE_OF(stname, field, type) \
0407                 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
0408 
0409 /* OPTIONAL SEQUENCE OF */
0410 # define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
0411                 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
0412 
0413 /* Same as above but for SET OF */
0414 
0415 # define ASN1_SET_OF(stname, field, type) \
0416                 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
0417 
0418 # define ASN1_SET_OF_OPT(stname, field, type) \
0419                 ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
0420 
0421 /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
0422 
0423 # define ASN1_IMP_SET_OF(stname, field, type, tag) \
0424                         ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
0425 
0426 # define ASN1_EXP_SET_OF(stname, field, type, tag) \
0427                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
0428 
0429 # define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
0430                         ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
0431 
0432 # define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
0433                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
0434 
0435 # define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
0436                         ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
0437 
0438 # define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
0439                         ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
0440 
0441 # define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
0442                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
0443 
0444 # define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
0445                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
0446 
0447 /* EXPLICIT using indefinite length constructed form */
0448 # define ASN1_NDEF_EXP(stname, field, type, tag) \
0449                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
0450 
0451 /* EXPLICIT OPTIONAL using indefinite length constructed form */
0452 # define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
0453                         ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
0454 
0455 /* Macros for the ASN1_ADB structure */
0456 
0457 # define ASN1_ADB(name) \
0458         static const ASN1_ADB_TABLE name##_adbtbl[]
0459 
0460 # define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
0461         ;\
0462         static const ASN1_ITEM *name##_adb(void) \
0463         { \
0464         static const ASN1_ADB internal_adb = \
0465                 {\
0466                 flags,\
0467                 offsetof(name, field),\
0468                 adb_cb,\
0469                 name##_adbtbl,\
0470                 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
0471                 def,\
0472                 none\
0473                 }; \
0474                 return (const ASN1_ITEM *) &internal_adb; \
0475         } \
0476         void dummy_function(void)
0477 
0478 # define ADB_ENTRY(val, template) {val, template}
0479 
0480 # define ASN1_ADB_TEMPLATE(name) \
0481         static const ASN1_TEMPLATE name##_tt
0482 
0483 /*
0484  * This is the ASN1 template structure that defines a wrapper round the
0485  * actual type. It determines the actual position of the field in the value
0486  * structure, various flags such as OPTIONAL and the field name.
0487  */
0488 
0489 struct ASN1_TEMPLATE_st {
0490     unsigned long flags;        /* Various flags */
0491     long tag;                   /* tag, not used if no tagging */
0492     unsigned long offset;       /* Offset of this field in structure */
0493     const char *field_name;     /* Field name */
0494     ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */
0495 };
0496 
0497 /* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
0498 
0499 # define ASN1_TEMPLATE_item(t) (t->item_ptr)
0500 # define ASN1_TEMPLATE_adb(t) (t->item_ptr)
0501 
0502 typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
0503 typedef struct ASN1_ADB_st ASN1_ADB;
0504 
0505 struct ASN1_ADB_st {
0506     unsigned long flags;        /* Various flags */
0507     unsigned long offset;       /* Offset of selector field */
0508     int (*adb_cb)(long *psel);  /* Application callback */
0509     const ASN1_ADB_TABLE *tbl;  /* Table of possible types */
0510     long tblcount;              /* Number of entries in tbl */
0511     const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
0512     const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
0513 };
0514 
0515 struct ASN1_ADB_TABLE_st {
0516     long value;                 /* NID for an object or value for an int */
0517     const ASN1_TEMPLATE tt;     /* item for this value */
0518 };
0519 
0520 /* template flags */
0521 
0522 /* Field is optional */
0523 # define ASN1_TFLG_OPTIONAL      (0x1)
0524 
0525 /* Field is a SET OF */
0526 # define ASN1_TFLG_SET_OF        (0x1 << 1)
0527 
0528 /* Field is a SEQUENCE OF */
0529 # define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)
0530 
0531 /*
0532  * Special case: this refers to a SET OF that will be sorted into DER order
0533  * when encoded *and* the corresponding STACK will be modified to match the
0534  * new order.
0535  */
0536 # define ASN1_TFLG_SET_ORDER     (0x3 << 1)
0537 
0538 /* Mask for SET OF or SEQUENCE OF */
0539 # define ASN1_TFLG_SK_MASK       (0x3 << 1)
0540 
0541 /*
0542  * These flags mean the tag should be taken from the tag field. If EXPLICIT
0543  * then the underlying type is used for the inner tag.
0544  */
0545 
0546 /* IMPLICIT tagging */
0547 # define ASN1_TFLG_IMPTAG        (0x1 << 3)
0548 
0549 /* EXPLICIT tagging, inner tag from underlying type */
0550 # define ASN1_TFLG_EXPTAG        (0x2 << 3)
0551 
0552 # define ASN1_TFLG_TAG_MASK      (0x3 << 3)
0553 
0554 /* context specific IMPLICIT */
0555 # define ASN1_TFLG_IMPLICIT      (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)
0556 
0557 /* context specific EXPLICIT */
0558 # define ASN1_TFLG_EXPLICIT      (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)
0559 
0560 /*
0561  * If tagging is in force these determine the type of tag to use. Otherwise
0562  * the tag is determined by the underlying type. These values reflect the
0563  * actual octet format.
0564  */
0565 
0566 /* Universal tag */
0567 # define ASN1_TFLG_UNIVERSAL     (0x0<<6)
0568 /* Application tag */
0569 # define ASN1_TFLG_APPLICATION   (0x1<<6)
0570 /* Context specific tag */
0571 # define ASN1_TFLG_CONTEXT       (0x2<<6)
0572 /* Private tag */
0573 # define ASN1_TFLG_PRIVATE       (0x3<<6)
0574 
0575 # define ASN1_TFLG_TAG_CLASS     (0x3<<6)
0576 
0577 /*
0578  * These are for ANY DEFINED BY type. In this case the 'item' field points to
0579  * an ASN1_ADB structure which contains a table of values to decode the
0580  * relevant type
0581  */
0582 
0583 # define ASN1_TFLG_ADB_MASK      (0x3<<8)
0584 
0585 # define ASN1_TFLG_ADB_OID       (0x1<<8)
0586 
0587 # define ASN1_TFLG_ADB_INT       (0x1<<9)
0588 
0589 /*
0590  * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
0591  * indefinite length constructed encoding to be used if required.
0592  */
0593 
0594 # define ASN1_TFLG_NDEF          (0x1<<11)
0595 
0596 /* Field is embedded and not a pointer */
0597 # define ASN1_TFLG_EMBED         (0x1 << 12)
0598 
0599 /* This is the actual ASN1 item itself */
0600 
0601 struct ASN1_ITEM_st {
0602     char itype;                 /* The item type, primitive, SEQUENCE, CHOICE
0603                                  * or extern */
0604     long utype;                 /* underlying type */
0605     const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
0606                                      * the contents */
0607     long tcount;                /* Number of templates if SEQUENCE or CHOICE */
0608     const void *funcs;          /* further data and type-specific functions */
0609     /* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */
0610     long size;                  /* Structure size (usually) */
0611     const char *sname;          /* Structure name */
0612 };
0613 
0614 /*
0615  * Cache for ASN1 tag and length, so we don't keep re-reading it for things
0616  * like CHOICE
0617  */
0618 
0619 struct ASN1_TLC_st {
0620     char valid;                 /* Values below are valid */
0621     int ret;                    /* return value */
0622     long plen;                  /* length */
0623     int ptag;                   /* class value */
0624     int pclass;                 /* class value */
0625     int hdrlen;                 /* header length */
0626 };
0627 
0628 /* Typedefs for ASN1 function pointers */
0629 typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
0630                         const ASN1_ITEM *it, int tag, int aclass, char opt,
0631                         ASN1_TLC *ctx);
0632 
0633 typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, long len,
0634                            const ASN1_ITEM *it, int tag, int aclass, char opt,
0635                            ASN1_TLC *ctx, OSSL_LIB_CTX *libctx,
0636                            const char *propq);
0637 typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
0638                         const ASN1_ITEM *it, int tag, int aclass);
0639 typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
0640 typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it,
0641                                 OSSL_LIB_CTX *libctx, const char *propq);
0642 typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
0643 
0644 typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval,
0645                                int indent, const char *fname,
0646                                const ASN1_PCTX *pctx);
0647 
0648 typedef int ASN1_primitive_i2c(const ASN1_VALUE **pval, unsigned char *cont,
0649                                int *putype, const ASN1_ITEM *it);
0650 typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
0651                                int len, int utype, char *free_cont,
0652                                const ASN1_ITEM *it);
0653 typedef int ASN1_primitive_print(BIO *out, const ASN1_VALUE **pval,
0654                                  const ASN1_ITEM *it, int indent,
0655                                  const ASN1_PCTX *pctx);
0656 
0657 typedef struct ASN1_EXTERN_FUNCS_st {
0658     void *app_data;
0659     ASN1_ex_new_func *asn1_ex_new;
0660     ASN1_ex_free_func *asn1_ex_free;
0661     ASN1_ex_free_func *asn1_ex_clear;
0662     ASN1_ex_d2i *asn1_ex_d2i;
0663     ASN1_ex_i2d *asn1_ex_i2d;
0664     ASN1_ex_print_func *asn1_ex_print;
0665     ASN1_ex_new_ex_func *asn1_ex_new_ex;
0666     ASN1_ex_d2i_ex *asn1_ex_d2i_ex;
0667 } ASN1_EXTERN_FUNCS;
0668 
0669 typedef struct ASN1_PRIMITIVE_FUNCS_st {
0670     void *app_data;
0671     unsigned long flags;
0672     ASN1_ex_new_func *prim_new;
0673     ASN1_ex_free_func *prim_free;
0674     ASN1_ex_free_func *prim_clear;
0675     ASN1_primitive_c2i *prim_c2i;
0676     ASN1_primitive_i2c *prim_i2c;
0677     ASN1_primitive_print *prim_print;
0678 } ASN1_PRIMITIVE_FUNCS;
0679 
0680 /*
0681  * This is the ASN1_AUX structure: it handles various miscellaneous
0682  * requirements. For example the use of reference counts and an informational
0683  * callback. The "informational callback" is called at various points during
0684  * the ASN1 encoding and decoding. It can be used to provide minor
0685  * customisation of the structures used. This is most useful where the
0686  * supplied routines *almost* do the right thing but need some extra help at
0687  * a few points. If the callback returns zero then it is assumed a fatal
0688  * error has occurred and the main operation should be abandoned. If major
0689  * changes in the default behaviour are required then an external type is
0690  * more appropriate.
0691  * For the operations ASN1_OP_I2D_PRE, ASN1_OP_I2D_POST, ASN1_OP_PRINT_PRE, and
0692  * ASN1_OP_PRINT_POST, meanwhile a variant of the callback with const parameter
0693  * 'in' is provided to make clear statically that its input is not modified. If
0694  * and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set.
0695  */
0696 
0697 typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
0698                         void *exarg);
0699 typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in,
0700                               const ASN1_ITEM *it, void *exarg);
0701 
0702 typedef struct ASN1_AUX_st {
0703     void *app_data;
0704     int flags;
0705     int ref_offset;             /* Offset of reference value */
0706     int ref_lock;               /* Offset of lock value */
0707     ASN1_aux_cb *asn1_cb;
0708     int enc_offset;             /* Offset of ASN1_ENCODING structure */
0709     ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */
0710 } ASN1_AUX;
0711 
0712 /* For print related callbacks exarg points to this structure */
0713 typedef struct ASN1_PRINT_ARG_st {
0714     BIO *out;
0715     int indent;
0716     const ASN1_PCTX *pctx;
0717 } ASN1_PRINT_ARG;
0718 
0719 /* For streaming related callbacks exarg points to this structure */
0720 typedef struct ASN1_STREAM_ARG_st {
0721     /* BIO to stream through */
0722     BIO *out;
0723     /* BIO with filters appended */
0724     BIO *ndef_bio;
0725     /* Streaming I/O boundary */
0726     unsigned char **boundary;
0727 } ASN1_STREAM_ARG;
0728 
0729 /* Flags in ASN1_AUX */
0730 
0731 /* Use a reference count */
0732 # define ASN1_AFLG_REFCOUNT      1
0733 /* Save the encoding of structure (useful for signatures) */
0734 # define ASN1_AFLG_ENCODING      2
0735 /* The Sequence length is invalid */
0736 # define ASN1_AFLG_BROKEN        4
0737 /* Use the new asn1_const_cb */
0738 # define ASN1_AFLG_CONST_CB      8
0739 
0740 /* operation values for asn1_cb */
0741 
0742 # define ASN1_OP_NEW_PRE         0
0743 # define ASN1_OP_NEW_POST        1
0744 # define ASN1_OP_FREE_PRE        2
0745 # define ASN1_OP_FREE_POST       3
0746 # define ASN1_OP_D2I_PRE         4
0747 # define ASN1_OP_D2I_POST        5
0748 # define ASN1_OP_I2D_PRE         6
0749 # define ASN1_OP_I2D_POST        7
0750 # define ASN1_OP_PRINT_PRE       8
0751 # define ASN1_OP_PRINT_POST      9
0752 # define ASN1_OP_STREAM_PRE      10
0753 # define ASN1_OP_STREAM_POST     11
0754 # define ASN1_OP_DETACHED_PRE    12
0755 # define ASN1_OP_DETACHED_POST   13
0756 # define ASN1_OP_DUP_PRE         14
0757 # define ASN1_OP_DUP_POST        15
0758 # define ASN1_OP_GET0_LIBCTX     16
0759 # define ASN1_OP_GET0_PROPQ      17
0760 
0761 /* Macro to implement a primitive type */
0762 # define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
0763 # define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
0764                                 ASN1_ITEM_start(itname) \
0765                                         ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
0766                                 ASN1_ITEM_end(itname)
0767 
0768 /* Macro to implement a multi string type */
0769 # define IMPLEMENT_ASN1_MSTRING(itname, mask) \
0770                                 ASN1_ITEM_start(itname) \
0771                                         ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
0772                                 ASN1_ITEM_end(itname)
0773 
0774 # define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
0775         ASN1_ITEM_start(sname) \
0776                 ASN1_ITYPE_EXTERN, \
0777                 tag, \
0778                 NULL, \
0779                 0, \
0780                 &fptrs, \
0781                 0, \
0782                 #sname \
0783         ASN1_ITEM_end(sname)
0784 
0785 /* Macro to implement standard functions in terms of ASN1_ITEM structures */
0786 
0787 # define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
0788 
0789 # define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
0790 
0791 # define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
0792                         IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
0793 
0794 # define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
0795                 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
0796 
0797 # define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
0798                 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
0799 
0800 # define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
0801         pre stname *fname##_new(void) \
0802         { \
0803                 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
0804         } \
0805         pre void fname##_free(stname *a) \
0806         { \
0807                 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
0808         }
0809 
0810 # define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
0811         stname *fname##_new(void) \
0812         { \
0813                 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
0814         } \
0815         void fname##_free(stname *a) \
0816         { \
0817                 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
0818         }
0819 
0820 # define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
0821         IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
0822         IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
0823 
0824 # define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
0825         stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
0826         { \
0827                 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
0828         } \
0829         int i2d_##fname(const stname *a, unsigned char **out) \
0830         { \
0831                 return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
0832         }
0833 
0834 # define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
0835         int i2d_##stname##_NDEF(const stname *a, unsigned char **out) \
0836         { \
0837                 return ASN1_item_ndef_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
0838         }
0839 
0840 # define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
0841         static stname *d2i_##stname(stname **a, \
0842                                    const unsigned char **in, long len) \
0843         { \
0844                 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
0845                                                ASN1_ITEM_rptr(stname)); \
0846         } \
0847         static int i2d_##stname(const stname *a, unsigned char **out) \
0848         { \
0849                 return ASN1_item_i2d((const ASN1_VALUE *)a, out, \
0850                                      ASN1_ITEM_rptr(stname)); \
0851         }
0852 
0853 # define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
0854         stname * stname##_dup(const stname *x) \
0855         { \
0856         return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
0857         }
0858 
0859 # define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
0860         IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
0861 
0862 # define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
0863         int fname##_print_ctx(BIO *out, const stname *x, int indent, \
0864                                                 const ASN1_PCTX *pctx) \
0865         { \
0866                 return ASN1_item_print(out, (const ASN1_VALUE *)x, indent, \
0867                         ASN1_ITEM_rptr(itname), pctx); \
0868         }
0869 
0870 /* external definitions for primitive types */
0871 
0872 DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
0873 DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
0874 DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
0875 DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
0876 DECLARE_ASN1_ITEM(CBIGNUM)
0877 DECLARE_ASN1_ITEM(BIGNUM)
0878 DECLARE_ASN1_ITEM(INT32)
0879 DECLARE_ASN1_ITEM(ZINT32)
0880 DECLARE_ASN1_ITEM(UINT32)
0881 DECLARE_ASN1_ITEM(ZUINT32)
0882 DECLARE_ASN1_ITEM(INT64)
0883 DECLARE_ASN1_ITEM(ZINT64)
0884 DECLARE_ASN1_ITEM(UINT64)
0885 DECLARE_ASN1_ITEM(ZUINT64)
0886 
0887 # ifndef OPENSSL_NO_DEPRECATED_3_0
0888 /*
0889  * LONG and ZLONG are strongly discouraged for use as stored data, as the
0890  * underlying C type (long) differs in size depending on the architecture.
0891  * They are designed with 32-bit longs in mind.
0892  */
0893 DECLARE_ASN1_ITEM(LONG)
0894 DECLARE_ASN1_ITEM(ZLONG)
0895 # endif
0896 
0897 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_VALUE, ASN1_VALUE, ASN1_VALUE)
0898 #define sk_ASN1_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk))
0899 #define sk_ASN1_VALUE_value(sk, idx) ((ASN1_VALUE *)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), (idx)))
0900 #define sk_ASN1_VALUE_new(cmp) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new(ossl_check_ASN1_VALUE_compfunc_type(cmp)))
0901 #define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_null())
0902 #define sk_ASN1_VALUE_new_reserve(cmp, n) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_VALUE_compfunc_type(cmp), (n)))
0903 #define sk_ASN1_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n))
0904 #define sk_ASN1_VALUE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk))
0905 #define sk_ASN1_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk))
0906 #define sk_ASN1_VALUE_delete(sk, i) ((ASN1_VALUE *)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i)))
0907 #define sk_ASN1_VALUE_delete_ptr(sk, ptr) ((ASN1_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)))
0908 #define sk_ASN1_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
0909 #define sk_ASN1_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
0910 #define sk_ASN1_VALUE_pop(sk) ((ASN1_VALUE *)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk)))
0911 #define sk_ASN1_VALUE_shift(sk) ((ASN1_VALUE *)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk)))
0912 #define sk_ASN1_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk),ossl_check_ASN1_VALUE_freefunc_type(freefunc))
0913 #define sk_ASN1_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), (idx))
0914 #define sk_ASN1_VALUE_set(sk, idx, ptr) ((ASN1_VALUE *)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), ossl_check_ASN1_VALUE_type(ptr)))
0915 #define sk_ASN1_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
0916 #define sk_ASN1_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
0917 #define sk_ASN1_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), pnum)
0918 #define sk_ASN1_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk))
0919 #define sk_ASN1_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk))
0920 #define sk_ASN1_VALUE_dup(sk) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_VALUE_sk_type(sk)))
0921 #define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), ossl_check_ASN1_VALUE_freefunc_type(freefunc)))
0922 #define sk_ASN1_VALUE_set_cmp_func(sk, cmp) ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_compfunc_type(cmp)))
0923 
0924 
0925 
0926 /* Functions used internally by the ASN1 code */
0927 
0928 int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
0929 void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
0930 
0931 int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
0932                      const ASN1_ITEM *it, int tag, int aclass, char opt,
0933                      ASN1_TLC *ctx);
0934 
0935 int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
0936                      const ASN1_ITEM *it, int tag, int aclass);
0937 
0938 /* Legacy compatibility */
0939 # define IMPLEMENT_ASN1_FUNCTIONS_const(name) IMPLEMENT_ASN1_FUNCTIONS(name)
0940 # define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
0941          IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname)
0942 
0943 #ifdef  __cplusplus
0944 }
0945 #endif
0946 #endif