xref: /freebsd/crypto/openssl/doc/man3/ASN1_item_d2i_bio.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1=pod
2
3=head1 NAME
4
5ASN1_item_d2i_ex, ASN1_item_d2i, ASN1_item_d2i_bio_ex, ASN1_item_d2i_bio,
6ASN1_item_d2i_fp_ex, ASN1_item_d2i_fp, ASN1_item_i2d_mem_bio
7- decode and encode DER-encoded ASN.1 structures
8
9=head1 SYNOPSIS
10
11 #include <openssl/asn1.h>
12
13 ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **pval, const unsigned char **in,
14                              long len, const ASN1_ITEM *it,
15                              OSSL_LIB_CTX *libctx, const char *propq);
16 ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in,
17                           long len, const ASN1_ITEM *it);
18
19 void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *x,
20                            OSSL_LIB_CTX *libctx, const char *propq);
21 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
22
23 void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x,
24                           OSSL_LIB_CTX *libctx, const char *propq);
25 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
26
27 BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val);
28
29=head1 DESCRIPTION
30
31ASN1_item_d2i_ex() decodes the contents of the data stored in I<*in> of length
32I<len> which must be a DER-encoded ASN.1 structure, using the ASN.1 template
33I<it>. It places the result in I<*pval> unless I<pval> is NULL. If I<*pval> is
34non-NULL on entry then the B<ASN1_VALUE> present there will be reused. Otherwise
35a new B<ASN1_VALUE> will be allocated. If any algorithm fetches are required
36during the process then they will use the B<OSSL_LIB_CTX>provided in the
37I<libctx> parameter and the property query string in I<propq>. See
38L<crypto(7)/ALGORITHM FETCHING> for more information about algorithm fetching.
39On exit I<*in> will be updated to point to the next byte in the buffer after the
40decoded structure.
41
42ASN1_item_d2i() is the same as ASN1_item_d2i_ex() except that the default
43OSSL_LIB_CTX is used (i.e. NULL) and with a NULL property query string.
44
45ASN1_item_d2i_bio_ex() decodes the contents of its input BIO I<in>,
46which must be a DER-encoded ASN.1 structure, using the ASN.1 template I<it>
47and places the result in I<*pval> unless I<pval> is NULL.
48If I<in> is NULL it returns NULL, else a pointer to the parsed structure. If any
49algorithm fetches are required during the process then they will use the
50B<OSSL_LIB_CTX> provided in the I<libctx> parameter and the property query
51string in I<propq>. See L<crypto(7)/ALGORITHM FETCHING> for more information
52about algorithm fetching.
53
54ASN1_item_d2i_bio() is the same as ASN1_item_d2i_bio_ex() except that the
55default B<OSSL_LIB_CTX> is used (i.e. NULL) and with a NULL property query
56string.
57
58ASN1_item_d2i_fp_ex() is the same as ASN1_item_d2i_bio_ex() except that a FILE
59pointer is provided instead of a BIO.
60
61ASN1_item_d2i_fp() is the same as ASN1_item_d2i_fp_ex() except that the
62default B<OSSL_LIB_CTX> is used (i.e. NULL) and with a NULL property query
63string.
64
65ASN1_item_i2d_mem_bio() encodes the given ASN.1 value I<val>
66using the ASN.1 template I<it> and returns the result in a memory BIO.
67
68=head1 RETURN VALUES
69
70ASN1_item_d2i_bio() returns a pointer to an B<ASN1_VALUE> or NULL.
71
72ASN1_item_i2d_mem_bio() returns a pointer to a memory BIO or NULL on error.
73
74=head1 HISTORY
75
76The functions ASN1_item_d2i_ex(), ASN1_item_d2i_bio_ex(), ASN1_item_d2i_fp_ex()
77and ASN1_item_i2d_mem_bio() were added in OpenSSL 3.0.
78
79=head1 COPYRIGHT
80
81Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
82
83Licensed under the Apache License 2.0 (the "License").  You may not use
84this file except in compliance with the License.  You can obtain a copy
85in the file LICENSE in the source distribution or at
86L<https://www.openssl.org/source/license.html>.
87
88=cut
89