xref: /freebsd/secure/lib/libcrypto/man/man3/ASN1_EXTERN_FUNCS.3 (revision 02e9120893770924227138ba49df1edb3896112a)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "ASN1_EXTERN_FUNCS 3ossl"
ASN1_EXTERN_FUNCS 3ossl "2023-09-19" "3.0.11" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
ASN1_EXTERN_FUNCS, ASN1_ex_d2i, ASN1_ex_d2i_ex, ASN1_ex_i2d, ASN1_ex_new_func, ASN1_ex_new_ex_func, ASN1_ex_free_func, ASN1_ex_print_func, IMPLEMENT_EXTERN_ASN1 \- ASN.1 external function support
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/asn1t.h> \& typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx, OSSL_LIB_CTX *libctx, const char *propq); typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, const char *propq); typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval, int indent, const char *fname, const ASN1_PCTX *pctx); \& struct ASN1_EXTERN_FUNCS_st { void *app_data; ASN1_ex_new_func *asn1_ex_new; ASN1_ex_free_func *asn1_ex_free; ASN1_ex_free_func *asn1_ex_clear; ASN1_ex_d2i *asn1_ex_d2i; ASN1_ex_i2d *asn1_ex_i2d; ASN1_ex_print_func *asn1_ex_print; ASN1_ex_new_ex_func *asn1_ex_new_ex; ASN1_ex_d2i_ex *asn1_ex_d2i_ex; }; typedef struct ASN1_EXTERN_FUNCS_st ASN1_EXTERN_FUNCS; \& #define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) .Ve
"DESCRIPTION"
Header "DESCRIPTION" \s-1ASN.1\s0 data structures templates are typically defined in OpenSSL using a series of macros such as \s-1ASN1_SEQUENCE\s0(), \s-1ASN1_SEQUENCE_END\s0() and so on. Instead templates can also be defined based entirely on external functions. These external functions are called to perform operations such as creating a new \fB\s-1ASN1_VALUE\s0 or converting an \s-1ASN1_VALUE\s0 to or from \s-1DER\s0 encoding.

The macro \s-1IMPLEMENT_EXTERN_ASN1\s0() can be used to create such an externally defined structure. The name of the structure should be supplied in the sname parameter. The tag for the structure (e.g. typically V_ASN1_SEQUENCE) should be supplied in the tag parameter. Finally a pointer to an \fB\s-1ASN1_EXTERN_FUNCS\s0 structure should be supplied in the fptrs parameter.

The \s-1ASN1_EXTERN_FUNCS\s0 structure has the following entries.

"app_data" 4
Item "app_data" A pointer to arbitrary application specific data.
"asn1_ex_new" 4
Item "asn1_ex_new" A \*(L"new\*(R" function responsible for constructing a new \s-1ASN1_VALUE\s0 object. The newly constructed value should be stored in *pval. The it parameter is a pointer to the \s-1ASN1_ITEM\s0 template object created via the \s-1IMPLEMENT_EXTERN_ASN1\s0() macro. .Sp Returns a positive value on success or 0 on error.
"asn1_ex_free" 4
Item "asn1_ex_free" A \*(L"free\*(R" function responsible for freeing the \s-1ASN1_VALUE\s0 passed in *pval that was previously allocated via a \*(L"new\*(R" function. The it parameter is a pointer to the \s-1ASN1_ITEM\s0 template object created via the \s-1IMPLEMENT_EXTERN_ASN1\s0() macro.
"asn1_ex_clear" 4
Item "asn1_ex_clear" A \*(L"clear\*(R" function responsible for clearing any data in the \s-1ASN1_VALUE\s0 passed in *pval and making it suitable for reuse. The it parameter is a pointer to the \s-1ASN1_ITEM\s0 template object created via the \s-1IMPLEMENT_EXTERN_ASN1\s0() macro.
"asn1_ex_d2i" 4
Item "asn1_ex_d2i" A \*(L"d2i\*(R" function responsible for converting \s-1DER\s0 data with the tag tag and class class into an \s-1ASN1_VALUE\s0. If *pval is non-NULL then the \fB\s-1ASN_VALUE\s0 it points to should be reused. Otherwise a new \s-1ASN1_VALUE\s0 should be allocated and stored in *pval. *in points to the \s-1DER\s0 data to be decoded and len is the length of that data. After decoding *in should be updated to point at the next byte after the decoded data. If the \s-1ASN1_VALUE\s0 is considered optional in this context then opt will be nonzero. Otherwise it will be zero. The it parameter is a pointer to the \s-1ASN1_ITEM\s0 template object created via the \s-1IMPLEMENT_EXTERN_ASN1\s0() macro. A pointer to the current \fB\s-1ASN1_TLC\s0 context (which may be required for other \s-1ASN1\s0 function calls) is passed in the ctx parameter. .Sp The asn1_ex_d2i entry may be \s-1NULL\s0 if asn1_ex_d2i_ex has been specified instead. .Sp Returns <= 0 on error or a positive value on success.
"asn1_ex_i2d" 4
Item "asn1_ex_i2d" An \*(L"i2d\*(R" function responsible for converting an \s-1ASN1_VALUE\s0 into \s-1DER\s0 encoding. On entry *pval will contain the \s-1ASN1_VALUE\s0 to be encoded. If default tagging is to be used then tag will be -1 on entry. Otherwise if implicit tagging should be used then tag and aclass will be the tag and associated class. .Sp If out is not \s-1NULL\s0 then this function should write the \s-1DER\s0 encoded data to the buffer in *out, and then increment *out to point to immediately after the data just written. .Sp If out is \s-1NULL\s0 then no data should be written but the length calculated and returned as if it were. .Sp The asn1_ex_i2d entry may be \s-1NULL\s0 if asn1_ex_i2d_ex has been specified instead. .Sp The return value should be negative if a fatal error occurred, or 0 if a non-fatal error occurred. Otherwise it should return the length of the encoded data.
"asn1_ex_print" 4
Item "asn1_ex_print" A \*(L"print\*(R" function. out is the \s-1BIO\s0 to print the output to. *pval is the \fB\s-1ASN1_VALUE\s0 to be printed. indent is the number of spaces of indenting to be printed before any data is printed. fname is currently unused and is always "". pctx is a pointer to the \s-1ASN1_PCTX\s0 for the print operation. .Sp Returns 0 on error or a positive value on success. If the return value is 2 then an additional newline will be printed after the data printed by this function.
"asn1_ex_new_ex" 4
Item "asn1_ex_new_ex" This is the same as asn1_ex_new except that it is additionally passed the \s-1OSSL_LIB_CTX\s0 to be used in libctx and any property query string to be used for algorithm fetching in the propq parameter. See \*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in crypto\|(7) for further details. If asn1_ex_new_ex is non \s-1NULL,\s0 then it will always be called in preference to asn1_ex_new.
"asn1_ex_d2i_ex" 4
Item "asn1_ex_d2i_ex" This is the same as asn1_ex_d2i except that it is additionally passed the \s-1OSSL_LIB_CTX\s0 to be used in libctx and any property query string to be used for algorithm fetching in the propq parameter. See \*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in crypto\|(7) for further details. If asn1_ex_d2i_ex is non \s-1NULL,\s0 then it will always be called in preference to asn1_ex_d2i.
"RETURN VALUES"
Header "RETURN VALUES" Return values for the various callbacks are as described above.
"SEE ALSO"
Header "SEE ALSO" \fBASN1_item_new_ex\|(3)
"HISTORY"
Header "HISTORY" The asn1_ex_new_ex and asn1_ex_d2i_ex callbacks were added in OpenSSL 3.0.
"COPYRIGHT"
Header "COPYRIGHT" Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.