BIO_F_ASN1(3) | Library Functions Manual | BIO_F_ASN1(3) |
BIO_f_asn1
,
asn1_ps_func
,
BIO_asn1_set_prefix
,
BIO_asn1_get_prefix
,
BIO_asn1_set_suffix
,
BIO_asn1_get_suffix
—
BER-encoding filter BIO
#include
<openssl/asn1.h>
const BIO_METHOD *
BIO_f_asn1
(void);
#include
<openssl/bio.h>
typedef int
asn1_ps_func
(BIO *bio,
unsigned char **pbuf, int *plen,
void *parg);
int
BIO_asn1_set_prefix
(BIO *chain,
asn1_ps_func *prefix, asn1_ps_func
*prefix_free);
int
BIO_asn1_get_prefix
(BIO *chain,
asn1_ps_func **pprefix, asn1_ps_func
**pprefix_free);
int
BIO_asn1_set_suffix
(BIO *chain,
asn1_ps_func *suffix, asn1_ps_func
*suffix_free);
int
BIO_asn1_get_suffix
(BIO *chain,
asn1_ps_func **psuffix, asn1_ps_func
**psuffix_free);
BIO_f_asn1
()
returns the "asn1" BIO method. BIOs created from it with
BIO_new(3) are filter BIOs intended to
BER-encode data written to them and pass the encoded data on to the next BIO
in the chain. Such BIOs operate as follows:
BIO_TYPE_ASN1
.If a prefix
function was installed with
BIO_asn1_set_prefix
(),
that function is called before writing the object. It may for example
produce additional output. If it fails, writing fails.
If a prefix_free function was installed as well, that function is called after writing any output produced by prefix but before writing the object. Failure of prefix_free is silently ignored.
BIO_C_SET_EX_ARG
stores the pointer
parg internally such that it will be passed to the
asn1_ps_func
()
callback functions. With a cmd of
BIO_C_GET_EX_ARG
, it retrieves that pointer,
storing it in *parg. The commands
BIO_C_SET_PREFIX
,
BIO_C_GET_PREFIX
,
BIO_C_SET_SUFFIX
,
BIO_C_GET_SUFFIX
, and
BIO_CTRL_FLUSH
are used internally to implement
BIO_asn1_set_prefix
(),
BIO_asn1_get_prefix
(),
BIO_asn1_set_suffix
(),
BIO_asn1_get_suffix
() and
BIO_flush(3) and are not intended
for use by application programs. Other commands are merely forwarded to
the next BIO in the chain.If the above description of a function mentions the next BIO in the chain, that function fails if the asn1 BIO is the last BIO in the chain.
BIO_asn1_set_prefix
()
and
BIO_asn1_get_prefix
()
install and retrieve the prefix and
prefix_free callback functions in and from the first
asn1 BIO in the given chain. Similarly,
BIO_asn1_set_suffix
()
and
BIO_asn1_get_suffix
()
install and retrieve the suffix and
suffix_free callback functions. Passing a
NULL
pointer for any of the
asn1_ps_func
() arguments disables that particular
callback.
BIO_f_asn1
() always returns a pointer to a
static built-in object.
Functions of the type asn1_ps_func
() are
supposed to return 1 on success or 0 on failure.
BIO_asn1_set_prefix
(),
BIO_asn1_get_prefix
(),
BIO_asn1_set_suffix
(), and
BIO_asn1_get_suffix
() return 1 on success or 0 if
chain is a NULL
pointer or
does not contain any asn1 BIO. They may return -2 if a BIO is encountered in
the chain that is not properly initialized.
ASN1_put_object(3), BIO_ctrl(3), BIO_new(3), BIO_new_NDEF(3), BIO_next(3), BIO_write(3), i2d_ASN1_OCTET_STRING(3)
These functions first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9.
December 12, 2021 | OpenBSD-current |