OSSL_CMP_ITAV_set0.pod 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. =pod
  2. =head1 NAME
  3. OSSL_CMP_ITAV_create,
  4. OSSL_CMP_ITAV_set0,
  5. OSSL_CMP_ITAV_get0_type,
  6. OSSL_CMP_ITAV_get0_value,
  7. OSSL_CMP_ITAV_push0_stack_item,
  8. OSSL_CMP_ITAV_new0_certProfile,
  9. OSSL_CMP_ITAV_get0_certProfile
  10. - OSSL_CMP_ITAV utility functions
  11. =head1 SYNOPSIS
  12. #include <openssl/cmp.h>
  13. OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
  14. void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
  15. ASN1_TYPE *value);
  16. ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
  17. ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
  18. int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p,
  19. OSSL_CMP_ITAV *itav);
  20. OSSL_CMP_ITAV
  21. *OSSL_CMP_ITAV_new0_certProfile(STACK_OF(ASN1_UTF8STRING) *certProfile);
  22. int OSSL_CMP_ITAV_get0_certProfile(const OSSL_CMP_ITAV *itav,
  23. STACK_OF(ASN1_UTF8STRING) **out);
  24. =head1 DESCRIPTION
  25. ITAV is short for InfoTypeAndValue. This type is defined in RFC 4210
  26. section 5.3.19 and Appendix F. It is used at various places in CMP messages,
  27. e.g., in the generalInfo PKIHeader field, to hold a key-value pair.
  28. OSSL_CMP_ITAV_create() creates a new B<OSSL_CMP_ITAV> structure and fills it in.
  29. It combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0().
  30. OSSL_CMP_ITAV_set0() sets the I<itav> with an infoType of I<type> and an
  31. infoValue of I<value>. This function uses the pointers I<type> and I<value>
  32. internally, so they must B<not> be freed up after the call.
  33. OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the
  34. I<itav>.
  35. OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in
  36. the I<itav> as generic B<ASN1_TYPE> pointer.
  37. OSSL_CMP_ITAV_push0_stack_item() pushes I<itav> to the stack pointed to
  38. by I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL.
  39. OSSL_CMP_ITAV_new0_certProfile() creates a new B<OSSL_CMP_ITAV> structure
  40. of type B<certProfile> that includes the optionally given list of profile names.
  41. On success, ownership of the list is with the new B<OSSL_CMP_ITAV> structure.
  42. OSSL_CMP_ITAV_get0_certProfile() on success assigns to I<*out>
  43. an internal pointer to the
  44. list of certificate profile names contained in the infoValue field of I<itav>.
  45. The pointer may be NULL if no profile name is included.
  46. It is an error if the infoType of I<itav> is not B<certProfile>.
  47. =head1 NOTES
  48. CMP is defined in RFC 4210 and RFC 9480 (and CRMF in RFC 4211).
  49. OIDs to use as types in B<OSSL_CMP_ITAV> can be found at
  50. L<https://datatracker.ietf.org/doc/html/rfc9480#section-4.2.2>.
  51. The respective OpenSSL NIDs, such as B<NID_id_it_certProfile>,
  52. are defined in the F<< <openssl/obj_mac.h> >> header file.
  53. =head1 RETURN VALUES
  54. OSSL_CMP_ITAV_create() and OSSL_CMP_ITAV_new0_certProfile()
  55. return a pointer to an ITAV structure on success, or NULL on error.
  56. OSSL_CMP_ITAV_set0() does not return a value.
  57. OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value()
  58. return the respective pointer or NULL if their input is NULL.
  59. OSSL_CMP_ITAV_push0_stack_item() and OSSL_CMP_ITAV_get0_certProfile()
  60. return 1 on success, 0 on error.
  61. =head1 EXAMPLES
  62. The following code creates and sets a structure representing a generic
  63. InfoTypeAndValue sequence, using an OID created from text as type, and an
  64. integer as value. Afterwards, it is pushed to the B<OSSL_CMP_CTX> to be later
  65. included in the requests' PKIHeader's genInfo field.
  66. ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1);
  67. if (type == NULL) ...
  68. ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
  69. if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ...
  70. ASN1_TYPE *val = ASN1_TYPE_new();
  71. if (val == NULL) ...
  72. ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int);
  73. OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val);
  74. if (itav == NULL) ...
  75. if (!OSSL_CMP_CTX_push0_geninfo_ITAV(ctx, itav)) {
  76. OSSL_CMP_ITAV_free(itav); /* also frees type and val */
  77. ...
  78. }
  79. ...
  80. OSSL_CMP_CTX_free(ctx); /* also frees itav */
  81. =head1 SEE ALSO
  82. L<OSSL_CMP_CTX_new(3)>, L<OSSL_CMP_CTX_free(3)>, L<ASN1_TYPE_set(3)>
  83. =head1 HISTORY
  84. The OpenSSL CMP support was added in OpenSSL 3.0.
  85. OSSL_CMP_ITAV_new0_certProfile() and OSSL_CMP_ITAV_get0_certProfile()
  86. were added in OpenSSL 3.3.
  87. =head1 COPYRIGHT
  88. Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
  89. Licensed under the Apache License 2.0 (the "License"). You may not use
  90. this file except in compliance with the License. You can obtain a copy
  91. in the file LICENSE in the source distribution or at
  92. L<https://www.openssl.org/source/license.html>.
  93. =cut