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