ASN1_AUX_CB(3ossl)

๐Ÿ“ฆ version 3.5.0, in opensuse-leap 16.0

๐Ÿ’… ASN1_AUX_CB โ€” ASN.1 auxiliary data (manual page 3ossl, bestie)

okay so this is the OpenSSL 3ossl page for ASN1_AUX, ASN1_PRINT_ARG, ASN1_STREAM_ARG, ASN1_aux_cb and ASN1_aux_const_cb โ€” literally all the auxiliary-data glue for your ASN.1 templates. buckle up, it's a long one but it's giving โœจreference materialโœจ ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

ASN1_AUX, ASN1_PRINT_ARG, ASN1_STREAM_ARG, ASN1_aux_cb, ASN1_aux_const_cb โ€” ASN.1 auxiliary data ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

#include <openssl/asn1t.h>

struct ASN1_AUX_st {
    void *app_data;
    int flags;
    int ref_offset;             /* Offset of reference value */
    int ref_lock;               /* Offset to an CRYPTO_RWLOCK */
    ASN1_aux_cb *asn1_cb;
    int enc_offset;             /* Offset of ASN1_ENCODING structure */
    ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */
};
typedef struct ASN1_AUX_st ASN1_AUX;

struct ASN1_PRINT_ARG_st {
    BIO *out;
    int indent;
    const ASN1_PCTX *pctx;
};
typedef struct ASN1_PRINT_ARG_st ASN1_PRINT_ARG;

struct ASN1_STREAM_ARG_st {
    BIO *out;
    BIO *ndef_bio;
    unsigned char **boundary;
};
typedef struct ASN1_STREAM_ARG_st ASN1_STREAM_ARG;

typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
                        void *exarg);
typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in,
                              const ASN1_ITEM *it, void *exarg);

๐Ÿ‘‘ DESCRIPTION ๐Ÿ‘‘

so basically: ASN.1 data structures can be associated with an ASN1_AUX object to supply extra info about the ASN.1 structure. ๐Ÿ’– An ASN1_AUX structure gets associated with your structure during the definition of the ASN.1 template โ€” for example, an ASN1_AUX structure will be associated by using one of the various ASN.1 template definition macros that supply auxiliary information, like ASN1_SEQUENCE_enc(), ASN1_SEQUENCE_ref(), ASN1_SEQUENCE_cb_const_cb(), ASN1_SEQUENCE_const_cb(), ASN1_SEQUENCE_cb() or ASN1_NDEF_SEQUENCE_cb(). slay, that's the whole entry point situation ๐ŸŒˆ

An ASN1_AUX structure contains the following information. ๐Ÿ‘‡

  • app_data โ€” arbitrary application data ๐Ÿซถ
  • flags โ€” flags which indicate the auxiliary functionality supported. the details:
    • The ASN1_AFLG_REFCOUNT flag indicates that objects support reference counting.
    • The ASN1_AFLG_ENCODING flag indicates that the original encoding of the object will be saved.
    • The ASN1_AFLG_BROKEN flag is a work around for broken encoders where the sequence length value may not be correct. This should generally not be used. ๐Ÿ’€
    • The ASN1_AFLG_CONST_CB flag indicates that the "const" form of the ASN1_AUX callback should be used in preference to the non-const form.
  • ref_offset โ€” if the ASN1_AFLG_REFCOUNT flag is set, then this value is assumed to be an offset into the ASN1_VALUE structure where a CRYPTO_REF_COUNT may be found, for the purposes of reference counting. ๐Ÿงฎ
  • ref_lock โ€” if the ASN1_AFLG_REFCOUNT flag is set, then this value is assumed to be an offset into the ASN1_VALUE structure where a CRYPTO_RWLOCK may be found, for the purposes of reference counting. ๐Ÿ”’
  • asn1_cb โ€” a callback that will be invoked at various points during the processing of the ASN1_VALUE. see below for further details. ๐Ÿ‘€
  • enc_offset โ€” offset into the ASN1_VALUE object where the original encoding of the object will be saved if the ASN1_AFLG_ENCODING flag has been set. ๐Ÿ’พ
  • asn1_const_cb โ€” a callback that will be invoked at various points during the processing of the ASN1_VALUE. this is used in preference to the asn1_cb callback if the ASN1_AFLG_CONST_CB flag is set. see below for further details. โญ

๐Ÿ”ฅ the callbacks, like, actually doing stuff ๐Ÿ”ฅ

During the processing of an ASN1_VALUE object, the callbacks set via asn1_cb or asn1_const_cb will be invoked as a result of various events indicated via the operation parameter. the value of *in will be the ASN1_VALUE object being processed based on the template in it. an additional operation-specific parameter may be passed in exarg. ๐Ÿ“ฆ

the currently supported operations are as follows. the callbacks should return a positive value on success or zero on error, unless otherwise noted below. (this is the vibe check you do not fail ๐Ÿ™ˆ)

  • ASN1_OP_NEW_PRE โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure prior to an ASN1_VALUE object being allocated. the callback may allocate the ASN1_VALUE itself and store it in *pval. if it does so it should return 2 from the callback. on error it should return 0. โœŒ๏ธ
  • ASN1_OP_NEW_POST โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure after an ASN1_VALUE object has been allocated. the allocated object is in *pval. ๐ŸŽ‰
  • ASN1_OP_FREE_PRE โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately before an ASN1_VALUE is freed. if the callback originally constructed the ASN1_VALUE via ASN1_OP_NEW_PRE, then it should free it at this point and return 2 from the callback. otherwise it should return 1 for success or 0 on error. ๐Ÿงน
  • ASN1_OP_FREE_POST โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately after ASN1_VALUE sub-structures are freed. ๐Ÿซง
  • ASN1_OP_D2I_PRE โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately before a "d2i" operation for the ASN1_VALUE. ๐Ÿ“ฅ
  • ASN1_OP_D2I_POST โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately after a "d2i" operation for the ASN1_VALUE. ๐Ÿ“ฅโœจ
  • ASN1_OP_I2D_PRE โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately before a "i2d" operation for the ASN1_VALUE. ๐Ÿ“ค
  • ASN1_OP_I2D_POST โ€” invoked when processing a CHOICE, SEQUENCE or NDEF_SEQUENCE structure immediately after a "i2d" operation for the ASN1_VALUE. ๐Ÿ“คโœจ
  • ASN1_OP_PRINT_PRE โ€” invoked when processing a SEQUENCE or NDEF_SEQUENCE structure immediately before printing the ASN1_VALUE. the exarg argument will be a pointer to an ASN1_PRINT_ARG structure (see below). ๐Ÿ–จ๏ธ
  • ASN1_OP_PRINT_POST โ€” invoked when processing a SEQUENCE or NDEF_SEQUENCE structure immediately after printing the ASN1_VALUE. the exarg argument will be a pointer to an ASN1_PRINT_ARG structure (see below). ๐Ÿ–จ๏ธโœจ
  • ASN1_OP_STREAM_PRE โ€” invoked immediately prior to streaming the ASN1_VALUE data using indefinite length encoding. the exarg argument will be a pointer to an ASN1_STREAM_ARG structure (see below). ๐ŸŒŠ
  • ASN1_OP_STREAM_POST โ€” invoked immediately after streaming the ASN1_VALUE data using indefinite length encoding. the exarg argument will be a pointer to an ASN1_STREAM_ARG structure (see below). ๐ŸŒŠโœจ
  • ASN1_OP_DETACHED_PRE โ€” invoked immediately prior to processing the ASN1_VALUE data as a "detached" value (as used in CMS and PKCS7). the exarg argument will be a pointer to an ASN1_STREAM_ARG structure (see below). ๐Ÿช
  • ASN1_OP_DETACHED_POST โ€” invoked immediately after processing the ASN1_VALUE data as a "detached" value (as used in CMS and PKCS7). the exarg argument will be a pointer to an ASN1_STREAM_ARG structure (see below). ๐Ÿชโœจ
  • ASN1_OP_DUP_PRE โ€” invoked immediate prior to an ASN1_VALUE being duplicated via a call to ASN1_item_dup(). ๐Ÿ‘ฏ
  • ASN1_OP_DUP_POST โ€” invoked immediate after to an ASN1_VALUE has been duplicated via a call to ASN1_item_dup(). ๐Ÿ‘ฏโœจ
  • ASN1_OP_GET0_LIBCTX โ€” invoked in order to obtain the OSSL_LIB_CTX associated with an ASN1_VALUE, if any. a pointer to an OSSL_LIB_CTX should be stored in *exarg if such a value exists. ๐Ÿ—‚๏ธ
  • ASN1_OP_GET0_PROPQ โ€” invoked in order to obtain the property query string associated with an ASN1_VALUE, if any. a pointer to the property query string should be stored in *exarg if such a value exists. ๐Ÿ”Ž

๐ŸŽ€ ASN1_PRINT_ARG ๐ŸŽ€

An ASN1_PRINT_ARG object is used during processing of the ASN1_OP_PRINT_PRE and ASN1_OP_PRINT_POST callback operations. it contains the following information. ๐Ÿ’–

  • out โ€” the BIO being used to print the data out.
  • ndef_bio โ€” the current number of indent spaces that should be used for printing this data.
  • pctx โ€” the context for the ASN1_PCTX operation.

๐Ÿฆ‹ ASN1_STREAM_ARG ๐Ÿฆ‹

An ASN1_STREAM_ARG object is used during processing of the ASN1_OP_STREAM_PRE, ASN1_OP_STREAM_POST, ASN1_OP_DETACHED_PRE and ASN1_OP_DETACHED_POST callback operations. it contains the following information. ๐Ÿ’œ

  • out โ€” the BIO to stream through.
  • ndef_bio โ€” the BIO with filters appended.
  • boundary โ€” the streaming I/O boundary.

๐Ÿ’€ RETURN VALUES ๐Ÿ’€

The callbacks return 0 on error and a positive value on success. some operations require specific positive success values as noted above. ๐Ÿ‘† no cap, read the notes, they matter.


๐Ÿ”— SEE ALSO ๐Ÿ”—

ASN1_item_new_ex(3)


๐Ÿ“œ HISTORY ๐Ÿ“œ

The ASN1_aux_const_cb() callback and the ASN1_OP_GET0_LIBCTX and ASN1_OP_GET0_PROPQ operation types were added in OpenSSL 3.0. ๐Ÿ•ฐ๏ธ


Copyright 2021-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. ๐Ÿ“„


and that's the whole page bestie, mwah ๐Ÿ’‹ โ€” this one's from OpenSSL 3.5.0, dated 2026-09-25, manual section 3ossl, and honestly? iconic. go read ASN1_item_new_ex(3) next, ily ๐Ÿซถ๐ŸŽ€

๐Ÿ“ฆ where this page comes from