ASN1_item_d2i_bio.pod 3.6 KB

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