Home | History | Annotate | Line # | Download | only in man3
      1  1.1  christos =pod
      2  1.1  christos 
      3  1.1  christos =head1 NAME
      4  1.1  christos 
      5  1.1  christos ASN1_AUX, ASN1_PRINT_ARG, ASN1_STREAM_ARG, ASN1_aux_cb, ASN1_aux_const_cb
      6  1.2  christos - ASN.1 auxiliary data
      7  1.1  christos 
      8  1.1  christos =head1 SYNOPSIS
      9  1.1  christos 
     10  1.1  christos  #include <openssl/asn1t.h>
     11  1.1  christos 
     12  1.1  christos  struct ASN1_AUX_st {
     13  1.1  christos      void *app_data;
     14  1.1  christos      int flags;
     15  1.1  christos      int ref_offset;             /* Offset of reference value */
     16  1.1  christos      int ref_lock;               /* Offset to an CRYPTO_RWLOCK */
     17  1.1  christos      ASN1_aux_cb *asn1_cb;
     18  1.1  christos      int enc_offset;             /* Offset of ASN1_ENCODING structure */
     19  1.1  christos      ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */
     20  1.1  christos  };
     21  1.1  christos  typedef struct ASN1_AUX_st ASN1_AUX;
     22  1.1  christos 
     23  1.1  christos  struct ASN1_PRINT_ARG_st {
     24  1.1  christos      BIO *out;
     25  1.1  christos      int indent;
     26  1.1  christos      const ASN1_PCTX *pctx;
     27  1.1  christos  };
     28  1.1  christos  typedef struct ASN1_PRINT_ARG_st ASN1_PRINT_ARG;
     29  1.1  christos 
     30  1.1  christos  struct ASN1_STREAM_ARG_st {
     31  1.1  christos      BIO *out;
     32  1.1  christos      BIO *ndef_bio;
     33  1.1  christos      unsigned char **boundary;
     34  1.1  christos  };
     35  1.1  christos  typedef struct ASN1_STREAM_ARG_st ASN1_STREAM_ARG;
     36  1.1  christos 
     37  1.1  christos  typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
     38  1.1  christos                          void *exarg);
     39  1.1  christos  typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in,
     40  1.1  christos                                const ASN1_ITEM *it, void *exarg);
     41  1.1  christos 
     42  1.1  christos =head1 DESCRIPTION
     43  1.1  christos 
     44  1.1  christos ASN.1 data structures can be associated with an B<ASN1_AUX> object to supply
     45  1.1  christos additional information about the ASN.1 structure. An B<ASN1_AUX> structure is
     46  1.1  christos associated with the structure during the definition of the ASN.1 template. For
     47  1.1  christos example an B<ASN1_AUX> structure will be associated by using one of the various
     48  1.2  christos ASN.1 template definition macros that supply auxiliary information such as
     49  1.1  christos ASN1_SEQUENCE_enc(), ASN1_SEQUENCE_ref(), ASN1_SEQUENCE_cb_const_cb(),
     50  1.1  christos ASN1_SEQUENCE_const_cb(), ASN1_SEQUENCE_cb() or ASN1_NDEF_SEQUENCE_cb().
     51  1.1  christos 
     52  1.1  christos An B<ASN1_AUX> structure contains the following information.
     53  1.1  christos 
     54  1.1  christos =over 4
     55  1.1  christos 
     56  1.1  christos =item I<app_data>
     57  1.1  christos 
     58  1.1  christos Arbitrary application data
     59  1.1  christos 
     60  1.1  christos =item I<flags>
     61  1.1  christos 
     62  1.1  christos Flags which indicate the auxiliarly functionality supported.
     63  1.1  christos 
     64  1.1  christos The B<ASN1_AFLG_REFCOUNT> flag indicates that objects support reference counting.
     65  1.1  christos 
     66  1.1  christos The B<ASN1_AFLG_ENCODING> flag indicates that the original encoding of the
     67  1.1  christos object will be saved.
     68  1.1  christos 
     69  1.1  christos The B<ASN1_AFLG_BROKEN> flag is a work around for broken encoders where the
     70  1.1  christos sequence length value may not be correct. This should generally not be used.
     71  1.1  christos 
     72  1.1  christos The B<ASN1_AFLG_CONST_CB> flag indicates that the "const" form of the
     73  1.1  christos B<ASN1_AUX> callback should be used in preference to the non-const form.
     74  1.1  christos 
     75  1.1  christos =item I<ref_offset>
     76  1.1  christos 
     77  1.1  christos If the B<ASN1_AFLG_REFCOUNT> flag is set then this value is assumed to be an
     78  1.1  christos offset into the B<ASN1_VALUE> structure where a B<CRYPTO_REF_COUNT> may be
     79  1.1  christos found for the purposes of reference counting.
     80  1.1  christos 
     81  1.1  christos =item I<ref_lock>
     82  1.1  christos 
     83  1.1  christos If the B<ASN1_AFLG_REFCOUNT> flag is set then this value is assumed to be an
     84  1.1  christos offset into the B<ASN1_VALUE> structure where a B<CRYPTO_RWLOCK> may be
     85  1.1  christos found for the purposes of reference counting.
     86  1.1  christos 
     87  1.1  christos =item I<asn1_cb>
     88  1.1  christos 
     89  1.1  christos A callback that will be invoked at various points during the processing of
     90  1.3  christos the B<ASN1_VALUE>. See below for further details.
     91  1.1  christos 
     92  1.1  christos =item I<enc_offset>
     93  1.1  christos 
     94  1.1  christos Offset into the B<ASN1_VALUE> object where the original encoding of the object
     95  1.1  christos will be saved if the B<ASN1_AFLG_ENCODING> flag has been set.
     96  1.1  christos 
     97  1.1  christos =item I<asn1_const_cb>
     98  1.1  christos 
     99  1.1  christos A callback that will be invoked at various points during the processing of
    100  1.3  christos the B<ASN1_VALUE>. This is used in preference to the I<asn1_cb> callback if
    101  1.1  christos the B<ASN1_AFLG_CONST_CB> flag is set. See below for further details.
    102  1.1  christos 
    103  1.1  christos =back
    104  1.1  christos 
    105  1.1  christos During the processing of an B<ASN1_VALUE> object the callbacks set via
    106  1.1  christos I<asn1_cb> or I<asn1_const_cb> will be invoked as a result of various events
    107  1.1  christos indicated via the I<operation> parameter. The value of I<*in> will be the
    108  1.1  christos B<ASN1_VALUE> object being processed based on the template in I<it>. An
    109  1.1  christos additional operation specific parameter may be passed in I<exarg>. The currently
    110  1.1  christos supported operations are as follows. The callbacks should return a positive
    111  1.1  christos value on success or zero on error, unless otherwise noted below.
    112  1.1  christos 
    113  1.1  christos =over 4
    114  1.1  christos 
    115  1.1  christos =item B<ASN1_OP_NEW_PRE>
    116  1.1  christos 
    117  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    118  1.1  christos prior to an B<ASN1_VALUE> object being allocated. The callback may allocate the
    119  1.1  christos B<ASN1_VALUE> itself and store it in I<*pval>. If it does so it should return 2
    120  1.1  christos from the callback. On error it should return 0.
    121  1.1  christos 
    122  1.1  christos =item B<ASN1_OP_NEW_POST>
    123  1.1  christos 
    124  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    125  1.1  christos after an B<ASN1_VALUE> object has been allocated. The allocated object is in
    126  1.1  christos I<*pval>.
    127  1.1  christos 
    128  1.1  christos =item B<ASN1_OP_FREE_PRE>
    129  1.1  christos 
    130  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    131  1.1  christos immediately before an B<ASN1_VALUE> is freed. If the callback originally
    132  1.1  christos constructed the B<ASN1_VALUE> via B<ASN1_OP_NEW_PRE> then it should free it at
    133  1.1  christos this point and return 2 from the callback. Otherwise it should return 1 for
    134  1.1  christos success or 0 on error.
    135  1.1  christos 
    136  1.1  christos =item B<ASN1_OP_FREE_POST>
    137  1.1  christos 
    138  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    139  1.1  christos immediately after B<ASN1_VALUE> sub-structures are freed.
    140  1.1  christos 
    141  1.1  christos =item B<ASN1_OP_D2I_PRE>
    142  1.1  christos 
    143  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    144  1.1  christos immediately before a "d2i" operation for the B<ASN1_VALUE>.
    145  1.1  christos 
    146  1.1  christos =item B<ASN1_OP_D2I_POST>
    147  1.1  christos 
    148  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    149  1.1  christos immediately after a "d2i" operation for the B<ASN1_VALUE>.
    150  1.1  christos 
    151  1.1  christos =item B<ASN1_OP_I2D_PRE>
    152  1.1  christos 
    153  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    154  1.1  christos immediately before a "i2d" operation for the B<ASN1_VALUE>.
    155  1.1  christos 
    156  1.1  christos =item B<ASN1_OP_I2D_POST>
    157  1.1  christos 
    158  1.1  christos Invoked when processing a B<CHOICE>, B<SEQUENCE> or B<NDEF_SEQUENCE> structure
    159  1.1  christos immediately after a "i2d" operation for the B<ASN1_VALUE>.
    160  1.1  christos 
    161  1.1  christos =item B<ASN1_OP_PRINT_PRE>
    162  1.1  christos 
    163  1.1  christos Invoked when processing a B<SEQUENCE> or B<NDEF_SEQUENCE> structure immediately
    164  1.1  christos before printing the B<ASN1_VALUE>. The I<exarg> argument will be a pointer to an
    165  1.1  christos B<ASN1_PRINT_ARG> structure (see below).
    166  1.1  christos 
    167  1.1  christos =item B<ASN1_OP_PRINT_POST>
    168  1.1  christos 
    169  1.1  christos Invoked when processing a B<SEQUENCE> or B<NDEF_SEQUENCE> structure immediately
    170  1.1  christos after printing the B<ASN1_VALUE>. The I<exarg> argument will be a pointer to an
    171  1.1  christos B<ASN1_PRINT_ARG> structure (see below).
    172  1.1  christos 
    173  1.1  christos =item B<ASN1_OP_STREAM_PRE>
    174  1.1  christos 
    175  1.1  christos Invoked immediately prior to streaming the B<ASN1_VALUE> data using indefinite
    176  1.1  christos length encoding. The I<exarg> argument will be a pointer to a B<ASN1_STREAM_ARG>
    177  1.1  christos structure (see below).
    178  1.1  christos 
    179  1.1  christos =item B<ASN1_OP_STREAM_POST>
    180  1.1  christos 
    181  1.1  christos Invoked immediately after streaming the B<ASN1_VALUE> data using indefinite
    182  1.1  christos length encoding. The I<exarg> argument will be a pointer to a B<ASN1_STREAM_ARG>
    183  1.1  christos structure (see below).
    184  1.1  christos 
    185  1.1  christos =item B<ASN1_OP_DETACHED_PRE>
    186  1.1  christos 
    187  1.1  christos Invoked immediately prior to processing the B<ASN1_VALUE> data as a "detached"
    188  1.1  christos value (as used in CMS and PKCS7). The I<exarg> argument will be a pointer to a
    189  1.1  christos B<ASN1_STREAM_ARG> structure (see below).
    190  1.1  christos 
    191  1.1  christos =item B<ASN1_OP_DETACHED_POST>
    192  1.1  christos 
    193  1.1  christos Invoked immediately after processing the B<ASN1_VALUE> data as a "detached"
    194  1.1  christos value (as used in CMS and PKCS7). The I<exarg> argument will be a pointer to a
    195  1.1  christos B<ASN1_STREAM_ARG> structure (see below).
    196  1.1  christos 
    197  1.1  christos =item B<ASN1_OP_DUP_PRE>
    198  1.1  christos 
    199  1.1  christos Invoked immediate prior to an ASN1_VALUE being duplicated via a call to
    200  1.1  christos ASN1_item_dup().
    201  1.1  christos 
    202  1.1  christos =item B<ASN1_OP_DUP_POST>
    203  1.1  christos 
    204  1.1  christos Invoked immediate after to an ASN1_VALUE has been duplicated via a call to
    205  1.1  christos ASN1_item_dup().
    206  1.1  christos 
    207  1.1  christos =item B<ASN1_OP_GET0_LIBCTX>
    208  1.1  christos 
    209  1.1  christos Invoked in order to obtain the B<OSSL_LIB_CTX> associated with an B<ASN1_VALUE>
    210  1.1  christos if any. A pointer to an B<OSSL_LIB_CTX> should be stored in I<*exarg> if such
    211  1.1  christos a value exists.
    212  1.1  christos 
    213  1.1  christos =item B<ASN1_OP_GET0_PROPQ>
    214  1.1  christos 
    215  1.1  christos Invoked in order to obtain the property query string associated with an
    216  1.1  christos B<ASN1_VALUE> if any. A pointer to the property query string should be stored in
    217  1.1  christos I<*exarg> if such a value exists.
    218  1.1  christos 
    219  1.1  christos =back
    220  1.1  christos 
    221  1.1  christos An B<ASN1_PRINT_ARG> object is used during processing of B<ASN1_OP_PRINT_PRE>
    222  1.1  christos and B<ASN1_OP_PRINT_POST> callback operations. It contains the following
    223  1.1  christos information.
    224  1.1  christos 
    225  1.1  christos =over 4
    226  1.1  christos 
    227  1.1  christos =item I<out>
    228  1.1  christos 
    229  1.1  christos The B<BIO> being used to print the data out.
    230  1.1  christos 
    231  1.1  christos =item I<ndef_bio>
    232  1.1  christos 
    233  1.1  christos The current number of indent spaces that should be used for printing this data.
    234  1.1  christos 
    235  1.1  christos =item I<pctx>
    236  1.1  christos 
    237  1.1  christos The context for the B<ASN1_PCTX> operation.
    238  1.1  christos 
    239  1.1  christos =back
    240  1.1  christos 
    241  1.1  christos An B<ASN1_STREAM_ARG> object is used during processing of B<ASN1_OP_STREAM_PRE>,
    242  1.1  christos B<ASN1_OP_STREAM_POST>, B<ASN1_OP_DETACHED_PRE> and B<ASN1_OP_DETACHED_POST>
    243  1.1  christos callback operations. It contains the following information.
    244  1.1  christos 
    245  1.1  christos =over 4
    246  1.1  christos 
    247  1.1  christos =item I<out>
    248  1.1  christos 
    249  1.1  christos The B<BIO> to stream through
    250  1.1  christos 
    251  1.1  christos =item I<ndef_bio>
    252  1.1  christos 
    253  1.1  christos The B<BIO> with filters appended
    254  1.1  christos 
    255  1.1  christos =item I<boundary>
    256  1.1  christos 
    257  1.1  christos The streaming I/O boundary.
    258  1.1  christos 
    259  1.1  christos =back
    260  1.1  christos 
    261  1.1  christos =head1 RETURN VALUES
    262  1.1  christos 
    263  1.1  christos The callbacks return 0 on error and a positive value on success. Some operations
    264  1.1  christos require specific positive success values as noted above.
    265  1.1  christos 
    266  1.1  christos =head1 SEE ALSO
    267  1.1  christos 
    268  1.1  christos L<ASN1_item_new_ex(3)>
    269  1.1  christos 
    270  1.1  christos =head1 HISTORY
    271  1.1  christos 
    272  1.1  christos The ASN1_aux_const_cb() callback and the B<ASN1_OP_GET0_LIBCTX> and
    273  1.1  christos B<ASN1_OP_GET0_PROPQ> operation types were added in OpenSSL 3.0.
    274  1.1  christos 
    275  1.1  christos =head1 COPYRIGHT
    276  1.1  christos 
    277  1.3  christos Copyright 2021-2025 The OpenSSL Project Authors. All Rights Reserved.
    278  1.1  christos 
    279  1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    280  1.1  christos this file except in compliance with the License.  You can obtain a copy
    281  1.1  christos in the file LICENSE in the source distribution or at
    282  1.1  christos L<https://www.openssl.org/source/license.html>.
    283  1.1  christos 
    284  1.1  christos =cut
    285