ASN1_TYPE_get.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. =pod
  2. =head1 NAME
  3. ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp, ASN1_TYPE_unpack_sequence, ASN1_TYPE_pack_sequence - ASN1_TYPE utility
  4. functions
  5. =head1 SYNOPSIS
  6. #include <openssl/asn1.h>
  7. int ASN1_TYPE_get(const ASN1_TYPE *a);
  8. void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
  9. int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
  10. int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
  11. void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
  12. ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s,
  13. ASN1_TYPE **t);
  14. =head1 DESCRIPTION
  15. These functions allow an B<ASN1_TYPE> structure to be manipulated. The
  16. B<ASN1_TYPE> structure can contain any ASN.1 type or constructed type
  17. such as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type.
  18. ASN1_TYPE_get() returns the type of I<a>.
  19. ASN1_TYPE_set() sets the value of I<a> to I<type> and I<value>. This
  20. function uses the pointer I<value> internally so it must B<not> be freed
  21. up after the call.
  22. ASN1_TYPE_set1() sets the value of I<a> to I<type> a copy of I<value>.
  23. ASN1_TYPE_cmp() compares ASN.1 types I<a> and I<b> and returns 0 if
  24. they are identical and nonzero otherwise.
  25. ASN1_TYPE_unpack_sequence() attempts to parse the SEQUENCE present in
  26. I<t> using the ASN.1 structure I<it>. If successful it returns a pointer
  27. to the ASN.1 structure corresponding to I<it> which must be freed by the
  28. caller. If it fails it return NULL.
  29. ASN1_TYPE_pack_sequence() attempts to encode the ASN.1 structure I<s>
  30. corresponding to I<it> into an B<ASN1_TYPE>. If successful the encoded
  31. B<ASN1_TYPE> is returned. If I<t> and I<*t> are not NULL the encoded type
  32. is written to I<t> overwriting any existing data. If I<t> is not NULL
  33. but I<*t> is NULL the returned B<ASN1_TYPE> is written to I<*t>.
  34. =head1 NOTES
  35. The type and meaning of the I<value> parameter for ASN1_TYPE_set() and
  36. ASN1_TYPE_set1() is determined by the I<type> parameter.
  37. If I<type> is B<V_ASN1_NULL> I<value> is ignored. If I<type> is
  38. B<V_ASN1_BOOLEAN>
  39. then the boolean is set to TRUE if I<value> is not NULL. If I<type> is
  40. B<V_ASN1_OBJECT> then value is an B<ASN1_OBJECT> structure. Otherwise I<type>
  41. is and B<ASN1_STRING> structure. If I<type> corresponds to a primitive type
  42. (or a string type) then the contents of the B<ASN1_STRING> contain the content
  43. octets of the type. If I<type> corresponds to a constructed type or
  44. a tagged type (B<V_ASN1_SEQUENCE>, B<V_ASN1_SET> or B<V_ASN1_OTHER>) then the
  45. B<ASN1_STRING> contains the entire ASN.1 encoding verbatim (including tag and
  46. length octets).
  47. ASN1_TYPE_cmp() may not return zero if two types are equivalent but have
  48. different encodings. For example the single content octet of the boolean TRUE
  49. value under BER can have any nonzero encoding but ASN1_TYPE_cmp() will
  50. only return zero if the values are the same.
  51. If either or both of the parameters passed to ASN1_TYPE_cmp() is NULL the
  52. return value is nonzero. Technically if both parameters are NULL the two
  53. types could be absent OPTIONAL fields and so should match, however, passing
  54. NULL values could also indicate a programming error (for example an
  55. unparsable type which returns NULL) for types which do B<not> match. So
  56. applications should handle the case of two absent values separately.
  57. =head1 RETURN VALUES
  58. ASN1_TYPE_get() returns the type of the B<ASN1_TYPE> argument.
  59. ASN1_TYPE_set() does not return a value.
  60. ASN1_TYPE_set1() returns 1 for success and 0 for failure.
  61. ASN1_TYPE_cmp() returns 0 if the types are identical and nonzero otherwise.
  62. ASN1_TYPE_unpack_sequence() returns a pointer to an ASN.1 structure or
  63. NULL on failure.
  64. ASN1_TYPE_pack_sequence() return an B<ASN1_TYPE> structure if it succeeds or
  65. NULL on failure.
  66. =head1 COPYRIGHT
  67. Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
  68. Licensed under the Apache License 2.0 (the "License"). You may not use
  69. this file except in compliance with the License. You can obtain a copy
  70. in the file LICENSE in the source distribution or at
  71. L<https://www.openssl.org/source/license.html>.
  72. =cut