Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:18:45

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