ASN1_aux_cb3ssl
Asn.1 auxiliary data
Usage
#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);
Overview
ASN.1 data structures can be associated with an ASN1_AUX object to supply additional information about the ASN.1 structure. An ASN1_AUX structure is associated with the 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 such as ASN1_SEQUENCE_enc(), ASN1_SEQUENCE_ref(), ASN1_SEQUENCE_cb_const_cb(), ASN1_SEQUENCE_const_cb(), ASN1_SEQUENCE_cb() or ASN1_NDEF_SEQUENCE_cb().
An ASN1_AUX structure contains the following information.
- app_data
-
Arbitrary application data
- flags
-
Flags which indicate the auxiliary functionality supported.
The
ASN1_AFLG_REFCOUNTflag indicates that objects support reference counting.The
ASN1_AFLG_ENCODINGflag indicates that the original encoding of the object will be saved.The
ASN1_AFLG_BROKENflag 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_CBflag indicates that the "const" form of theASN1_AUXcallback should be used in preference to the non-const form.
- ref_offset
-
If the
ASN1_AFLG_REFCOUNTflag is set then this value is assumed to be an offset into theASN1_VALUEstructure where aCRYPTO_REF_COUNTmay be found for the purposes of reference counting.
- ref_lock
-
If the
ASN1_AFLG_REFCOUNTflag is set then this value is assumed to be an offset into theASN1_VALUEstructure where aCRYPTO_RWLOCKmay 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_VALUEobject where the original encoding of the object will be saved if theASN1_AFLG_ENCODINGflag 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 theASN1_AFLG_CONST_CBflag is set. See below for further details.
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. Unless noted otherwise below, the callbacks should return a positive value on success and zero on error; some operations recognise additional return values, and a few do not consult the return value at all.
ASN1_OP_NEW_PRE-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure prior to anASN1_VALUEobject being allocated. The callback may allocate theASN1_VALUEitself 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_SEQUENCEstructure after anASN1_VALUEobject has been allocated. The allocated object is in *pval.
ASN1_OP_FREE_PRE-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately before anASN1_VALUEis freed. If the callback originally constructed theASN1_VALUEviaASN1_OP_NEW_PREthen it should free it at this point and return 2; the caller will then skip its normal freeing. Any other return value (including zero) causes the caller to proceed with normal freeing; the hook cannot signal an error.
ASN1_OP_FREE_POST-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately afterASN1_VALUEsub-structures are freed. The caller does not consult the return value from this hook.
ASN1_OP_D2I_PRE-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately before a "d2i" operation for theASN1_VALUE.
ASN1_OP_D2I_POST-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately after a "d2i" operation for theASN1_VALUE.
ASN1_OP_I2D_PRE-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately before a "i2d" operation for theASN1_VALUE.
ASN1_OP_I2D_POST-
Invoked when processing a CHOICE, SEQUENCE or
NDEF_SEQUENCEstructure immediately after a "i2d" operation for theASN1_VALUE.
ASN1_OP_PRINT_PRE-
Invoked when processing a SEQUENCE or
NDEF_SEQUENCEstructure immediately before printing theASN1_VALUE. The exarg argument will be a pointer to anASN1_PRINT_ARGstructure (see below). If the callback has fully printed the value itself it should return 2; the caller will then skip the per-field printing loop and the matchingASN1_OP_PRINT_POSTcallback. Return zero on error or any other positive value to continue with normal printing.
ASN1_OP_PRINT_POST-
Invoked when processing a SEQUENCE or
NDEF_SEQUENCEstructure immediately after printing theASN1_VALUE. The exarg argument will be a pointer to anASN1_PRINT_ARGstructure (see below).
ASN1_OP_STREAM_PRE-
Invoked immediately prior to streaming the
ASN1_VALUEdata using indefinite length encoding. The exarg argument will be a pointer to aASN1_STREAM_ARGstructure (see below).
ASN1_OP_STREAM_POST-
Invoked immediately after streaming the
ASN1_VALUEdata using indefinite length encoding. The exarg argument will be a pointer to aASN1_STREAM_ARGstructure (see below).
ASN1_OP_DETACHED_PRE-
Invoked immediately prior to processing the
ASN1_VALUEdata as a "detached" value (as used in CMS and PKCS7). The exarg argument will be a pointer to aASN1_STREAM_ARGstructure (see below).
ASN1_OP_DETACHED_POST-
Invoked immediately after processing the
ASN1_VALUEdata as a "detached" value (as used in CMS and PKCS7). The exarg argument will be a pointer to aASN1_STREAM_ARGstructure (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_CTXassociated with anASN1_VALUEif any. A pointer to anOSSL_LIB_CTXshould 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_VALUEif any. A pointer to the property query string should be stored in *exarg if such a value exists.
An ASN1_PRINT_ARG object is used during processing of 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 |
An ASN1_STREAM_ARG object is used during processing of 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
In general the callbacks return zero on error and a positive value on success. Several operations have additional or different return-value semantics, summarised here:
- •
-
ASN1_OP_NEW_PRErecognises a return of 2, meaning that the callback has allocated theASN1_VALUEitself and normal allocation should be skipped.
- •
-
ASN1_OP_FREE_PRErecognises a return of 2, meaning that the callback has freed theASN1_VALUEitself and normal freeing should be skipped. Other return values (including zero) cause normal freeing to proceed; the hook cannot signal an error.
- •
-
ASN1_OP_FREE_POST's return value is not consulted by the caller.
- •
-
ASN1_OP_PRINT_PRErecognises a return of 2, meaning that the callback has printed the value itself; the caller will skip the per-field printing loop and the matchingASN1_OP_PRINT_POSTinvocation.
- •
-
ASN1_OP_STREAM_PRE,ASN1_OP_STREAM_POST,ASN1_OP_DETACHED_PRE, andASN1_OP_DETACHED_POSTtreat any non-positive return value (zero or negative) as an error.
Releases
3 releases since Debian 12 (Bookworm); the text changed 2 times.